Skip to content

A PHPCS sniff to enforce the use of short scalar type names (bool, int, etc) in comments, instead of long names (boolean, integer, etc).

License

Notifications You must be signed in to change notification settings

Justintime50/phpcs-short-scalar-types

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

PHPCS Short Scalar Types Sniff

Version Licence

A PHPCS sniff to enforce the use of short scalar type names (bool, int, etc) in comments, instead of long names (boolean, integer, etc).

Install

# Install Sniff
composer require --dev justintime50/phpcs-short-scalar-types

# Allow PHPCS to find Sniff (or use https://github.com/PHPCSStandards/composer-installer)
vendor/bin/phpcs --config-set installed_paths vendor/justintime50/phpcs-short-scalar-types/ShortTypes

Usage

Add to your phpcs.xml:

<rule ref="ShortTypes.Commenting.ShortScalarTypes" />

Run PHPCS as usual. Use --fix to auto-correct long forms in comments.

Example

// @var boolean $flag  // Error: Use "bool" instead of "boolean".
// @var bool $flag     // OK

Development

To have PHPCS pick up the local copy of this sniff, you'll need to adjust the installed paths like so:

# Set config
vendor/bin/phpcs --config-set installed_paths "$(pwd)/ShortTypes"

# Confirm ShortTypes is now available
vendor/bin/phpcs -i

Testing

# Run sniff test
composer test

# Run autofix test
composer fix

About

A PHPCS sniff to enforce the use of short scalar type names (bool, int, etc) in comments, instead of long names (boolean, integer, etc).

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Languages