Handle FuncCall nodes that represent first class callables#32
Handle FuncCall nodes that represent first class callables#32shish merged 12 commits intothecodingmachine:masterfrom mll-lab:handle-potential-first-class-callable
Conversation
|
@dbrekelmans I rebased atop the latest changes. I think #33 and this can be applied independently from one another. The condition I put to check for first class callables should come before the condition added there. |
|
Hi all, new maintainer here, hoping to get this merged if it's still relevant. Coming in with little context, what does the PR do? Could it include a unit test showing what fails now, and succeeds after the patch is applied? (There are merge conflicts and failing tests, and I daren't try to fix it myself without understanding the intention behind the code 😅 ) |
…first-class-callable # Conflicts: # composer.json # src/Rules/UseSafeFunctionsRule.php
|
Thank you @shish for looking into this. I tried adding a failing test. I think first-class callables should also be recognized by this rule, such as |
|
I have enabled the CI, but it looks like the added unit test is failing both before and after the changes to add support for it o.o;; |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #32 +/- ##
============================================
+ Coverage 92.70% 94.54% +1.83%
- Complexity 40 46 +6
============================================
Files 7 8 +1
Lines 96 110 +14
============================================
+ Hits 89 104 +15
+ Misses 7 6 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Looks like PHPStan has introduced a custom node type for first-class callables from functions, see https://apiref.phpstan.org/2.1.x/PHPStan.Node.FunctionCallableNode.html. |
|
@shish I hope you don't mind the restructuring of the tests. I found it hard to fit in the new tests in a logical and structured manner without it. |
Stumbled upon this while working on a fix for #31. The original fix no longer applies, but I think this is still valuable to ensure PHP 8.1 compatibility.