diff --git a/.github/workflows/test-application.yaml b/.github/workflows/test-application.yaml index 2aeff83..1db5c8d 100644 --- a/.github/workflows/test-application.yaml +++ b/.github/workflows/test-application.yaml @@ -19,27 +19,39 @@ jobs: - php-version: '7.2' dependency-versions: 'lowest' tools: 'composer:v1' - php-cs-fixer: false + envs: + SYMFONY_PHPUNIT_REQUIRE: phpspec/prophecy:^1.14 - php-version: '7.4' dependency-versions: 'highest' tools: 'composer:v2' - php-cs-fixer: false + envs: + SYMFONY_PHPUNIT_REQUIRE: phpspec/prophecy:^1.14 - php-version: '8.0' dependency-versions: 'highest' tools: 'composer:v2' - php-cs-fixer: false + envs: + SYMFONY_PHPUNIT_REQUIRE: phpspec/prophecy:^1.14 phpspec/prophecy-phpunit:^2.0 - php-version: '8.1' dependency-versions: 'highest' tools: 'composer:v2' - php-cs-fixer: true + envs: + SYMFONY_PHPUNIT_REQUIRE: phpspec/prophecy:^1.14 phpspec/prophecy-phpunit:^2.0 - php-version: '8.2' dependency-versions: 'highest' tools: 'composer:v2' - php-cs-fixer: false + envs: + SYMFONY_PHPUNIT_REQUIRE: phpspec/prophecy:^1.14 phpspec/prophecy-phpunit:^2.0 + + - php-version: '8.3' + dependency-versions: 'highest' + minimum-stability: 'dev' + tools: 'composer:v2' + envs: + SYMFONY_PHPUNIT_REQUIRE: phpspec/prophecy:^1.14 phpspec/prophecy-phpunit:^2.0 steps: - name: Checkout project @@ -51,13 +63,43 @@ jobs: php-version: ${{ matrix.php-version }} tools: ${{ matrix.tools }} + - name: Set composer stability + if: ${{ matrix.composer-stability }} + run: composer config minimum-stability ${{ matrix.composer-stability }} + - name: Install composer dependencies uses: ramsey/composer-install@v1 with: dependency-versions: ${{matrix.dependency-versions}} + - name: Install PHPUnit + run: vendor/bin/simple-phpunit install + env: + SYMFONY_PHPUNIT_REQUIRE: ${{ matrix.envs.SYMFONY_PHPUNIT_REQUIRE }} + + - name: Execute test cases + run: vendor/bin/simple-phpunit + + lint: + name: 'PHP Lint' + runs-on: ubuntu-latest + + steps: + - name: Checkout project + uses: actions/checkout@v2 + + - name: Install and configure PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.1 + tools: 'composer:v2' + + - name: Install composer dependencies + uses: ramsey/composer-install@v1 + with: + dependency-versions: 'highest' + - name: Run php-cs-fixer - if: ${{ matrix.php-cs-fixer }} run: | composer global require friendsofphp/php-cs-fixer --prefer-dist --no-interaction GLOBAL_BIN_DIR=$(composer global config bin-dir --absolute --quiet) @@ -65,6 +107,3 @@ jobs: - name: Lint code run: composer validate --strict - - - name: Execute test cases - run: vendor/bin/simple-phpunit diff --git a/Build/BuildRegistry.php b/Build/BuildRegistry.php index b6ad163..b1131ce 100644 --- a/Build/BuildRegistry.php +++ b/Build/BuildRegistry.php @@ -11,6 +11,9 @@ namespace Massive\Bundle\BuildBundle\Build; +/** + * @final + */ class BuildRegistry { protected $builders = []; @@ -137,7 +140,7 @@ protected function getUnsequencedBuilders($sequences, $dependencies = null) $dependencies = \array_keys($sequences); } - foreach ($dependencies as $dependency) { + foreach ($dependencies as $dependency) { if (-1 === $sequences[$dependency]) { $unsequencedBuilders[] = $dependency; } diff --git a/Build/BuilderContext.php b/Build/BuilderContext.php index c2a3975..1a2a52c 100644 --- a/Build/BuilderContext.php +++ b/Build/BuilderContext.php @@ -15,6 +15,9 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +/** + * @internal + */ class BuilderContext { protected $input; diff --git a/Builder/VirtualBuilder.php b/Builder/VirtualBuilder.php index ba853d9..149e5f2 100644 --- a/Builder/VirtualBuilder.php +++ b/Builder/VirtualBuilder.php @@ -19,6 +19,8 @@ * dependencies on other builders. * * @author Daniel Leech + * + * @final */ class VirtualBuilder implements BuilderInterface { diff --git a/CHANGELOG.md b/CHANGELOG.md index bea168c..17450ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,18 @@ Changelog for MassiveBuildBundle ================================ +* [0.5.6 (2023-04-05)](https://github.com/massiveart/MassiveBuildBundle/releases/tag/0.5.6) + * Introduce own `ContainerAwareInterface` to keep compatibility with Symfony 7. + +```diff +-use Symfony\Component\DependencyInjection\ContainerAwareInterface; ++use Massive\Bundle\BuildBundle\ContainerAwareInterface; +``` + +* [0.5.5 (2023-03-15)](https://github.com/massiveart/MassiveBuildBundle/releases/tag/0.5.5) + +* [0.5.4 (2022-04-21)](https://github.com/massiveart/MassiveBuildBundle/releases/tag/0.5.4) + * 0.5.3 (2020-11-11) * ENHANCEMENT #20 Fix autoloader for composer 2 diff --git a/Command/BuildCommand.php b/Command/BuildCommand.php index 44a695b..e415636 100644 --- a/Command/BuildCommand.php +++ b/Command/BuildCommand.php @@ -15,6 +15,7 @@ use Massive\Bundle\BuildBundle\Build\BuilderInterface; use Massive\Bundle\BuildBundle\Build\BuildRegistry; use Massive\Bundle\BuildBundle\Console\MassiveOutputFormatter; +use Massive\Bundle\BuildBundle\ContainerAwareInterface; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Helper\Table; @@ -23,9 +24,12 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ConfirmationQuestion; -use Symfony\Component\DependencyInjection\ContainerAwareInterface; +use Symfony\Component\DependencyInjection\ContainerAwareInterface as SymfonyContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerInterface; +/** + * @final + */ class BuildCommand extends Command { /** @@ -61,7 +65,7 @@ public function __construct(BuildRegistry $buildRegistry, ContainerInterface $co $this->question = new QuestionHelper(); } - public function configure() + public function configure(): void { $this->setName('massive:build'); $this->setDescription('Execute build or build targets'); @@ -86,7 +90,7 @@ public function configure() $this->addOption('keep-exit-code', '-k', InputOption::VALUE_NONE, 'Keep the exit code of a job if it fails'); } - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { $this->input = $input; $this->output = $output; @@ -178,7 +182,9 @@ protected function runBuilders($builders) foreach ($builders as $builder) { $this->output->getFormatter()->setIndentLevel(0); - if ($builder instanceof ContainerAwareInterface) { + if ($builder instanceof SymfonyContainerAwareInterface + || $builder instanceof ContainerAwareInterface + ) { $builder->setContainer($this->container); } diff --git a/ContainerAwareInterface.php b/ContainerAwareInterface.php new file mode 100644 index 0000000..45a680b --- /dev/null +++ b/ContainerAwareInterface.php @@ -0,0 +1,17 @@ + + * + * @final + * + * @internal */ class BuilderPass implements CompilerPassInterface { - public function process(ContainerBuilder $container) + public function process(ContainerBuilder $container): void { if (!$container->hasDefinition( 'massive_build.build.registry' diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index dc377ac..2d772fc 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -18,10 +18,14 @@ * This is the class that validates and merges configuration from your app/config files. * * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class} + * + * @final + * + * @internal */ class Configuration implements ConfigurationInterface { - public function getConfigTreeBuilder() + public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder('massive_art_build'); $rootNode = $treeBuilder->getRootNode(); diff --git a/DependencyInjection/MassiveBuildExtension.php b/DependencyInjection/MassiveBuildExtension.php index 66dcfbc..e22eac6 100644 --- a/DependencyInjection/MassiveBuildExtension.php +++ b/DependencyInjection/MassiveBuildExtension.php @@ -21,10 +21,14 @@ * This is the class that loads and manages your bundle configuration. * * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html} + * + * @final + * + * @internal */ class MassiveBuildExtension extends Extension { - public function load(array $configs, ContainerBuilder $container) + public function load(array $configs, ContainerBuilder $container): void { $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); diff --git a/MassiveBuildBundle.php b/MassiveBuildBundle.php index f50636f..219249c 100644 --- a/MassiveBuildBundle.php +++ b/MassiveBuildBundle.php @@ -15,11 +15,13 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\Bundle; +/** + * @final + */ class MassiveBuildBundle extends Bundle { - public function build(ContainerBuilder $container) + public function build(ContainerBuilder $container): void { - parent::build($container); $container->addCompilerPass(new BuilderPass()); } } diff --git a/Tests/Build/BuildRegistryTest.php b/Tests/Build/BuildRegistryTest.php index b30769e..58e3c25 100644 --- a/Tests/Build/BuildRegistryTest.php +++ b/Tests/Build/BuildRegistryTest.php @@ -14,9 +14,12 @@ use Massive\Bundle\BuildBundle\Build\BuilderInterface; use Massive\Bundle\BuildBundle\Build\BuildRegistry; use Massive\Bundle\BuildBundle\Tests\BaseTestCase; +use Massive\Bundle\BuildBundle\Tests\ProphecyTrait; class BuildRegistryTest extends BaseTestCase { + use ProphecyTrait; + /** * @var BuildRegistry */ diff --git a/Tests/Build/BuilderContextTest.php b/Tests/Build/BuilderContextTest.php index 7301a6c..35cb1af 100644 --- a/Tests/Build/BuilderContextTest.php +++ b/Tests/Build/BuilderContextTest.php @@ -13,9 +13,12 @@ use Massive\Bundle\BuildBundle\Build\BuilderContext; use Massive\Bundle\BuildBundle\Tests\BaseTestCase; +use Massive\Bundle\BuildBundle\Tests\ProphecyTrait; class BuilderContextTest extends BaseTestCase { + use ProphecyTrait; + protected $input; protected $output; diff --git a/Tests/Command/BuildCommandTest.php b/Tests/Command/BuildCommandTest.php index 34e7d93..2823f69 100644 --- a/Tests/Command/BuildCommandTest.php +++ b/Tests/Command/BuildCommandTest.php @@ -13,13 +13,16 @@ use Massive\Bundle\BuildBundle\Build\BuilderInterface; use Massive\Bundle\BuildBundle\Command\BuildCommand; +use Massive\Bundle\BuildBundle\ContainerAwareInterface; use Massive\Bundle\BuildBundle\Tests\BaseTestCase; +use Massive\Bundle\BuildBundle\Tests\ProphecyTrait; use Prophecy\Argument; use Symfony\Component\Console\Tester\CommandTester; -use Symfony\Component\DependencyInjection\ContainerAwareInterface; class BuildCommandTest extends BaseTestCase { + use ProphecyTrait; + public function setUp() { parent::setUp(); diff --git a/Tests/ProphecyTrait.php b/Tests/ProphecyTrait.php new file mode 100644 index 0000000..b8887af --- /dev/null +++ b/Tests/ProphecyTrait.php @@ -0,0 +1,14 @@ +=7.2.0", - "symfony/console": "^4.3 || ^5.0 || ^6.0", - "symfony/config": "^4.3 || ^5.0 || ^6.0", - "symfony/dependency-injection": "^4.3 || ^5.0 || ^6.0", - "symfony/framework-bundle": "^4.3 || ^5.0 || ^6.0" + "symfony/console": "^4.3 || ^5.0 || ^6.0 || ^7.0", + "symfony/config": "^4.3 || ^5.0 || ^6.0 || ^7.0", + "symfony/dependency-injection": "^4.3 || ^5.0 || ^6.0 || ^7.0", + "symfony/framework-bundle": "^4.3 || ^5.0 || ^6.0 || ^7.0" }, "require-dev": { - "symfony/phpunit-bridge": "^5.0.4 || ^6.0", - "matthiasnoback/symfony-dependency-injection-test": "^4.0", - "phpspec/prophecy": "^1.14" + "symfony/phpunit-bridge": "^5.4.33|^6.3.10|^7.0.1", + "matthiasnoback/symfony-dependency-injection-test": "^4.0 || ^5.0" }, "autoload": { "psr-4": {"Massive\\Bundle\\BuildBundle\\": "."}, diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 8c3b0f3..3c0c9f3 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -19,5 +19,6 @@ +