diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b6a0777..9aecb50 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: - php: ['8.2', '8.3'] + php: ['8.3'] steps: - name: Checkout Code diff --git a/CHANGELOG.md b/CHANGELOG.md index 14669eb..40af76c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +2.3.0 +===== + +* (feature) Add proper types for configurable bundle extension. +* (internal) Update CI. +* (improvement) Require Symfony 7 and PHP 8.3+ + + 2.2.0 ===== diff --git a/composer.json b/composer.json index 18ea169..787bb8e 100644 --- a/composer.json +++ b/composer.json @@ -11,15 +11,15 @@ ], "homepage": "https://github.com/21TORR/bundle-helpers", "require": { - "php": ">= 8.2", - "symfony/config": "^6.4 || ^7.0", - "symfony/dependency-injection": "^6.4 || ^7.0", - "symfony/http-kernel": "^6.4 || ^7.0" + "php": ">= 8.3", + "symfony/config": "^7.0", + "symfony/dependency-injection": "^7.0", + "symfony/http-kernel": "^7.0" }, "require-dev": { "bamarni/composer-bin-plugin": "^1.8.2", "roave/security-advisories": "dev-latest", - "symfony/phpunit-bridge": "^7.0" + "symfony/phpunit-bridge": "^7.1" }, "autoload": { "psr-4": { @@ -53,10 +53,11 @@ ], "lint": [ "@composer bin c-norm normalize \"$(pwd)/composer.json\" --indent-style tab --indent-size 1 --dry-run --ansi", - "vendor-bin/cs-fixer/vendor/bin/php-cs-fixer fix --diff --config vendor-bin/cs-fixer/vendor/21torr/php-cs-fixer/.php-cs-fixer.dist.php --dry-run --no-interaction --ansi --using-cache no" + "vendor-bin/cs-fixer/vendor/bin/php-cs-fixer check --diff --config vendor-bin/cs-fixer/vendor/21torr/php-cs-fixer/.php-cs-fixer.dist.php --no-interaction --ansi" ], "test": [ - "vendor-bin/test/vendor/bin/phpstan analyze -c phpstan.neon . --ansi" + "simple-phpunit", + "vendor-bin/phpstan/vendor/bin/phpstan analyze -c phpstan.neon . --ansi -v" ] } } diff --git a/phpstan.neon b/phpstan.neon index 05b3505..a2774e6 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,5 +1,8 @@ includes: - - vendor-bin/test/vendor/21torr/php-cs/phpstan/lib.neon + - vendor-bin/janus/vendor/21torr/janus/phpstan/lib.neon +# If you use simple-phpunit, you need to uncomment the following line. +# Always make sure to first run simple-phpunit and then PHPStan. parameters: - level: 9 + bootstrapFiles: + - vendor/bin/.phpunit/phpunit/vendor/autoload.php diff --git a/phpunit.xml b/phpunit.xml index ce2a66e..de0b74b 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,6 +1,6 @@ @@ -11,6 +11,7 @@ + diff --git a/src/Bundle/BundleExtension.php b/src/Bundle/BundleExtension.php index 792ee4d..35557b7 100644 --- a/src/Bundle/BundleExtension.php +++ b/src/Bundle/BundleExtension.php @@ -18,7 +18,6 @@ class BundleExtension extends Extension private BundleInterface $bundle; private ?string $alias; - public function __construct ( BundleInterface $bundle, ?string $alias = null, @@ -28,7 +27,6 @@ public function __construct ( $this->alias = $alias; } - /** * @inheritDoc */ @@ -36,14 +34,13 @@ public function load (array $configs, ContainerBuilder $container) : void { $configDir = "{$this->bundle->getPath()}/config"; - if (\is_file("{$configDir}/services.yaml")) + if (is_file("{$configDir}/services.yaml")) { $loader = new YamlFileLoader($container, new FileLocator($configDir)); $loader->load("services.yaml"); } } - /** * @inheritDoc */ @@ -56,17 +53,17 @@ public function getAlias () : string $className = \get_class($this->bundle); - if ('Bundle' !== \substr($className, -6)) + if ('Bundle' !== substr($className, -6)) { - throw new BundleHelpersException(\sprintf( + throw new BundleHelpersException(sprintf( "The bundle does not follow the naming convention; you must pass an explicit alias. Its name should end on 'Bundle', but it is '%s'.", $className, )); } - $classBaseNameForNamespacedClass = \strrchr($className, '\\'); + $classBaseNameForNamespacedClass = strrchr($className, '\\'); $classBaseName = false !== $classBaseNameForNamespacedClass - ? \substr($classBaseNameForNamespacedClass, 1, -6) + ? substr($classBaseNameForNamespacedClass, 1, -6) : $className; return Container::underscore($classBaseName); diff --git a/src/Bundle/ConfigurableBundleExtension.php b/src/Bundle/ConfigurableBundleExtension.php index 5c3abcb..d4049b5 100644 --- a/src/Bundle/ConfigurableBundleExtension.php +++ b/src/Bundle/ConfigurableBundleExtension.php @@ -13,10 +13,12 @@ class ConfigurableBundleExtension extends BundleExtension { private ConfigurationInterface $config; - /** @var callable */ + + /** @var callable(array, ContainerBuilder): void */ private $callback; /** + * @param callable(array, ContainerBuilder): void $callback */ public function __construct ( BundleInterface $bundle, @@ -30,7 +32,6 @@ public function __construct ( $this->callback = $callback; } - /** * @inheritDoc */ diff --git a/tests/Bundle/BundleExtensionTest.php b/tests/Bundle/BundleExtensionTest.php index 1d33ae0..ba10eb1 100644 --- a/tests/Bundle/BundleExtensionTest.php +++ b/tests/Bundle/BundleExtensionTest.php @@ -8,6 +8,9 @@ use Torr\BundleHelpers\Bundle\BundleExtension; use Torr\BundleHelpers\Exception\BundleHelpersException; +/** + * @internal + */ final class BundleExtensionTest extends TestCase { /** diff --git a/vendor-bin/c-norm/composer.json b/vendor-bin/c-norm/composer.json index 6294b6a..29d96fe 100644 --- a/vendor-bin/c-norm/composer.json +++ b/vendor-bin/c-norm/composer.json @@ -1,10 +1,11 @@ { - "require": { - "ergebnis/composer-normalize": "^2.41" - }, - "config": { - "allow-plugins": { - "ergebnis/composer-normalize": true - } - } + "require-dev": { + "ergebnis/composer-normalize": "^2.42", + "roave/security-advisories": "dev-latest" + }, + "config": { + "allow-plugins": { + "ergebnis/composer-normalize": true + } + } } diff --git a/vendor-bin/cs-fixer/composer.json b/vendor-bin/cs-fixer/composer.json index 74c4a41..ceadfce 100644 --- a/vendor-bin/cs-fixer/composer.json +++ b/vendor-bin/cs-fixer/composer.json @@ -1,5 +1,6 @@ { - "require": { - "21torr/php-cs-fixer": "^1.0.2" - } + "require-dev": { + "21torr/php-cs-fixer": "^1.1.1", + "roave/security-advisories": "dev-latest" + } } diff --git a/vendor-bin/janus/composer.json b/vendor-bin/janus/composer.json new file mode 100644 index 0000000..8b7c3d9 --- /dev/null +++ b/vendor-bin/janus/composer.json @@ -0,0 +1,8 @@ +{ + "require": { + "21torr/janus": "^1.3" + }, + "require-dev": { + "roave/security-advisories": "dev-latest" + } +} diff --git a/vendor-bin/phpstan/composer.json b/vendor-bin/phpstan/composer.json new file mode 100644 index 0000000..cf165ff --- /dev/null +++ b/vendor-bin/phpstan/composer.json @@ -0,0 +1,21 @@ +{ + "require": { + "php": "^8.3" + }, + "require-dev": { + "phpstan/extension-installer": "^1.3.1", + "phpstan/phpstan": "^1.11", + "phpstan/phpstan-deprecation-rules": "^1.2", + "phpstan/phpstan-doctrine": "^1.4", + "phpstan/phpstan-phpunit": "^1.4", + "phpstan/phpstan-symfony": "^1.4", + "roave/security-advisories": "dev-latest", + "staabm/phpstan-todo-by": "^0.1.25" + }, + "config": { + "sort-packages": true, + "allow-plugins": { + "phpstan/extension-installer": true + } + } +} diff --git a/vendor-bin/test/composer.json b/vendor-bin/test/composer.json deleted file mode 100644 index 8105a33..0000000 --- a/vendor-bin/test/composer.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "require": { - "21torr/php-cs": "^4.0.4" - }, - "config": { - "allow-plugins": { - "phpstan/extension-installer": true, - "ergebnis/composer-normalize": true - } - } -}