PR A: Type constructor $options / $collaborators array shapes#43
Merged
Conversation
`OpenIdConfigurationProvider::__construct(array $options, array $collaborators)` previously took untyped arrays — every `$options['cacheItemPool']`, `$options['cacheDuration']`, `$collaborators['jwt']`, `$options['openIDConnectMetadataUrl']` read flowed as `mixed` into the typed setters (`setCacheItemPool(CacheItemPoolInterface)`, `setCacheDuration(int)`, `setRequestFactory(RequestFactory)`, `setOpenIDConnectMetadataUrl(string)`), so PHPStan at `level: max` produced 4 `argument.type` errors. Add PHPDoc array shapes that declare the keys we read and their types. Keys are marked optional (`?:`) because the runtime `array_key_exists` + `ConfigurationException` checks still gate them — but their type is narrowed when present so the setter calls type-check. The `...` trailing entry lets the league/oauth2-client extra options (`clientId`, `clientSecret`, `redirectUri`, …) and Guzzle's forwarded options (`timeout`, `proxy`, `verify`) pass through without flagging. Drops a now-redundant `is_int($options['leeway'])` runtime check that became a `function.alreadyNarrowedType` tautology once the shape declared `leeway?: int`. Under `declare(strict_types=1)`, PHP itself enforces the type via `setLeeway(int $leeway)`. Behaviour unchanged — purely a static-analysis tightening at the constructor boundary. Removes 4 errors when PHPStan is run at `level: max`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #43 +/- ##
===========================================
Coverage 100.00% 100.00%
+ Complexity 62 61 -1
===========================================
Files 1 1
Lines 172 172
===========================================
Hits 172 172
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
jekuaitk
approved these changes
May 12, 2026
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
First of three small follow-ups (A → B → C) tightening the JSON-payload boundary to make a future
level: 8→level: maxPHPStan bump achievable.PR A targets the constructor's untyped
array $options/array $collaboratorsparameters. The four reads we make —cacheItemPool,openIDConnectMetadataUrl,cacheDuration,jwt— currently flow asmixedinto typed setters, producing 4argument.typeerrors atlevel: max.What changes
Adds PHPDoc array shapes:
?:) — the runtimearray_key_exists+ConfigurationExceptionchecks still gate the required ones. PHPStan narrows their type when present....trailing entry allows league/oauth2-client's extras (clientId,clientSecret,redirectUri, …) and Guzzle's forwarded options (timeout,proxy,verify) to pass through.Also drops a redundant
is_int($options['leeway'])runtime check — once the shape declaresleeway?: int, the check becomes afunction.alreadyNarrowedTypetautology. Underdeclare(strict_types=1), PHP itself enforces the type viasetLeeway(int $leeway).Behaviour change
None. Pure static-analysis tightening at the constructor boundary.
Test plan
task test:coverage— 100% coverage onOpenIdConfigurationProvider(24/24 methods, 148/148 lines) preserved.task analyze:phpatlevel: 8— no errors.task analyze:phpatlevel: max— 4 constructorargument.typeerrors gone (16 unrelated max-level errors remain, scheduled for PR B and PR C).task lint:php— clean.task lint:markdown— clean.Follow-ups
fetchJsonResource()andjson_decodereturn types viais_array/is_stringguards (~10 max-level errors).validateIdTokenclaim accesses + the remaining test-side Mockery / fixture-helper types (~6 max-level errors).After all three land,
level: maxbecomes achievable in a final config bump.🤖 Generated with Claude Code