Skip to content

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Jul 25, 2024

@staabm staabm marked this pull request as ready for review July 25, 2024 13:54
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

@takaram
Copy link
Contributor

takaram commented Jul 25, 2024

highlight_string never returns false while its return type is declared as string|bool
PHP 8.4 is going to change it to string|true.
https://github.com/php/php-src/blob/php-8.4.0alpha2/NEWS#L26-L27

highlight_file and show_source may return both true and false, but it means that using the return value is not useless, doesn't it?

@staabm
Copy link
Contributor Author

staabm commented Jul 25, 2024

highlight_file and show_source may return both true and false, but it means that using the return value is not useless, doesn't it?

I am not sure. this might mean we should drop these 2 from the rule

Copy link
Member

@ondrejmirtes ondrejmirtes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, highlight_file and show_source should be dropped from this rule. It's more complicated with them.

Instead, these functions could have a stub file with a conditional return type.

Then, someone is free to write a rule that disallows bool and potentially other types to be used in a string context, like concat and others. (But it's a bad fit for PHPStan core because it's not a bug.)

@staabm
Copy link
Contributor Author

staabm commented Aug 1, 2024

Yes, highlight_file and show_source should be dropped from this rule. It's more complicated with them.

done

Instead, these functions could have a stub file with a conditional return type.

we already have these stubs

@ondrejmirtes ondrejmirtes merged commit 35a2f57 into phpstan:1.11.x Aug 1, 2024
@ondrejmirtes
Copy link
Member

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants