feat: add phpstan method annotations - #3331
Conversation
| $segments[] = "{$key}?: {$rendered}"; | ||
| } | ||
|
|
||
| // Append the unsealed marker so PHPStan/Psalm don't flag |
There was a problem hiding this comment.
Note: this is where I ran into severe issues with AWS, passing completely ignored arguments to the API, and almost destroying production resources
There was a problem hiding this comment.
You're right, this is the false-negative we accept with the unsealed marker. Sealing here would catch Buckt → Bucket, but it would also flag the common pattern of dynamically-built array<string, mixed> values passed as $args (request context, tracing metadata) where PHPStan/Psalm can't prove key set membership at the call site. What do you think about sealing top-level members, but leaving nested members unsealed?
There was a problem hiding this comment.
Sorry, I was on vacation
but it would also flag the common pattern of dynamically-built
array<string, mixed>
For this, tools like PHPStan/Psalm/Mago/Phan have the concept of a "baseline", which is a sufficient approach to catch this sort of detail.
What do you think about sealing top-level members, but leaving nested members unsealed?
I think it wouldn't be added value here.
People that use PHPStan/Psalm/etc. can ignore these issues themselves, as an opt-in, either via a pattern or via a baseline.
Reporting these problems is more valuable than taking an upfront decision to suppress them for consumers.
0d57dfc to
149da8e
Compare
149da8e to
d0e84a8
Compare


Issue #, if available:
#3309
Description of changes:
Adds
phpstan-methodannotations to service client methods for better static analysis support.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.