Add support for the callable-string type#296
Add support for the callable-string type#296ondrejmirtes merged 2 commits intophpstan:masterfrom ste93cry:feature/3723-add-callable-string-type-support
Conversation
|
Hi, I don't understand this:
What's the point then? I'd definitely want the validation. |
ondrejmirtes
left a comment
There was a problem hiding this comment.
I'll fix the build of dev-master, you can then rebase.
There was a problem hiding this comment.
You can also add some testcases to TypeCombinatorTest::dataIntersect. It should work like this:
- Intersection of string and callable-string -> callable-string.
- Intersection of ConstantStringType and CallableStringType - depends on the value, can be normalized to ConstantStringType, it might not. Please test both cases.
|
Actually, I just checked what So we can scratch the new whole CallableStringType class and just work with the intersection... |
I did some testing (I'm not practical enough of how PHPStan internals works, so I'm having an hard time contributing), but changing the |
|
You need to make |
|
Thank you. |
|
Uuum, thank you for merging the PR but I still had to push the commit with the additional tests of the |
|
PR is a PR, you're always risking I'm gonna merge it unless it's a draft :) |
|
When you're at it, a new NodeScopeResolver::testFileAsserts data provider with |
Lesson learned 😄
Sure, will do 👍 |
With this PR I would like to add support for the
callable-stringtype as it works in Psalm. I have deliberately decided not to check through the broker if the function exists as I think that it may be an issue in some cases due to false positives, but let me know if we want to go stricter. I did some tests with Psalm and it looks like there is no validation at all of the value itself. This fixes the specific case reported in phpstan/phpstan#3723, although the original problem with the missing fallback of PHPStan to the plain PHPDoc annotation remains