Reflected class method returning type #8993
-
Hello everyone, let's assume I have this chunk of code:
How I can determine the returning type of a reflected class method call and set that type as a returning type of the method "callMethod"? Note that methods in class A are private and cannot be called directly. The lasts calls of returnInt and returnString fails because callMethod returns mixed. Example: https://phpstan.org/r/5733e54a-de8c-4018-9fb4-c62b03f335d2 in this example detects unused functions in lines 7 and 10 but this is not the problem. Thank you in advance /roger |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
This feature could help you to do this in PHPDocs once implemented: https://twitter.com/OndrejMirtes/status/1606017239882338304 For now, you can achieve the same thing with: https://phpstan.org/developing-extensions/dynamic-return-type-extensions |
Beta Was this translation helpful? Give feedback.
This feature could help you to do this in PHPDocs once implemented: https://twitter.com/OndrejMirtes/status/1606017239882338304
For now, you can achieve the same thing with: https://phpstan.org/developing-extensions/dynamic-return-type-extensions