PHP_CodeSniffer icon indicating copy to clipboard operation
PHP_CodeSniffer copied to clipboard

Add support to use short forms of type keywords

Open filips123 opened this issue 3 years ago • 4 comments

This adds support to use short forms of type keywords in comments for function parameters and returns and variable types. It fixes #1864 and fixes #1434.

It adds useShortTypes property, which is by default false, to Squiz.Commenting.FunctionComment and Squiz.Commenting.VariableComment to allow users to use short type checks. If it is enabled, it will force short types in comments and suggest them when long ones are used.

P.S. I would appreciate if you add hacktoberfest-accepted label to this PR, so it will count for this year's Hacktoberfest.

filips123 avatar Oct 10 '20 17:10 filips123

Any chance to get this merged? Short return types are the way to go, especially because it does not comply to the rules of PSR-12 currently. "Short form of type keywords MUST be used i.e. bool instead of boolean, int instead of integer etc.".

bramstroker avatar Aug 02 '21 13:08 bramstroker

Until such time as this can be merged, I've added a workaround here: https://packagist.org/packages/zebra-north/phpcs-short-types

It's not a proper fix, it would be great if this PR could be merged.

ZebraNorth avatar Dec 20 '21 20:12 ZebraNorth

I would love for this to be merged, we are using PHPStorm and it automatically (and correctly) uses short types which we have to manually update to pass our code sniffers

drdrak3 avatar Dec 02 '22 17:12 drdrak3