diff --git a/composer.json b/composer.json index 7de07557..1fe57fb4 100644 --- a/composer.json +++ b/composer.json @@ -78,6 +78,8 @@ "friendsofphp/php-cs-fixer": "*", "phpstan/extension-installer": "*", "phpstan/phpstan": "*", + "phpstan/phpstan-deprecation-rules": "*", + "phpstan/phpstan-phpunit": "*", "phpstan/phpstan-symfony": "*", "phpunit/phpunit": "^10.5|^11|^12|^13", "rector/rector": "*", diff --git a/phpstan.neon b/phpstan.neon index 1c22ba10..84f792d9 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -5,3 +5,24 @@ parameters: - tests inferPrivatePropertyTypeFromConstructor: true treatPhpDocTypesAsCertain: false + # Same ignores in all the process bundles: not all of them match in each bundle + reportUnmatchedIgnoredErrors: false + ignoreErrors: + # PHPUnit 13 deprecates expectExceptionMessage() (sebastianbergmann/phpunit#6560), still needed with PHPUnit 11 and 12 + - message: '#^Call to deprecated method expectExceptionMessage\(\) of class PHPUnit\\Framework\\TestCase#' + path: tests/* + # Symfony 8.1 deprecates HttpKernel\Bundle\BundleInterface: its replacement does not exist in Symfony 6.4 and 7.4 + - message: '#typehint with deprecated interface Symfony\\Component\\HttpKernel\\Bundle\\BundleInterface#' + path: tests/* + # The tests of the deprecated code of the bundles use it + - message: '#deprecated .*CleverAge\\#' + path: tests/* + # Assertions on values already known by PHPStan, kept as regression checks (or values changed by reference) + - identifier: staticMethod.alreadyNarrowedType + path: tests/* + - identifier: method.alreadyNarrowedType + path: tests/* + - identifier: staticMethod.impossibleType + path: tests/* + - identifier: method.impossibleType + path: tests/* diff --git a/src/Command/ProcessHelpCommand.php b/src/Command/ProcessHelpCommand.php index af865943..4fc0e827 100644 --- a/src/Command/ProcessHelpCommand.php +++ b/src/Command/ProcessHelpCommand.php @@ -85,6 +85,7 @@ public function __construct( TaskRegistry::class, TaskRegistry::class, ); + // @phpstan-ignore property.deprecated (kept for BC until v6.0) $this->container = $taskRegistry; // Same behaviour as before the task registry: any service of the container $taskRegistry = new TaskRegistry($taskRegistry, $taskRegistry); diff --git a/src/Configuration/TaskConfiguration.php b/src/Configuration/TaskConfiguration.php index 9dd6890a..e6031d8d 100644 --- a/src/Configuration/TaskConfiguration.php +++ b/src/Configuration/TaskConfiguration.php @@ -70,6 +70,7 @@ public function __construct( protected string $errorStrategy = self::STRATEGY_SKIP, protected string $logLevel = LogLevel::CRITICAL, ) { + // @phpstan-ignore property.deprecated (kept for BC until v6.0) $this->logErrors = LogLevel::DEBUG !== $logLevel; } diff --git a/src/DependencyInjection/Compiler/UnavailableServicesCompilerPass.php b/src/DependencyInjection/Compiler/UnavailableServicesCompilerPass.php index af76a019..f991d8d4 100644 --- a/src/DependencyInjection/Compiler/UnavailableServicesCompilerPass.php +++ b/src/DependencyInjection/Compiler/UnavailableServicesCompilerPass.php @@ -107,6 +107,7 @@ private function replace(ContainerBuilder $container, string $message, array $cl // The code is needed by the transformer registry: the one of the tag (see TransformerLocatorCompilerPass), // or, for a definition tagged without code (deprecated), the one returned by the bundle transformer $code = $this->getTagCode($original) + // @phpstan-ignore method.deprecated (transformer registered without code, until v6.0) ?? (new \ReflectionClass($class))->newInstanceWithoutConstructor()->getCode(); $definition = new Definition(UnavailableTransformer::class, [$code, $text]); } else { diff --git a/src/Model/SubprocessInstance.php b/src/Model/SubprocessInstance.php index 274b9f4e..e192d587 100644 --- a/src/Model/SubprocessInstance.php +++ b/src/Model/SubprocessInstance.php @@ -71,6 +71,7 @@ public function __construct( self::class, ); $this->environment ??= $consolePath->getEnvironment(); + // @phpstan-ignore property.deprecated (kept for BC until v6.0) $this->logDir = $consolePath->getLogDir().'/process'; $consolePath = $consolePath->getProjectDir().'/bin/console'; } diff --git a/src/Registry/TransformerRegistry.php b/src/Registry/TransformerRegistry.php index 4bbda85b..a21c974b 100644 --- a/src/Registry/TransformerRegistry.php +++ b/src/Registry/TransformerRegistry.php @@ -91,7 +91,9 @@ public function getTransformer(string $code): TransformerInterface if (!$transformer instanceof TransformerInterface) { throw new UnexpectedValueException(\sprintf('The service of the transformer "%s" must implement "%s".', $code, TransformerInterface::class)); } + // @phpstan-ignore method.deprecated (the code returned by getCode() must stay the same until v6.0) if ($code !== $transformer->getCode()) { + // @phpstan-ignore method.deprecated (the code returned by getCode() must stay the same until v6.0) throw new UnexpectedValueException(\sprintf('The transformer "%s" is registered with the code "%s" but its getCode() method returns "%s": both must be the same.', $transformer::class, $code, $transformer->getCode())); } diff --git a/src/Task/Process/CommandRunnerTask.php b/src/Task/Process/CommandRunnerTask.php index da324256..0b87d84e 100644 --- a/src/Task/Process/CommandRunnerTask.php +++ b/src/Task/Process/CommandRunnerTask.php @@ -47,6 +47,7 @@ public function __construct(KernelInterface|string $projectDir) KernelInterface::class, self::class, ); + // @phpstan-ignore property.deprecated (kept for BC until v6.0) $this->kernel = $projectDir; $projectDir = $projectDir->getProjectDir(); } diff --git a/src/Task/Process/ProcessLauncherTask.php b/src/Task/Process/ProcessLauncherTask.php index 2d8a079f..65af78ee 100644 --- a/src/Task/Process/ProcessLauncherTask.php +++ b/src/Task/Process/ProcessLauncherTask.php @@ -74,6 +74,7 @@ public function __construct( KernelInterface::class, self::class, ); + // @phpstan-ignore property.deprecated (kept for BC until v6.0) $this->kernel = $consolePath; $this->environment ??= $consolePath->getEnvironment(); $consolePath = $consolePath->getProjectDir().'/bin/console';