Skip to content

Commit

Permalink
Merge pull request #25 from 21TORR/remove-deprecations
Browse files Browse the repository at this point in the history
Prepare v3
  • Loading branch information
apfelbox authored Jun 20, 2024
2 parents a34c17c + f804fe8 commit 29f92a5
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 115 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
3.0.0
=====

* (bc) Remove deprecated config and code.
* (improvement) Require Symfony 7.


2.1.3
=====

Expand Down
21 changes: 10 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,17 @@
"ext-intl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"21torr/bundle-helpers": "^2.1",
"21torr/cli": "^1.0.3",
"21torr/bundle-helpers": "^2.2",
"21torr/cli": "^1.2.3",
"psr/log": "^3.0",
"symfony/cache-contracts": "^3.4",
"symfony/clock": "^6.4 || ^7.0",
"symfony/config": "^6.4 || ^7.0",
"symfony/console": "^6.4 || ^7.0",
"symfony/dependency-injection": "^6.4 || ^7.0",
"symfony/deprecation-contracts": "^3.4",
"symfony/event-dispatcher-contracts": "^3.4",
"symfony/filesystem": "^6.4 || ^7.0",
"symfony/process": "^6.4 || ^7.0"
"symfony/cache-contracts": "^3.5",
"symfony/clock": "^7.0",
"symfony/config": "^7.0",
"symfony/console": "^7.0",
"symfony/dependency-injection": "^7.0",
"symfony/event-dispatcher-contracts": "^3.5",
"symfony/filesystem": "^7.0",
"symfony/process": "^7.0"
},
"require-dev": {
"21torr/janus": "^1.3.4",
Expand Down
13 changes: 1 addition & 12 deletions src/Command/PostBuildTasksCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Torr\Hosting\Deployment\TaskCli;
use Torr\Hosting\Deployment\TaskRunners;

#[AsCommand("hosting:run-tasks:post-build", aliases: ["hosting:post-build"])]
#[AsCommand("hosting:run-tasks:post-build")]
final class PostBuildTasksCommand extends Command
{
private TaskRunners $runners;
Expand All @@ -29,17 +29,6 @@ public function __construct(TaskRunners $runners)
protected function execute (InputInterface $input, OutputInterface $output) : int
{
$io = new TaskCli($input, $output);

// @todo remove in v3 and remove alias above
if ("hosting:run-tasks:post-build" !== $input->getFirstArgument())
{
trigger_deprecation("21torr/hosting", "2.1.0", "The command name '{$input->getFirstArgument()}' was deprecated. Use 'hosting:run-tasks:post-build' instead.");
$io->caution(sprintf(
"The command name `%s` was deprecated.\nUse `hosting:run-tasks:post-build` instead.",
$input->getFirstArgument(),
));
}

$io->title("Run Post Build Tasks");

$this->runners->runPostBuild($io);
Expand Down
14 changes: 1 addition & 13 deletions src/Command/PostDeploymentTasksCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Torr\Hosting\Deployment\TaskCli;
use Torr\Hosting\Deployment\TaskRunners;

#[AsCommand("hosting:run-tasks:post-deploy", aliases: ["hosting:post-deploy"])]
#[AsCommand("hosting:run-tasks:post-deploy")]
final class PostDeploymentTasksCommand extends Command
{
private TaskRunners $runners;
Expand All @@ -28,18 +28,6 @@ public function __construct(TaskRunners $runners)
*/
protected function execute(InputInterface $input, OutputInterface $output) : int
{
$io = new TaskCli($input, $output);

// @todo remove in v3 and remove alias above
if ("hosting:run-tasks:post-deploy" !== $input->getFirstArgument())
{
trigger_deprecation("21torr/hosting", "2.1.0", "The command name '{$input->getFirstArgument()}' was deprecated. Use 'hosting:run-tasks:post-deploy' instead.");
$io->caution(sprintf(
"The command name `%s` was deprecated.\nUse `hosting:run-tasks:post-deploy` instead.",
$input->getFirstArgument(),
));
}

$io = new TaskCli($input, $output);
$io->title("Run Post Deployment Tasks");

Expand Down
31 changes: 3 additions & 28 deletions src/Hosting/HostingEnvironment.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,12 @@ public function __construct (
}

/**
* @todo refactor in v3
*/
private function getHostingTier (string|HostingTier $tier) : HostingTier
{
if ($tier instanceof HostingTier)
{
return $tier;
}

if ("live" === $tier)
{
// @phpstan-ignore-next-line todoBy.sfDeprecation
trigger_deprecation("21torr/hosting", "2.1.0", "The hosting tier 'live' is deprecated. Use 'production' instead.");

return HostingTier::PRODUCTION;
}

return HostingTier::from($tier);
return $tier instanceof HostingTier
? $tier
: HostingTier::from($tier);
}

/**
Expand All @@ -53,19 +41,6 @@ public function isStaging () : bool
return HostingTier::STAGING === $this->tier;
}

/**
* @deprecated use {@see self::isProduction()} instead
*
* @todo remove in v3
*/
public function isLive () : bool
{
// @phpstan-ignore-next-line todoBy.sfDeprecation
trigger_deprecation("21torr/hosting", "2.1.0", "The hosting tier 'live' is deprecated. Use 'production' instead.");

return $this->isProduction();
}

/**
*/
public function isProduction () : bool
Expand Down
12 changes: 1 addition & 11 deletions src/Tier/HostingTier.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
*/
enum HostingTier : string
{
/**
* @deprecated
*
* @todo remove in v3
*/
case LIVE = "live";
case PRODUCTION = "production";
case STAGING = "staging";
case DEVELOPMENT = "development";
Expand All @@ -25,11 +19,7 @@ public static function getAllowedConfigValues () : array

foreach (self::cases() as $tier)
{
// @phpstan-ignore-next-line classConstant.deprecated
if (self::LIVE !== $tier)
{
$result[] = $tier->value;
}
$result[] = $tier->value;
}

return $result;
Expand Down
40 changes: 0 additions & 40 deletions tests/Hosting/HostingEnvironmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
namespace Tests\Torr\Hosting\Hosting;

use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
use Symfony\Component\Config\Definition\Processor;
use Torr\Hosting\DependencyInjection\HostingBundleConfiguration;
use Torr\Hosting\Hosting\HostingEnvironment;
use Torr\Hosting\Tier\HostingTier;

Expand All @@ -14,8 +11,6 @@
*/
final class HostingEnvironmentTest extends TestCase
{
use ExpectDeprecationTrait;

/**
*/
public function testInstallationKey () : void
Expand Down Expand Up @@ -57,39 +52,4 @@ public function testHostingTiers (string|HostingTier $value, HostingTier $expect
$environment = new HostingEnvironment($value, "installation");
self::assertSame($expected, $environment->getTier());
}

/**
* @group legacy
*/
public function testLegacyLiveHostingTier () : void
{
$this->expectDeprecation("Since 21torr/hosting 2.1.0: The hosting tier 'live' is deprecated. Use 'production' instead.");
$environment = new HostingEnvironment("live", "installation");
self::assertSame(HostingTier::PRODUCTION, $environment->getTier());
}

/**
* @group legacy
*/
public function testLegacyLiveHostingTierGetter () : void
{
$this->expectDeprecation("Since 21torr/hosting 2.1.0: The hosting tier 'live' is deprecated. Use 'production' instead.");
$environment = new HostingEnvironment(HostingTier::PRODUCTION, "installation");
self::assertTrue($environment->isLive());
}

/**
* @group legacy
*/
public function testLegacyConfigValues () : void
{
$config = new HostingBundleConfiguration();
$configProcessor = new Processor();
$resolved = $configProcessor->processConfiguration($config, [[
"tier" => "live",
]]);

// live is explicitly allowed
self::assertSame("live", $resolved["tier"]);
}
}

0 comments on commit 29f92a5

Please sign in to comment.