diff --git a/composer.json b/composer.json index 13430076..4ff61951 100644 --- a/composer.json +++ b/composer.json @@ -25,13 +25,14 @@ "require": { "php": "^7.1", "ext-simplexml": "*", - "phpstan/phpstan": "^0.11.4", + "phpstan/phpstan": "^0.11.7", "nikic/php-parser": "^4.0" }, "require-dev": { "consistence/coding-standard": "^3.0.1", "jakub-onderka/php-parallel-lint": "^1.0", "dealerdirect/phpcodesniffer-composer-installer": "^0.4.4", + "nette/di": "^3.0-stable", "phpunit/phpunit": "^7.0", "phing/phing": "^2.16.0", "phpstan/phpstan-strict-rules": "^0.11", diff --git a/extension.neon b/extension.neon index a98009f5..70249360 100644 --- a/extension.neon +++ b/extension.neon @@ -4,6 +4,13 @@ parameters: constant_hassers: true console_application_loader: null +parametersSchema: + symfony: structure([ + container_xml_path: schema(string(), nullable()) + constant_hassers: bool() + console_application_loader: schema(string(), nullable()) + ]) + rules: - PHPStan\Rules\Symfony\ContainerInterfacePrivateServiceRule - PHPStan\Rules\Symfony\ContainerInterfaceUnknownServiceRule diff --git a/tests/Symfony/NeonTest.php b/tests/Symfony/NeonTest.php index 18b90a9e..dfc57b4c 100644 --- a/tests/Symfony/NeonTest.php +++ b/tests/Symfony/NeonTest.php @@ -4,6 +4,7 @@ use Nette\DI\Compiler; use Nette\DI\ContainerLoader; +use PHPStan\DependencyInjection\ParametersSchemaExtension; use PHPStan\DependencyInjection\RulesExtension; use PHPUnit\Framework\TestCase; use function sprintf; @@ -24,6 +25,7 @@ public function testExtensionNeon(): void $class = $loader->load(function (Compiler $compiler): void { $compiler->addExtension('rules', new RulesExtension()); + $compiler->addExtension('parametersSchema', new ParametersSchemaExtension()); $compiler->addConfig(['parameters' => ['rootDir' => __DIR__]]); $compiler->loadConfig(__DIR__ . '/../../extension.neon'); $compiler->loadConfig(__DIR__ . '/config.neon'); @@ -31,6 +33,9 @@ public function testExtensionNeon(): void /** @var \Nette\DI\Container $container */ $container = new $class(); + $parameters = $container->getParameters(); + unset($parameters['__parametersSchema']); + self::assertSame([ 'rootDir' => __DIR__, 'symfony' => [ @@ -38,7 +43,7 @@ public function testExtensionNeon(): void 'constant_hassers' => true, 'console_application_loader' => null, ], - ], $container->getParameters()); + ], $parameters); self::assertCount(6, $container->findByTag('phpstan.rules.rule')); self::assertCount(11, $container->findByTag('phpstan.broker.dynamicMethodReturnTypeExtension'));