Skip to content

update phpstan/phpstan-phpunit#5972

Merged
staabm merged 1 commit into
phpstan:2.2.xfrom
staabm:up-unit
Jul 9, 2026
Merged

update phpstan/phpstan-phpunit#5972
staabm merged 1 commit into
phpstan:2.2.xfrom
staabm:up-unit

Conversation

@staabm

@staabm staabm commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

fixes the CI build error in e2e/result-cache-restore-without-reflection because of a outdated phpstan-phpunit version:

In Resolver.php line 677:
                                                                               
  [Nette\DI\ServiceCreationException]                                          
  Service of type PHPStan\Rules\PHPUnit\AttributeRequiresPhpVersionRule: Para  
  meter $deprecationRulesInstalled in AttributeRequiresPhpVersionRule::__cons  
  truct() has no class type or default value, so its value must be specified.  
                                                                               

Exception trace:
  at /home/runner/work/phpstan-src/phpstan-src/vendor/nette/di/src/DI/Resolver.php:677
 Nette\DI\Resolver::autowireArgument() at /home/runner/work/phpstan-src/phpstan-src/vendor/nette/di/src/DI/Resolver.php:572
 Nette\DI\Resolver::autowireArguments() at /home/runner/work/phpstan-src/phpstan-src/vendor/nette/di/src/DI/Resolver.php:229
 Nette\DI\Resolver->completeStatement() at /home/runner/work/phpstan-src/phpstan-src/vendor/nette/di/src/DI/Definitions/ServiceDefinition.php:178
 Nette\DI\Definitions\ServiceDefinition->complete() at /home/runner/work/phpstan-src/phpstan-src/vendor/nette/di/src/DI/Resolver.php:173
 Nette\DI\Resolver->completeDefinition() at /home/runner/work/phpstan-src/phpstan-src/vendor/nette/di/src/DI/ContainerBuilder.php:338
 Nette\DI\ContainerBuilder->complete() at /home/runner/work/phpstan-src/phpstan-src/vendor/nette/di/src/DI/Compiler.php:275
 Nette\DI\Compiler->processBeforeCompile() at /home/runner/work/phpstan-src/phpstan-src/vendor/nette/di/src/DI/Compiler.php:212
 Nette\DI\Compiler->compile() at /home/runner/work/phpstan-src/phpstan-src/vendor/nette/di/src/DI/ContainerLoader.php:119
 Nette\DI\ContainerLoader->generate() at /home/runner/work/phpstan-src/phpstan-src/vendor/nette/di/src/DI/ContainerLoader.php:80
 Nette\DI\ContainerLoader->loadFile() at /home/runner/work/phpstan-src/phpstan-src/vendor/nette/di/src/DI/ContainerLoader.php:44
 Nette\DI\ContainerLoader->load() at /home/runner/work/phpstan-src/phpstan-src/src/DependencyInjection/Configurator.php:111
 PHPStan\DependencyInjection\Configurator->loadContainer() at /home/runner/work/phpstan-src/phpstan-src/vendor/nette/bootstrap/src/Bootstrap/Configurator.php:258
 Nette\Bootstrap\Configurator->createContainer() at /home/runner/work/phpstan-src/phpstan-src/src/DependencyInjection/Configurator.php:226
 PHPStan\DependencyInjection\Configurator->createContainer() at /home/runner/work/phpstan-src/phpstan-src/src/DependencyInjection/ContainerFactory.php:164
 PHPStan\DependencyInjection\ContainerFactory->create() at /home/runner/work/phpstan-src/phpstan-src/src/Command/CommandHelper.php:388
 PHPStan\Command\CommandHelper::begin() at /home/runner/work/phpstan-src/phpstan-src/src/Command/AnalyseCommand.php:179
 PHPStan\Command\AnalyseCommand->execute() at /home/runner/work/phpstan-src/phpstan-src/vendor/symfony/console/Command/Command.php:298
 Symfony\Component\Console\Command\Command->run() at /home/runner/work/phpstan-src/phpstan-src/vendor/symfony/console/Application.php:1040
 Symfony\Component\Console\Application->doRunCommand() at /home/runner/work/phpstan-src/phpstan-src/vendor/symfony/console/Application.php:301
 Symfony\Component\Console\Application->doRun() at /home/runner/work/phpstan-src/phpstan-src/vendor/symfony/console/Application.php:171
 Symfony\Component\Console\Application->run() at /home/runner/work/phpstan-src/phpstan-src/bin/phpstan:139
 {closure}() at /home/runner/work/phpstan-src/phpstan-src/bin/phpstan:140

@staabm

staabm commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

the errors we see here are related to phpstan-src analyzing the codebase with a fixed PHP_VERSION_ID and the phpversion is compared since phpstan/phpstan-phpunit#269 against #[RequiresPhp('<= 8.5')].

I am not yet sure how/where to fix it properly

@ondrejmirtes

Copy link
Copy Markdown
Member

Why is this rule reporting a problem in this situation when an ordinary PHP_VERSION_ID < 80200 does not?

Also I'd argue the error message of the rule should be improved. "Version requirement will always evaluate to false." doesn't tell the left and right side of the comparison (and also what the comparison is). All of that would improve the error message.

@staabm

staabm commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

I factored out the logic which was responsible for ignoring this kind of error when a single specific phpversion is configured with #6014 and re-used it further in #6017

in phpstan/phpstan-phpunit#315 I will make sure the same logic applies to phpstan-phpunit

@staabm staabm marked this pull request as ready for review July 9, 2026 05:33
@staabm staabm merged commit 43e9d32 into phpstan:2.2.x Jul 9, 2026
670 checks passed
@staabm staabm deleted the up-unit branch July 9, 2026 05:34
@phpstan-bot

Copy link
Copy Markdown
Collaborator

This pull request has been marked as ready for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants