justintime50/phpcs-short-scalar-types

PHPCS sniff to enforce short scalar type names in comments (bool, int, etc.)

Fund package maintenance!
Justintime50

Installs: 34

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

Type:phpcodesniffer-standard

pkg:composer/justintime50/phpcs-short-scalar-types

0.3.0 2026-01-04 06:12 UTC

This package is auto-updated.

Last update: 2026-01-04 06:30:18 UTC


README

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