PHPackages                             zebra-north/phpcs-short-types - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. zebra-north/phpcs-short-types

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

zebra-north/phpcs-short-types
=============================

Require the use of short scalar type names (bool, int) in comments, instead of long names (boolean, integer).

v1.1.0(2mo ago)270.0k↓19.2%2MITPHPPHP &gt;=7.0

Since Dec 20Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/ZebraNorth/phpcs-short-types)[ Packagist](https://packagist.org/packages/zebra-north/phpcs-short-types)[ RSS](/packages/zebra-north-phpcs-short-types/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)DependenciesVersions (4)Used By (2)

Short Type Names for PHP Codesniffer
====================================

[](#short-type-names-for-php-codesniffer)

PHP Codesniffer requires that scalar types be written in their long form, eg. `boolean` or `integer`.

As of PHP 7+, scalars are required to be written in their short form, eg. `bool` or `int`.

This patch allows you to use the short form in doc-block comments.

Before:

```
/**
 * Test function.
 *
 * @param integer $test A numeric argument.
 *
 * @return boolean Returns true or false.
 */
function test(int $test): bool
{
    return false;
}
```

After:

```
/**
 * Test function.
 *
 * @param int $test A numeric argument.
 *
 * @return bool Returns true or false.
 */
function test(int $test): bool
{
    return false;
}
```

Errors Fixed
------------

[](#errors-fixed)

- **Squiz.Commenting.FunctionComment.IncorrectParamVarName**
    - Expected "boolean" but found "bool" for parameter type
    - Expected "integer" but found "int" for parameter type
- **Squiz.Commenting.VariableComment.IncorrectVarType**
    - Expected "boolean" but found "bool" for @var tag in member variable comment
    - Expected "integer" but found "int" for @var tag in member variable comment
- **Squiz.Commenting.FunctionComment.InvalidReturn**
    - Expected "boolean" but found "bool" for function return type
    - Expected "integer" but found "int" for function return type

Installation for CodeSniffer v4
-------------------------------

[](#installation-for-codesniffer-v4)

1. Install into composer with: `composer require --dev zebra-north/phpcs-short-types`
2. Edit your project's `phpcs.xml` to replace:

- `Squiz.Commenting.FunctionComment` with `ZebraNorth.Commenting.FunctionComment`
- `Squiz.Commenting.VariableComment` with `ZebraNorth.Commenting.VariableComment`

3. Edit your `CodeSniffer.conf` file. Adjust the path if necessary.

```
