Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add template generics for PSR-11 implementations in PHPStan and Psalm #3322

Open
wants to merge 7 commits into
base: 4.x
Choose a base branch
from

Conversation

limarkxx
Copy link

Slim v4 abstracts out DI to PSR-11, which means given a Slim/App it is unclear what its DI container is capable of.
Psalm and PHPStan both provide mechanisms to express the types generically, allowing them to ensure that you are calling the correct set method on a DI container received from getContainer

preg_match(CallableResolver::$callablePattern, $toResolve, $matches);
[$class, $method] = $matches ? [$matches[1], $matches[2]] : [$toResolve, null];

/** @var string $class */
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: psalm considers this annotation redundant. They can be included if findUnusedCode is set to false

@limarkxx limarkxx marked this pull request as ready for review May 14, 2024 04:17
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.

None yet

1 participant