diff --git a/doc/tasks/tester.md b/doc/tasks/tester.md index a8eff8f2..d1fb799c 100644 --- a/doc/tasks/tester.md +++ b/doc/tasks/tester.md @@ -29,6 +29,8 @@ grumphp: colors: ~ coverage: ~ coverage_src: ~ + php_ini_configuration_path: null + load_php_ini_configuration: false ``` **path** @@ -102,3 +104,15 @@ Example: `coverage.html` or `coverage.xml` *Default: null* This is issued with the `coverage` option. This is a path to the source code for which we generate the report. + +**php_ini_configuration_path** + +*Default: null* + +The Tester runs PHP processes from custom php.ini file. + +**default_php_ini_configuration** + +*Default: false* + +When this option is set to `true`, Tester runs PHP processes with system configuration .ini files. diff --git a/src/Parser/Php/Visitor/ForbiddenStaticMethodCallsVisitor.php b/src/Parser/Php/Visitor/ForbiddenStaticMethodCallsVisitor.php index 089b61ac..7e4f7c50 100644 --- a/src/Parser/Php/Visitor/ForbiddenStaticMethodCallsVisitor.php +++ b/src/Parser/Php/Visitor/ForbiddenStaticMethodCallsVisitor.php @@ -37,11 +37,16 @@ public function configure(array $options): void */ public function leaveNode(Node $node): void { - if (!$node instanceof Node\Expr\StaticCall) { + if (!$node instanceof Node\Expr\StaticCall || !$node->class instanceof Node\Name) { return; } + /** + * https://github.com/nikic/PHP-Parser/releases/tag/v4.16.0 + * @psalm-suppress DeprecatedProperty + */ $class = implode('\\', $node->class->parts); + $method = $node->name; $normalized = sprintf('%s::%s', $class, $method); diff --git a/src/Task/Tester.php b/src/Task/Tester.php index b1768077..0f94b281 100644 --- a/src/Task/Tester.php +++ b/src/Task/Tester.php @@ -34,6 +34,8 @@ public static function getConfigurableOptions(): ConfigOptionsResolver 'colors' => null, 'coverage' => null, 'coverage_src' => null, + 'php_ini_configuration_path' => null, + 'default_php_ini_configuration' => false, ]); $resolver->addAllowedTypes('path', ['string']); @@ -48,6 +50,8 @@ public static function getConfigurableOptions(): ConfigOptionsResolver $resolver->addAllowedTypes('colors', ['null', 'int']); $resolver->addAllowedTypes('coverage', ['null', 'string']); $resolver->addAllowedTypes('coverage_src', ['null', 'string']); + $resolver->addAllowedTypes('php_ini_configuration_path', ['null', 'string']); + $resolver->addAllowedTypes('default_php_ini_configuration', ['bool']); return ConfigOptionsResolver::fromOptionsResolver($resolver); } @@ -80,6 +84,8 @@ public function run(ContextInterface $context): TaskResultInterface $arguments->addOptionalIntegerArgument('%s', $config['colors']); $arguments->addOptionalArgumentWithSeparatedValue('--coverage', $config['coverage']); $arguments->addOptionalArgumentWithSeparatedValue('--coverage-src', $config['coverage_src']); + $arguments->addOptionalArgumentWithSeparatedValue('-c', $config['php_ini_configuration_path']); + $arguments->addOptionalArgument('-C', $config['default_php_ini_configuration']); $process = $this->processBuilder->buildProcess($arguments); $process->run(); diff --git a/test/Unit/Task/TesterTest.php b/test/Unit/Task/TesterTest.php index f7a1174f..e61822f6 100644 --- a/test/Unit/Task/TesterTest.php +++ b/test/Unit/Task/TesterTest.php @@ -37,6 +37,8 @@ public function provideConfigurableOptions(): iterable 'colors' => null, 'coverage' => null, 'coverage_src' => null, + 'php_ini_configuration_path' => null, + 'default_php_ini_configuration' => false, ] ]; } @@ -255,5 +257,28 @@ public function provideExternalTaskRuns(): iterable 'coverageSrdFile', ] ]; + yield 'php_ini_configuration_path' => [ + [ + 'php_ini_configuration_path' => 'customPhpIniFile', + ], + $this->mockContext(RunContext::class, ['helloTest.php', 'hello2Test.php']), + 'tester', + [ + '.', + '-c', + 'customPhpIniFile', + ] + ]; + yield 'default_php_ini_configuration' => [ + [ + 'default_php_ini_configuration' => true, + ], + $this->mockContext(RunContext::class, ['helloTest.php', 'hello2Test.php']), + 'tester', + [ + '.', + '-C', + ] + ]; } }