Conversation
Adi-ty
left a comment
There was a problem hiding this comment.
The issue mentions that level 5 is the target and that any pre-existing issues should be handled via a baseline rather than lowering the level. Moving to level 8 feels like a fairly meaningful step up in strictness, so I wanted to check whether that was intentional. If it was, could we call that out explicitly and get sign-off on the tighter standard? Otherwise, it may make sense to keep this at level 5 for now and rely on the baseline as described in the issue.
| * Collection of instance. | ||
| * | ||
| * @var array | ||
| * @var array<string, static> |
There was a problem hiding this comment.
array<string, static> works here, but the key type could be a bit more precise and the value type is slightly broader in practice because the cache can hold instances for multiple classes. Consider array<class-string, object> for the cache and narrowing the looked-up entry to static at return time with /** @var static $singleton */ before the return.
There was a problem hiding this comment.
This is right 🙌
I added the fix for this and pushed it in the PR
There was a problem hiding this comment.
A small stub file wired via bootstrapFiles resolves it cleanly and lets us drop the baseline entry. Happy to leave it for now if you prefer to keep the change small.
There was a problem hiding this comment.
Added a boostrap file and removed the errors from baseline file and left it empty.
Hello @aryanjasala Why we should take a stricter approach:
|
| * @param string $block_content Block content. | ||
| * @param array $block Block. | ||
| * @param string $block_content Block content. | ||
| * @param array<mixed> $block Block. |
There was a problem hiding this comment.
$block parameter is typed as array<mixed> across all three methods, which allows integer keys, but the parsed block array always uses string keys (blockName, attrs etc.). array<string, mixed> would be a more accurate type here.
Description
Setup phpstan for the theme.
Technical Details
Adding phpstan setup along with the baseline setup so that errors that are to be ignored can be added and setup a baseline again.
Checklist
Screenshots
To-do
Fixes/Covers issue
Fixes #634