Skip to content
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

Merged
merged 4 commits into from
Oct 9, 2024

Conversation

zonuexe
Copy link
Contributor

@zonuexe zonuexe commented Oct 9, 2024

@zonuexe zonuexe marked this pull request as draft October 9, 2024 08:54
RuleErrorBuilder::message(
sprintf(
'Dumped type: %s',
$scope->getType($node->getArgs()[0]->value)->toPhpDocNode(),
Copy link
Member

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'}",
Copy link
Member

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;
Copy link
Contributor

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

Copy link
Member

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.

Copy link
Contributor Author

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.

@zonuexe zonuexe marked this pull request as ready for review October 9, 2024 09:37
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

@ondrejmirtes
Copy link
Member

@ondrejmirtes ondrejmirtes merged commit df39688 into phpstan:1.12.x Oct 9, 2024
473 of 500 checks passed
@ondrejmirtes
Copy link
Member

Thank you!

@staabm
Copy link
Contributor

staabm commented Oct 9, 2024

@zonuexe please see PHP7.4 only test errors

grafik

https://github.com/phpstan/phpstan-src/actions/runs/11254262628/job/31291308442?pr=3561
https://github.com/phpstan/phpstan-src/actions/runs/11254262628/job/31291309269?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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants