From 9b69a5f1d37ad4be77b561c45c169ff2b1a96412 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Sun, 12 May 2019 19:01:59 +0200 Subject: [PATCH 1/3] Test with bleeding edge --- composer.json | 2 +- phpstan.neon | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 822562eb..13430076 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "require": { "php": "^7.1", "ext-simplexml": "*", - "phpstan/phpstan": "^0.11.1", + "phpstan/phpstan": "^0.11.4", "nikic/php-parser": "^4.0" }, "require-dev": { diff --git a/phpstan.neon b/phpstan.neon index 4dd356bf..d13658e7 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,6 +2,7 @@ includes: - vendor/phpstan/phpstan-phpunit/extension.neon - vendor/phpstan/phpstan-phpunit/rules.neon - vendor/phpstan/phpstan-strict-rules/rules.neon + - vendor/phpstan/phpstan/conf/bleedingEdge.neon parameters: excludes_analyse: From 2ce274ca2846574b4a2e3d79ea8a29a52450613b Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Sun, 12 May 2019 19:04:36 +0200 Subject: [PATCH 2/3] Include extension.neon in phpstan.neon --- phpstan.neon | 1 + 1 file changed, 1 insertion(+) diff --git a/phpstan.neon b/phpstan.neon index d13658e7..8b7b1559 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,4 +1,5 @@ includes: + - extension.neon - vendor/phpstan/phpstan-phpunit/extension.neon - vendor/phpstan/phpstan-phpunit/rules.neon - vendor/phpstan/phpstan-strict-rules/rules.neon From fcaef71e5582d7118fec6c441429768b7bdf0c57 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Sun, 12 May 2019 19:03:54 +0200 Subject: [PATCH 3/3] Forward compatibility - define parameters schema --- composer.json | 3 ++- extension.neon | 7 +++++++ tests/Symfony/NeonTest.php | 7 ++++++- 3 files changed, 15 insertions(+), 2 deletions(-) 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'));