PHPCSUtils

A suite of utility functions for use with PHP_CodeSniffer.

Read the Documentation

Install using Composer:
composer require phpcsstandards/phpcsutils

Latest release: 1.0.11

View Changelog

Visit the Project on GitHub PHPCSStandards/PHPCSUtils

Change Log for PHPCSUtils for PHP CodeSniffer

All notable changes to this project will be documented in this file.

This projects adheres to Keep a CHANGELOG and uses Semantic Versioning.

1.0.11 - 2024-04-24

Changed

Other

Fixed

PHPCS BackCompat

Utils

1.0.10 - 2024-03-18

Changed

Other

Deprecated

Utils

Fixed

PHPCS BackCompat

1.0.9 - 2023-12-08

Added

PHPCS BackCompat

Changed

TestUtils

Other

1.0.8 - 2023-07-17

Changed

PHPCS BackCompat

Other

Fixed

Fixers

1.0.7 - 2023-07-10

Changed

Other

Fixed

Utils

1.0.6 - 2023-05-27

Changed

PHPCS BackCompat

Utils

Other

Fixed

Abstract Sniffs

1.0.5 - 2023-04-17

Fixed

Utils

1.0.4 - 2023-04-15

Changed

Other

Fixed

Utils

1.0.3 - 2023-04-13

Changed

Other

Fixed

Utils

1.0.2 - 2023-03-28

Changed

Tokens

Other

Fixed

Utils

1.0.1 - 2023-01-05

Changed

Other

1.0.0 - 2023-01-04

For the full list of features, please see the changelogs of the alpha/rc releases:

Changed

Other

1.0.0-rc1 - 2022-12-27

Added

Tokens

Changed

Utils

Other

Removed

Everything which was previously deprecated in the 1.0.0-alpha4 release, has now been removed. #410

This includes:

See the changelog for the 1.0.0-alpha4 release for details about replacements for the removed functionality.

Fixed

Utils

1.0.0-alpha4 - 2022-10-25

Notes:

Breaking Changes

Support for PHP_CodeSniffer < 3.7.1 has been dropped after consultation with the principle external standards which depend on PHPCSUtils. #347

This was unfortunately necessary as the incessant additions of new syntaxes since PHP 7.4 made it impossible to continue to support PHPCS < 3.7.1, while still providing reliable results for modern PHP code.

Added

Now support for PHPCS < 3.7.1 has been dropped, this edition adds support to all functionality in PHPCSUtils for new syntaxes and features from PHP 8.0 and 8.1 and preliminary support for PHP 8.2.

This means that support for the following syntaxes/features has been added (or existing support verified/improved):

Please report any bugs/oversights you encounter!

PHPCS Backcompat

TestUtils

Tokens

Utils

Other

Changed

PHPCS Backcompat

TestUtils

Tokens

Utils

Other

Deprecated

:warning: Everything which has currently been deprecated, will be removed before the final 1.0.0 version of PHPCSUtils is tagged.

Tokens

Collections class: direct access to the properties in the class is now deprecated for forward-compatibility reasons. All properties have a replacement which should be used instead, in most cases this will be a method with the same name as the previously used property,

Deprecated Replacement PR Remarks
Collections::$alternativeControlStructureSyntaxTokens Collections::alternativeControlStructureSyntaxes() #311 Mind the change in the name!
Collections::$alternativeControlStructureSyntaxCloserTokens Collections::alternativeControlStructureSyntaxClosers() #311 Mind the change in the name!
Collections::$arrayTokens Collections::arrayTokens() #311
Collections::$arrayTokensBC Collections::arrayTokensBC() #311
Collections::$classModifierKeywords Collections::classModifierKeywords() #311
Collections::$closedScopes Collections::closedScopes() #311
Collections::$controlStructureTokens Collections::controlStructureTokens() #311
Collections::$incrementDecrementOperators Collections::incrementDecrementOperators() #311
Collections::$listTokens Collections::listTokens() #311
Collections::$listTokensBC Collections::listTokensBC() #311
Collections::$magicConstants PHPCSUtils\BackCompat\BCTokens::magicConstants() or PHP_CodeSniffer\Util\Tokens::$magicConstants #311
Collections::$namespaceDeclarationClosers Collections::namespaceDeclarationClosers() #311
Collections::$objectOperators Collections::objectOperators() #176
Collections::$OOCanImplement Collections::ooCanImplement() #311 Mind the case change in the oo prefix!
Collections::$OOCanExtend Collections::ooCanExtend() #311 Mind the case change in the oo prefix!
Collections::$OOConstantScopes Collections::ooConstantScopes() #311 Mind the case change in the oo prefix!
Collections::$OOPropertyScopes Collections::ooPropertyScopes() #311 Mind the case change in the oo prefix!
Collections::$OOHierarchyKeywords Collections::ooHierarchyKeywords() #311 Mind the case change in the oo prefix!
Collections::$OONameTokens Collections::namespacedNameTokens() #202 Mind the change name!
Collections::$parameterTypeTokens Collections::parameterTypeTokens() #168
Collections::$propertyModifierKeywords Collections::propertyModifierKeywords() #311
Collections::$propertyTypeTokens Collections::propertyTypeTokens() #168
Collections::$returnTypeTokens Collections::returnTypeTokens() #168
Collections::$shortArrayTokens Collections::shortArrayTokens() #311
Collections::$shortArrayTokensBC Collections::shortArrayTokensBC() #311
Collections::$shortListTokens Collections::shortListTokens() #311
Collections::$shortListTokensBC Collections::shortListTokensBC() #311
Collections::$textStingStartTokens Collections::textStringStartTokens() #311, #319 Mind the fixed typo in the name!

Additionally, the following methods in the Collections class have been deprecated:

Deprecated Replacement PR
Collections::arrowFunctionTokensBC() Use the T_FN token instead. #347
Collections::functionDeclarationTokensBC() Collections::functionDeclarationTokens() #347
Collections::parameterTypeTokensBC() Collections::parameterTypeTokens() #347
Collections::propertyTypeTokensBC() Collections::propertyTypeTokens() #347
Collections::returnTypeTokensBC() Collections::returnTypeTokens() #347

Utils

Other

Removed

Utils

Fixed

Abstract Sniffs

Fixers

TestUtils

Tokens

Utils

1.0.0-alpha3 - 2020-06-29

Notes:

Added

PHPCS BackCompat

TestUtils

Tokens

Utils

Changed

PHPCS BackCompat

TestUtils

Tokens

Utils

Other

Fixed

Abstract Sniffs

PHPCS BackCompat

Utils

1.0.0-alpha2 - 2020-02-16

Note:

Added

PHPCS BackCompat

Tokens

Utils

Other

Changed

PHPCS BackCompat

Tokens

Utils

Other

1.0.0-alpha1 - 2020-01-23

Initial alpha release containing:

All utilities offered are compatible with PHP_CodeSniffer 2.6.0 up to the latest stable release.

This initial alpha release contains the following utility classes:

Abstract Sniffs

BackCompat

Fixers

TestUtils

Tokens

Utils