-
Notifications
You must be signed in to change notification settings - Fork 459
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 PHPStan\dumpPhpDocType() #3559
Conversation
9481317
to
cc9e271
Compare
RuleErrorBuilder::message( | ||
sprintf( | ||
'Dumped type: %s', | ||
$scope->getType($node->getArgs()[0]->value)->toPhpDocNode(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the Printer here (https://phpstan.github.io/phpdoc-parser/2.0.x/PHPStan.PhpDocParser.Printer.Printer.html#_print), not Node::__toString()
. It's more precise, uses less parentheses, only where needed.
5, | ||
], | ||
[ | ||
"Dumped type: array{'\0': 'NUL', NUL: '\0'}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also try some of the special multi-byte characters you did in the previous PR? (\x??
)
*/ | ||
function dumpPhpDocType($value) // phpcs:ignore Squiz.Functions.GlobalFunction.Found | ||
{ | ||
return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is copied from dumpType
, but I always wondered: Why does this even return something?
PHPStorm always complains that the result is not used.
Can't we make this return void
? Then do the same for the other helpers?
/cc @ondrejmirtes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can’t make void functions pure, that’s why.
Personally I turn this off in PhpStorm, as PHPStan will tell me the same thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is because if declared as void, dumpType()
would affect the purity of the embedded function.
This pull request has been marked as ready for review. |
c330ef5
to
9985e47
Compare
Thank you! |
@zonuexe please see PHP7.4 only test errors https://github.com/phpstan/phpstan-src/actions/runs/11254262628/job/31291308442?pr=3561 interesstingly these appear in a followup PR, and were not detected in this PR here. maybe its a PHPStan 2.x only thing |
resolve phpstan/phpstan#11823, refs #3555