re #96 clear PHPStan 'unsafe new static()' via @phpstan-consistent-constructor#108
Merged
Merged
Conversation
…nstructor Annotate the Structure base collections (Map, Set, Queue, Stack, Pair, PriorityQueue) and the two Courier classes that copy themselves through new static() with @phpstan-consistent-constructor. No subclass overrides the inherited constructor, so the annotation documents and enforces a real invariant rather than silencing the checker. The annotation on Map propagates to its subclasses (CookieCollection, SetCookieCollection), clearing their new static() findings too. Regenerate phpstan-baseline.neon: 27 'unsafe new static()' errors across 11 entries drop out; no entries added. Baseline 92 -> 65 errors.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Part of the #96 PHPStan burn-down (Phase 4). Clears all 27
Unsafe usage of new static()findings from the level-6 baseline.Map,Set,Queue,Stack,Pair,PriorityQueue) and the two Courier classes (InMemoryCommandLocatorService,CommandRunnerMiddlewareStrategy) that copy themselves vianew static()with@phpstan-consistent-constructor.Map's annotation propagates toCookieCollection/SetCookieCollection, clearing theirnew static()findings without touching those files.phpstan-baseline.neon: 92 → 65 errors (72 → 62 entries), no entries added.Out of scope (follow-ups)
The remaining baseline entries that looked like "optional-dep class-not-found" turned out to be real API-version-mismatch bugs, not ignorable artifacts — they will be handled in dedicated PRs:
Altair\Http\Jwt\*targets the lcobucci/jwt 3.x API while^5.3is required/installed (security-sensitive; needs migration + security review).FormatNegotiatorusesAcceptHeader::getValue()which is gone in willdurand/negotiation 3.x.Test plan
composer cs— cleancomposer stan—[OK] No errorsvendor/bin/rector process --dry-run(touched files) — cleancomposer test— 5541 pass (the only local errors areMongoSessionHandlerTest, a pre-existing env issue when ext-mongodb is absent; CI loads mongodb)