Skip to content

PHPCSUtils: Add dependency #474

@GaryJones

Description

@GaryJones

What problem would the enhancement address for VIP?

Much of the logic in our sniffs does not account for certain code styles, more modern PHP syntax, and misses other edge cases related to whitespace etc.

Rather than having to spend the time working out all of the edge cases of unusually formatted code, writing unit tests, and

Describe the solution you'd like

PHPCSUtils is a set of utilities to aid developers of sniffs for PHP_CodeSniffer.

This package offers the following features [taken from the above linked page]:

Use the latest version of PHP_CodeSniffer native utility functions.
Normally to use the latest version of PHP_CodeSniffer native utility functions, you would have to raise the minimum requirements of your external PHPCS standard.

Now you won't have to anymore. This package allows you to use the latest version of those utility functions in all PHP_CodeSniffer versions from PHPCS 2.6.0 and up.

A number of abstract sniff classes which your sniffs can extend.
These classes take some of the heavy lifting away for a number of frequently occurring sniff types.

A collection of static properties for often used token groups.
Collections of related tokens as often used and needed for sniffs.
These are additional "token groups" to compliment the ones available through the PHPCS native PHP_CodeSniffer\Util\Tokens class.

An ever growing number of utility functions for use with PHP_CodeSniffer.
Whether you need to split an array into the individual items, are trying to determine which variables are being assigned to in a list() or are figuring out whether a function has a DocBlock, PHPCSUtils got you covered!

Includes improved versions of the PHPCS native utility functions and plenty new utility functions.

These functions are, of course, compatible with PHPCS 2.6.0 up to PHPCS master.

Test utilities
An abstract UtilityMethodTestCase class to allow for testing your own utility methods written for PHP_CodeSniffer with ease.
Compatible with both PHPCS 2.x as well as 3.x. Supports PHPUnit 4.x up to 8.x.

Backward compatibility layer
A PHPCS23Utils standard which allows sniffs to work in both PHPCS 2.x and 3.x, as well as a number of helper functions for external standards which still want to support both PHP_CodeSniffer 2.x as well as 3.x.

Fully documented
To see detailed information about all available abstract sniffs, utility functions and PHPCS helper functions, have a read through the extensive documentation.

Additional context

This Issue is to summarise what PHPCSUtils is, and to be the point of reference for the PR that adds the dependencies.

Further Issues / PRs will be needed for actually swapping in the utility functions.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions