Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHPCSUtils: Add dependency #474

Closed
GaryJones opened this issue Mar 28, 2020 · 4 comments · Fixed by #777
Closed

PHPCSUtils: Add dependency #474

GaryJones opened this issue Mar 28, 2020 · 4 comments · Fixed by #777
Assignees
Labels
PHPCSUtils The addition and utilisation of PHPCSUtils package Status: Has PR Type: Enhancement
Milestone

Comments

@GaryJones
Copy link
Contributor

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.

@GaryJones GaryJones added Type: Enhancement PHPCSUtils The addition and utilisation of PHPCSUtils package labels Mar 28, 2020
@GaryJones GaryJones added this to the Sprint 1 (v2.0.1) milestone Apr 17, 2020
@GaryJones GaryJones modified the milestones: Sprint 1, 2.2.0 Jul 27, 2020
@jrfnl
Copy link
Collaborator

jrfnl commented Jul 27, 2020

I've prepared the branch with the necessary changes for this, but am a little hesitant to pull it as of yet.

PHPCSUtils is at this moment at 1.0.0-alpha3. This means that a minimum-stability of dev is needed to allow it to install.

I intend to tag 1.0.0 stable before the release of WPCS 3.0.0 and PHPCompatibility 10.0.0, or earlier if I deem it ready enough, but for now, there are still some things I'd like to add before tagging 1.0.0.

Having said that, this means that if the PR adding PHPCSUtils would be pulled & merged now, the next release of VIPCS would have to wait to be tagged until PHPCSUtils 1.0.0 has been released.

Seeing that there are 19 closed issues/PRs in the 2.2.0 milestone so far, it would block the release of these to the general public.
And I have feeling that of the currently open issues in the milestone, at least some can be fixed for the time being with a simple fix without PHPCSUtils.

VariableAnalysis will also use PHPCSUtils as of their next major 3.0.0, but as the version included in VIPCS is 2.x, that's not an issue for now.

What is the current release timeline for VIPCS 2.2.0 ? And with the above in mind, should PHPCSUtils be deferred to VIPCS 2.3.0 ?

@GaryJones
Copy link
Contributor Author

GaryJones commented Jul 27, 2020

That makes sense then.

There's no hard release date for 2.2.0 (though once we get started on the sniff reviews, I'd love to have a 4-6 week cadence), so if there are bug fixes and other improvements that can be made without needing PHPCSUtils, then we can defer adding that until 2.3.0.

That said, what would be the impact on using 1.0.0-alpha3? Could it be added, and you only improve sniffs with the Utils bits you think are most stable? At worst, some unstable bits are used, and the next release of VIPCS switches to the next version of PHPCSUtils and adjusts to account for whatever bits changed.

@jrfnl
Copy link
Collaborator

jrfnl commented Jul 27, 2020

That said, what would be the impact on using 1.0.0-alpha3? Could it be added, and you only improve sniffs with the Utils bits you think are most stable? At worst, some unstable bits are used, and the next release of VIPCS switches to the next version of PHPCSUtils and adjusts to account for whatever bits changed.

It's not about anything what's currently in PHPCSUtils being unstable. I'm pretty confident about what's in there already.

The issue is that end-users of VIPCS would also need to set their minimum-stability in their composer.json to dev for VIPCS to be able to install when using PHPCSUtils alpha.
They may already have this in place, but I don't think "forcing" this on them is a good idea.

@GaryJones GaryJones modified the milestones: 2.2.0, 2.3.0 Aug 29, 2020
@rebeccahum rebeccahum modified the milestones: 2.3.0, 2.4.0, 3.x Nov 20, 2020
@GaryJones
Copy link
Contributor Author

Can be closed once #734 is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PHPCSUtils The addition and utilisation of PHPCSUtils package Status: Has PR Type: Enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants