phpstan-src icon indicating copy to clipboard operation
phpstan-src copied to clipboard

DynamicFunctionReturnTypeExtension for the get_debug_type function.

Open patrickkusebauch opened this issue 1 year ago • 5 comments
trafficstars

Closes: https://github.com/phpstan/phpstan/issues/10558 Closes: https://github.com/phpstan/phpstan/issues/10585

patrickkusebauch avatar Feb 10 '24 21:02 patrickkusebauch

You've opened the pull request against the latest branch 1.11.x. If your code is relevant on 1.10.x and you want it to be released sooner, please rebase your pull request and change its target to 1.10.x.

phpstan-bot avatar Feb 10 '24 21:02 phpstan-bot

Looking at the failing checks, none of them seem to be genuinely caused by this change.

patrickkusebauch avatar Feb 10 '24 22:02 patrickkusebauch

Please add a pattern-matching example-test and use it in rule-tests which emit errors before this PR and are expected to be fixed now

staabm avatar Feb 11 '24 08:02 staabm

Please add a pattern-matching example-test and use it in rule-tests which emit errors before this PR and are expected to be fixed now

Updated the PR.

Error emitted before this PR: '20: Match expression does not handle remaining value: string'.

patrickkusebauch avatar Feb 12 '24 16:02 patrickkusebauch

Updated to also specify the type in condition branches. This closes https://github.com/phpstan/phpstan/issues/10585 for me.

I have a question about TypeTraverser::map and TypeCombinator::union. I tried to replicate the code in GettypeFunctionReturnTypeExtension as it is a similar feature. However, when trying to combine:

  • 'bool'|string (constant string bool or any string) it gets normalized to string
  • 'Namespace\ClassA'|'Namespace\ClassB' (constant strings with FQCN) it gets normalized to Namespace\ClassA|Namespace\ClassB

Is this expected? Can this be turned off? Are those considered equivalent?

patrickkusebauch avatar Feb 16 '24 20:02 patrickkusebauch