Skip to content

Conversation

@staabm
Copy link
Contributor

@staabm staabm commented Dec 23, 2025

with static calls assertion-calls do not affect remembered non-static properties.

in addition assertion methods are declared static so we don't need to process ignored errors for these lines


before PR

➜  phpstan-src git:(2.1.x) ✗ hyperfine 'bin/phpstan analyze tests/PHPStan/Analyser/AnalyserIntegrationTest.php' --runs=5
Benchmark 1: bin/phpstan analyze tests/PHPStan/Analyser/AnalyserIntegrationTest.php
  Time (mean ± σ):      2.537 s ±  0.047 s    [User: 2.224 s, System: 0.279 s]
  Range (min … max):    2.508 s …  2.620 s    5 runs

after PR

➜  phpstan-src git:(this-self) ✗ hyperfine 'bin/phpstan analyze tests/PHPStan/Analyser/AnalyserIntegrationTest.php' --runs=5
Benchmark 1: bin/phpstan analyze tests/PHPStan/Analyser/AnalyserIntegrationTest.php
  Time (mean ± σ):      2.526 s ±  0.016 s    [User: 2.220 s, System: 0.281 s]
  Range (min … max):    2.513 s …  2.554 s    5 runs

static calls can be analyzed faster by PHPStan (less scope managment required)
@ondrejmirtes
Copy link
Member

I kind of disagree with this one. PHPUnit documentation allows both, and because of years of muscle memory I still use $this-> myself.

If anything we should have ignoreErrors entry with reportUnmatched: false in phpstan-phpunit so that people don't have to ignore this on their own. Or an IgnoreErrorsExtension.

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.

2 participants