Skip to content

Fix analysis errors reported by PHPStan 2.3 - #362

Open
michielgerritsen wants to merge 2 commits into
masterfrom
fix/phpstan-2.3-analysis-errors
Open

michielgerritsen wants to merge 2 commits into
masterfrom
fix/phpstan-2.3-analysis-errors

Conversation

@michielgerritsen

Copy link
Copy Markdown
Contributor

CI installs dependencies without a lock file, so every run now resolves PHPStan 2.3.x, which reports three errors on untouched master and turns every PR build red, including #361. The PSR-4 loop in ClassLoaderProvider reused the key and value variables of the PSR-0 loop above it; they are now named $psr4Namespace/$psr4Path. PHPStan 2.3 documents the scope parameter of DynamicMethodReturnTypeExtension::getTypeFromMethodCall() as Scope&DependencyTracker, so the extension test now mocks MutatingScope, which satisfies that intersection on 2.3 and still exists on PHPStan 2.0-2.2, where DependencyTracker does not. Worth a look: MutatingScope is outside PHPStan's BC promise, but referencing DependencyTracker directly would fatal on the older PHPStan versions composer.json allows. Verified on PHPStan 2.3.6 and 2.2.14: composer analyze clean, 113 tests green, cs-check clean.

CI installs dependencies without a lock file, so every run now gets
PHPStan 2.3.x, which reports three errors on untouched master and
turns all PR builds red.

The PSR-4 loop in ClassLoaderProvider reused the key and value
variables of the PSR-0 loop above it (foreach.keyOverwrite).

PHPStan 2.3 documents the scope parameter of
DynamicMethodReturnTypeExtension::getTypeFromMethodCall() as
Scope&DependencyTracker. The test now mocks MutatingScope, which
satisfies both there and still works on PHPStan 2.0-2.2, where
DependencyTracker does not exist.
Since PHPStan 2.3 "diagnose" reports the turbo extension as loaded
by the restart an analyse run performs instead of "enabled", and
\PHPStanTurbo\ArenaCache, which the arena probe loaded, no longer
exists. The REQUIRE_TURBO guard therefore failed on CI although the
analyse run does load turbo.

The worker binary PHPStan names, provided it exists on disk, is now
the signal on the 2.3 wording; the direct arena probe remains for
PHPStan 2.2 and older.
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.

1 participant