-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Type hinting: bool or boolean #1864
Comments
The error message comes from a particular coding standard that enforces that convention. Those standards have not been updated in a while (the PEAR one probably never will be) so there isn't a lot you can do without either writing your own sniff to enforce the rules you want, or finding a sniff someone else has written. I do intend on changing the Squiz standard, so I'll leave this open as a reminder. |
Same for integer, see: codeigniter4/coding-standard#22 . Thank you! 😃 |
Just throwing an idea out there: Could this be as simple as changing the switch case in Common->suggestType() and adding an optional strict param for backwards compatibility. We could then add a $strictType to commenting sniffs that use it that can be set in the ruleset config? Something like this. https://gist.github.com/louisl/a1e0fe4fc1ab33b1369f37f8052585e0 |
Coding standard can break typehints in many ways, since they don't know the context of parent/child files: <?php
final class SuperCoolSniff implements Sniff
{
/**
* @param int $position
*/
- public function process(File $file, $position)
+ public function process(File $file, int $position)
{
// ...
}
} It's better to use AST for this in tools like Retor instead of |
The adding of an optional parameter to the |
This still needs fixing for PHP > 7 BTW, much like how it's (almost) fixed for Params. @gsherwood |
I created PR #3139 to allow using short forms of type keywords using |
The sniffer makes a pretty strange requirement. He is always want to see the
boolean
as a type hint. But, at the same time PHP 7.1 supports onlybool
as a type hinting. So, to make everyone happy I need to write the hinting in two versions:This is weird from the coding viewpoint.
Here is a discussion about the right hinting https://stackoverflow.com/a/44009101/5497749
The text was updated successfully, but these errors were encountered: