diff --git a/composer.json b/composer.json index 0aadc52..20c18d5 100644 --- a/composer.json +++ b/composer.json @@ -5,8 +5,8 @@ "require": { "php": ">=8.1", "nette/utils": "^3.2", - "nikic/php-parser": "^4.16", - "symfony/yaml": "^6.2" + "nikic/php-parser": "^4.18", + "symfony/yaml": "^6.4" }, "require-dev": { "myclabs/php-enum": "^1.8", @@ -18,10 +18,7 @@ "symplify/easy-coding-standard": "^12.0", "symplify/easy-testing": "^11.1", "symplify/phpstan-extensions": "^11.2", - "symplify/phpstan-rules": "^12.0", - "symplify/symplify-kernel": "^11.0", - "tomasvotruba/class-leak": "0.1.1.72", - "tomasvotruba/unused-public": "^0.2.0" + "tomasvotruba/class-leak": "^0.2" }, "autoload": { "psr-4": { diff --git a/config/config.php b/config/config.php index dcb7348..8602ec9 100644 --- a/config/config.php +++ b/config/config.php @@ -7,6 +7,11 @@ use PhpParser\NodeVisitor\ParentConnectingVisitor; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use Symfony\Component\Yaml\Parser; +use Symplify\PhpConfigPrinter\Contract\CaseConverterInterface; +use Symplify\PhpConfigPrinter\Contract\RoutingCaseConverterInterface; +use Symplify\PhpConfigPrinter\NodeFactory\ContainerConfiguratorReturnClosureFactory; +use Symplify\PhpConfigPrinter\NodeFactory\RoutingConfiguratorReturnClosureFactory; +use function Symfony\Component\DependencyInjection\Loader\Configurator\tagged_iterator; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); @@ -18,6 +23,22 @@ $services->load('Symplify\PhpConfigPrinter\\', __DIR__ . '/../src') ->exclude([__DIR__ . '/../src/ValueObject']); + $services->load( + 'Symplify\\PhpConfigPrinter\\CaseConverter\\', + __DIR__ . '/../src/CaseConverter' + )->tag(CaseConverterInterface::class); + + $services->load( + 'Symplify\\PhpConfigPrinter\\RoutingCaseConverter\\', + __DIR__ . '/../src/RoutingCaseConverter' + )->tag(RoutingCaseConverterInterface::class); + + $services->set(ContainerConfiguratorReturnClosureFactory::class) + ->arg('$caseConverters', tagged_iterator(CaseConverterInterface::class)); + + $services->set(RoutingConfiguratorReturnClosureFactory::class) + ->arg('$routingCaseConverters', tagged_iterator(RoutingCaseConverterInterface::class)); + $services->set(NodeFinder::class); $services->set(Parser::class); $services->set(BuilderFactory::class); diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon deleted file mode 100644 index 45a65e5..0000000 --- a/phpstan-baseline.neon +++ /dev/null @@ -1,31 +0,0 @@ -parameters: - ignoreErrors: - - - message: "#^Parameter \\#1 \\$items of class PhpParser\\\\Node\\\\Expr\\\\Array_ constructor expects array\\, array\\ given\\.$#" - count: 1 - path: src/NodeFactory/NewValueObjectFactory.php - - - - message: "#^Parameter \\#1 \\$objectOrClass of class ReflectionClass constructor expects class\\-string\\\\|T of object, string given\\.$#" - count: 1 - path: src/NodeFactory/NewValueObjectFactory.php - - - - message: "#^Method Symplify\\\\PhpConfigPrinter\\\\NodeFinder\\\\TypeAwareNodeFinder\\:\\:findFirstInstanceOf\\(\\) should return \\(TNode of PhpParser\\\\Node\\)\\|null but returns PhpParser\\\\Node\\|null\\.$#" - count: 1 - path: src/NodeFinder/TypeAwareNodeFinder.php - - - - message: "#^Method Symplify\\\\PhpConfigPrinter\\\\NodeFinder\\\\TypeAwareNodeFinder\\:\\:findInstanceOf\\(\\) should return array\\ but returns array\\\\.$#" - count: 1 - path: src/NodeFinder/TypeAwareNodeFinder.php - - - - message: "#^Parameter \\#1 \\$nodes of method PhpParser\\\\PrettyPrinterAbstract\\:\\:pCommaSeparatedMultiline\\(\\) expects array\\, array\\ given\\.$#" - count: 1 - path: src/Printer/PhpParserPhpConfigPrinter.php - - - - message: "#^Parameter \\#1 \\$objectOrClass of class ReflectionClass constructor expects class\\-string\\\\|T of object, string given\\.$#" - count: 1 - path: src/Reflection/ConstantNameFromValueResolver.php diff --git a/phpstan.neon b/phpstan.neon index 3f54791..6cf6292 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,8 +1,5 @@ -includes: - - phpstan-baseline.neon - parameters: - level: 8 + level: 6 paths: - src @@ -14,3 +11,4 @@ parameters: - '*/tests/**/data/*' ignoreErrors: + - '#Parameter \#1 \$items of class PhpParser\\Node\\Expr\\Array_ constructor expects array, array given#' diff --git a/src/NodeFactory/ContainerConfiguratorReturnClosureFactory.php b/src/NodeFactory/ContainerConfiguratorReturnClosureFactory.php index 3b0193b..aab7118 100644 --- a/src/NodeFactory/ContainerConfiguratorReturnClosureFactory.php +++ b/src/NodeFactory/ContainerConfiguratorReturnClosureFactory.php @@ -32,7 +32,7 @@ final class ContainerConfiguratorReturnClosureFactory */ public function __construct( private readonly ConfiguratorClosureNodeFactory $configuratorClosureNodeFactory, - private readonly array $caseConverters, + private readonly iterable $caseConverters, private readonly ContainerNestedNodesFactory $containerNestedNodesFactory ) { } diff --git a/src/NodeFactory/RoutingConfiguratorReturnClosureFactory.php b/src/NodeFactory/RoutingConfiguratorReturnClosureFactory.php index 7c1e68e..c5070b9 100644 --- a/src/NodeFactory/RoutingConfiguratorReturnClosureFactory.php +++ b/src/NodeFactory/RoutingConfiguratorReturnClosureFactory.php @@ -9,9 +9,6 @@ use Symplify\PhpConfigPrinter\Contract\RoutingCaseConverterInterface; use Symplify\PhpConfigPrinter\PhpParser\NodeFactory\ConfiguratorClosureNodeFactory; -/** - * @api - */ final class RoutingConfiguratorReturnClosureFactory { /** @@ -19,7 +16,7 @@ final class RoutingConfiguratorReturnClosureFactory */ public function __construct( private readonly ConfiguratorClosureNodeFactory $containerConfiguratorClosureNodeFactory, - private readonly array $routingCaseConverters + private readonly iterable $routingCaseConverters ) { }