-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Drop support for PHPCS < 3.7.1 #347
Conversation
This: * Updates the minimum PHPCS requirement in `composer.json`. * Updates the minimum PHPCS version in the `README`. Includes removing quite some pieces of text which referenced use of older PHPCS versions. Includes putting more emphasis on the utilities PHPCSUtils provides and less on the (now minimal) backcompat layer. * Updates the GH Actions scripts to no longer test against PHPCS < 3.7.1.
bafe6db
to
6318b27
Compare
PHPCSDevCS was previously not added to the `require-dev` dependencies as the minimum supported PHPCS version conflicted with the minimum supported PHPCS version of this package. Now this is no longer the case, the package can be safely added to `require-dev` and work-arounds can be removed. Notes: * Includes declaring a `COMPOSER_ROOT_VERSION` environment variable in the test workflows as PHPCSUtils is a dependency of PHPCSDevCS and having the `COMPOSER_ROOT_VERSION` environment variable prevents a conflict due to the circular dependency. * Includes (still) removing the package for the `test` job as PHPCSDevCS does not allow for PHPCS 4.x (yet) and would prevent the tests from being run against PHPCS 4.x.
368064a
to
a8b300c
Compare
Note: the drop in code coverage for the The code coverage should be back up after that PR. For all other drops in code coverage, I've reviewed the relevant commits (again) and fixed up anything that needed fixing (and yes, there were a few things which needed fixing). |
a8b300c
to
9d8cdae
Compare
Includes removing test work-arounds and skips related to PHPCS 2.x. Includes a minor test tweak in the `testGetTabWidth()` and the `testGetEncoding()` method to ensure that all code branches will still be hit.
This commit removes support for PHPCS < 3.7.1 for the functionality in the `PHPCSUtils\BackCompat\BCTokens` class. Note: all previously supported methods still "exist" and will remain functioning and continue to be supported due to the use of the magic `__callStatic()` method. This is safeguarded via the (updated) tests in the `UnchangedTokenArraysTest` class. This applies to the following methods: * `PHPCSUtils\BackCompat\BCTokens::assignmentTokens()` * `PHPCSUtils\BackCompat\BCTokens::comparisonTokens()` * `PHPCSUtils\BackCompat\BCTokens::arithmeticTokens()` * `PHPCSUtils\BackCompat\BCTokens::operators()` * `PHPCSUtils\BackCompat\BCTokens::parenthesisOpeners()` * `PHPCSUtils\BackCompat\BCTokens::scopeOpeners()` * `PHPCSUtils\BackCompat\BCTokens::phpcsCommentTokens()` * `PHPCSUtils\BackCompat\BCTokens::textStringTokens()` * `PHPCSUtils\BackCompat\BCTokens::ooScopeTokens()` * `PHPCSUtils\BackCompat\BCTokens::magicConstants()`
Use the PHPCS native token arrays when there are no backcompat issues as static property access is faster than a function call.
This commit removes support for PHPCS < 3.7.1 for the functionality in the `PHPCSUtils\BackCompat\BCFile` class. Note: all previously supported methods still exist and will remain functioning as before. Any changes to the PHPCS native methods in future PHPCS versions, which can be accounted for without a minimum PHPCS version bump, will be handled via these compatibility methods. Includes minor updates to the method docblocks and select tests to account for upstream changes this library did not yet handle so far. Note: a custom implementation of the `getMethodParameters()` method remains to support PHPCS cross-version differences between PHPCS 3.x and 4.x.
... which no longer actually test anything with the current minimum PHPCS version.
Note: this does **not** remove BC support from the `Arrays::isShortArray()` method (yet). This will be addressed in a separate PR.
Includes deprecating the `getDeclareScopeOpenClose()` method, which is now redundant. Note: as the caching has been removed from this function, the cache related test has also been removed.
Note: this does **not** remove BC support from the `Lists::isShortList()` method (yet). This will be addressed in a separate PR.
This method was introduced to support detecting whether new lines in error messages are supported in PHPCS, but is no longer needed now support for PHPCS < 3.7.1 has been dropped. The method can be safely removed as it was never in a tagged release. Note: as PHPCS itself does not have any tests for this natively, I'm keeping the associated test and moving it to a separate `Xtra` directory for tests not directly related to PHPCSUtils.
Includes removing the `getEndOfDoubleQuotedString()` method, which is no longer needed. The method can be safely removed as it was never in a tagged release. Note: the tests for the `TextStrings::getEndOfDoubleQuotedString()` method have been re-purposed as additional safeguards for the `TextStrings::getEndOfCompleteTextString()` method. Also note that while the caching in the `TextStrings::getEndOfCompleteTextString()` method may be a bit over the top now, it will still be helpful when handling source documents which contain long multi-line text strings, so better to keep it in place.
This method was introduced to support detecting whether a `&` was used as a union type separator, but is no longer needed now support for PHPCS < 3.7.1 has been dropped. The method can be safely removed as it was never in a tagged release.
…pport union types
This method was introduced to support detecting whether a token was part of a nullsafe object operator, but is no longer needed now support for PHPCS < 3.7.1 has been dropped. The method can be safely removed as it was never in a tagged release.
…objectOperatorsBC()` methods These methods were introduced to support detecting whether a token was part of a nullsafe object operator, but are no longer needed now support for PHPCS < 3.7.1 has been dropped. These methods can be safely removed as they were never in a tagged release.
Includes moving select tests from the `IsReferenceDiffTest` case file to the `isReference` case file as these no longer constitute a difference between the sister-method in `BCFile` and the method in the `Operators` class. Includes removing some tests which were only relevant to safeguard compatibility with older PHPCS versions in which certain tokens would not have been retokenized yet.
9d8cdae
to
dc2e90b
Compare
Includes removing the following constants: * `Numbers::REGEX_NUMLIT_STRING` * `Numbers::REGEX_HEX_NUMLIT_STRING` * `Numbers::UNSUPPORTED_PHPCS_VERSION` Note: even though less useful/necessary now, the `Numbers::getCompleteNumber()` method remains available, as it still provides useful information when working with number tokens. If passed a valid token, though, the call to the `Numbers::getCompleteNumber()` method no longer needs to be wrapped in a `try`/`catch`. The tests also no longer need process isolation.
Includes deprecating the `isArrowFunction()` and `getArrowFunctionOpenClose()` methods. Note: as the caching has been removed from those functions, the cache related test has also been removed.
… support arrow functions This means the following methods are now deprecated: * `PHPCSUtils\Tokens\Collections::arrowFunctionTokensBC()` - use the `T_FN` token instead. * `PHPCSUtils\Tokens\Collections::functionDeclarationTokensBC()` - use the `PHPCSUtils\Tokens\Collections::functionDeclarationTokens()` method instead. Includes introducing a dedicated method to encapsulates the throwing of deprecation notices for methods in the `Collections` class via a new `private` `triggerDeprecation()` method. The new method is tested via the deprecations being introduced in this PR.
This method is no longer needed.
This method is no longer needed.
This method is no longer needed.
dc2e90b
to
3b413c1
Compare
…ted methods Use the `T_FN` token directly instead. Follow up to #347.
…ose()` method Use the the `scope_opener`/`scope_closer` on the `T_DECLARE` token instead. Follow up to #347.
As the most pertinent external PHPCS standards which depend on PHPCSUtils (PHPCSExtra, PHPCompatibility, WordPressCS) have now all dropped support for PHPCS < 3.7.1, PHPCSUtils can as well.
This PR does so, though there may still be more bits and pieces which can be removed.
Important notes for the changelog
Deprecated
PHPCSUtils\Tokens\Collections::arrowFunctionTokensBC()
- Use theT_FN
token instead.PHPCSUtils\Tokens\Collections::functionDeclarationTokensBC()
- Use thePHPCSUtils\Tokens\Collections::functionDeclarationTokens()
method instead.PHPCSUtils\Tokens\Collections::parameterTypeTokensBC()
- Use thePHPCSUtils\Tokens\Collections::parameterTypeTokens()
method instead.PHPCSUtils\Tokens\Collections::propertyTypeTokensBC()
- Use thePHPCSUtils\Tokens\Collections::propertyTypeTokens()
method instead.PHPCSUtils\Tokens\Collections::returnTypeTokensBC()
- Use thePHPCSUtils\Tokens\Collections::returnTypeTokens()
method instead.PHPCSUtils\Utils\ControlStructures::getDeclareScopeOpenClose()
- This method is no longer needed, check thescope_opener
/scope_closer
on theT_DECLARE
token instead.PHPCSUtils\Utils\FunctionDeclarations::isArrowFunction()
- This method is no longer needed, use theT_FN
token instead.PHPCSUtils\Utils\FunctionDeclarations::getArrowFunctionOpenClose()
- This method is no longer needed, check thescope_opener
/scope_closer
etc on theT_FN
token instead.Removed
PHPCSUtils\Utils\Numbers::REGEX_NUMLIT_STRING
PHPCSUtils\Utils\Numbers::REGEX_HEX_NUMLIT_STRING
PHPCSUtils\Utils\Numbers::UNSUPPORTED_PHPCS_VERSION
Removed (but was never in a released version)
PHPCSUtils\Tokens\Collections::nullsafeObjectOperatorBC()
PHPCSUtils\Tokens\Collections::objectOperatorsBC()
PHPCSUtils\Utils\MessageHelper::hasNewLineSupport()
PHPCSUtils\Utils\Operators::isTypeUnion()
PHPCSUtils\Utils\Operators::isNullsafeObjectOperator()
PHPCSUtils\Utils\TextStrings::getEndOfDoubleQuotedString()
Commits
Drop support for PHPCS < 3.7.1
This:
composer.json
.README
.Includes removing quite some pieces of text which referenced use of older PHPCS versions.
Includes putting more emphasis on the utilities PHPCSUtils provides and less on the (now minimal) backcompat layer.
Test bootstrap: remove condition related to PHPCS 2.x
Composer: add PHPCSDevCS to the dependencies
PHPCSDevCS was previously not added to the
require-dev
dependencies as the minimum supported PHPCS version conflicted with the minimum supported PHPCS version of this package.Now this is no longer the case, the package can be safely added to
require-dev
and work-arounds can be removed.Notes:
COMPOSER_ROOT_VERSION
environment variable in the test workflows as PHPCSUtils is a dependency of PHPCSDevCS and having theCOMPOSER_ROOT_VERSION
environment variable prevents a conflict due to the circular dependency.test
job as PHPCSDevCS does not allow for PHPCS 4.x (yet) and would prevent the tests from being run against PHPCS 4.x.BackCompat\Helper: remove support for PHPCS 2.x
Includes removing test work-arounds and skips related to PHPCS 2.x.
Includes a minor test tweak in the
testGetTabWidth()
and thetestGetEncoding()
method to ensure that all code branches will still be hit.BackCompat\BCTokens: remove support for PHPCS < 3.7.1
This commit removes support for PHPCS < 3.7.1 for the functionality in the
PHPCSUtils\BackCompat\BCTokens
class.Note: all previously supported methods still "exist" and will remain functioning and continue to be supported due to the use of the magic
__callStatic()
method.This is safeguarded via the (updated) tests in the
UnchangedTokenArraysTest
class.This applies to the following methods:
PHPCSUtils\BackCompat\BCTokens::assignmentTokens()
PHPCSUtils\BackCompat\BCTokens::comparisonTokens()
PHPCSUtils\BackCompat\BCTokens::arithmeticTokens()
PHPCSUtils\BackCompat\BCTokens::operators()
PHPCSUtils\BackCompat\BCTokens::parenthesisOpeners()
PHPCSUtils\BackCompat\BCTokens::scopeOpeners()
PHPCSUtils\BackCompat\BCTokens::phpcsCommentTokens()
PHPCSUtils\BackCompat\BCTokens::textStringTokens()
PHPCSUtils\BackCompat\BCTokens::ooScopeTokens()
PHPCSUtils\BackCompat\BCTokens::magicConstants()
Utils: minor efficiency tweak after BCTokens cleanup
Use the PHPCS native token arrays when there are no backcompat issues as static property access is faster than a function call.
BackCompat\BCFile: remove support for PHPCS < 3.7.1
This commit removes support for PHPCS < 3.7.1 for the functionality in the
PHPCSUtils\BackCompat\BCFile
class.Note: all previously supported methods still exist and will remain functioning as before.
Any changes to the PHPCS native methods in future PHPCS versions, which can be accounted for without a minimum PHPCS version bump, will still be handled via these compatibility methods.
Includes minor updates to the method docblocks and select tests to account for upstream changes this library did not yet handle so far.
Note: a custom implementation of the
getMethodParameters()
method remains to support PHPCS cross-version differences between PHPCS 3.x and 4.x.Fixers\SpacesFixer: remove support for PHPCS < 3.7.1
TestUtils\UtilityMethodTestCase: remove support for PHPCS < 3.7.1
Tokens\TokenHelper\TokenExistsTest: remove three tests
... which no longer actually test anything with the current minimum PHPCS version.
Utils\Arrays: remove support for PHPCS < 3.7.1
Note: this does not remove BC support from the
Arrays::isShortArray()
method (yet). This will be addressed in a separate PR.Utils\ControlStructures: remove support for PHPCS < 3.7.1
Includes deprecating the
getDeclareScopeOpenClose()
method, which is now redundant.Note: as the caching has been removed from this function, the cache related test has also been removed.
Utils\Lists: remove support for PHPCS < 3.7.1
Note: this does not remove BC support from the
Lists::isShortList()
method (yet). This will be addressed in a separate PR.Utils\MessageHelper::hasNewLineSupport(): remove the method
This method was introduced to support detecting whether new lines in error messages are supported in PHPCS, but is no longer needed now support for PHPCS < 3.7.1 has been dropped.
The method can be safely removed as it was never in a tagged release.
Note: as PHPCS itself does not have any tests for this natively, I'm keeping the associated test and moving it to a separate
Xtra
directory for tests not directly related to PHPCSUtils.Utils\Namespaces: remove support for PHPCS < 3.7.1
Utils\Parentheses: remove support for PHPCS < 3.7.1
Utils\PassedParameters: remove support for PHPCS < 3.7.1
Utils\ObjectDeclarations: remove support for PHPCS < 3.7.1
Utils\TextStrings: remove support for PHPCS < 3.7.1
Includes removing the
getEndOfDoubleQuotedString()
method, which is no longer needed.The method can be safely removed as it was never in a tagged release.
Note: the tests for the
TextStrings::getEndOfDoubleQuotedString()
method have been re-purposed as additional safeguards for theTextStrings::getEndOfCompleteTextString()
method.Also note that while the caching in the
TextStrings::getEndOfCompleteTextString()
method may be a bit over the top now, it will still be helpful when handling source documents which contain long multi-line text strings, so better to keep it in place.Utils\UseStatements: remove support for PHPCS < 3.7.1
Utils\Variables: remove support for PHPCS < 3.7.1
Utils\Operators::isTypeUnion(): remove the method
This method was introduced to support detecting whether a
&
was used as a union type separator, but is no longer needed now support for PHPCS < 3.7.1 has been dropped.The method can be safely removed as it was never in a tagged release.
Tokens\Collections: remove the work-arounds which were in place to support union types
Utils\Operators::isNullsafeObjectOperator(): remove the method
This method was introduced to support detecting whether a token was part of a nullsafe object operator, but is no longer needed now support for PHPCS < 3.7.1 has been dropped.
The method can be safely removed as it was never in a tagged release.
Tokens\Collections: remove the
nullsafeObjectOperatorBC() and the
objectOperatorsBC()` methodsThese methods were introduced to support detecting whether a token was part of a nullsafe object operator, but are no longer needed now support for PHPCS < 3.7.1 has been dropped.
These methods can be safely removed as they were never in a tagged release.
Utils\Operators: remove support for PHPCS < 3.7.1
Includes moving select tests from the
IsReferenceDiffTest
case file to theisReference
case file as these no longer constitute a difference between the sister-method inBCFile
and the method in theOperators
class.Includes removing some tests which were only relevant to safeguard compatibility with older PHPCS versions in which certain tokens would not have been retokenized yet.
Utils\Numbers: remove support for PHPCS < 3.7.1
Includes removing the following constants:
Numbers::REGEX_NUMLIT_STRING
Numbers::REGEX_HEX_NUMLIT_STRING
Numbers::UNSUPPORTED_PHPCS_VERSION
Note: even though less useful/necessary now, the
Numbers::getCompleteNumber()
method remains available, as it still provides useful information when working with number tokens.If passed a valid token, though, the call to the
Numbers::getCompleteNumber()
method no longer needs to be wrapped in atry
/catch
.The tests also no longer need process isolation.
Utils\FunctionDeclarations: remove support for PHPCS < 3.7.1
Includes deprecating the
isArrowFunction()
andgetArrowFunctionOpenClose()
methods.Note: as the caching has been removed from those functions, the cache related test has also been removed.
Tokens\Collections: deprecate the work-arounds which were in place to support arrow functions
This means the following methods are now deprecated:
PHPCSUtils\Tokens\Collections::arrowFunctionTokensBC()
- use theT_FN
token instead.PHPCSUtils\Tokens\Collections::functionDeclarationTokensBC()
- use thePHPCSUtils\Tokens\Collections::functionDeclarationTokens()
method instead.Includes introducing a dedicated method to encapsulates the throwing of deprecation notices for methods in the
Collections
class via a newprivate
triggerDeprecation()
method.The new method is tested via the deprecations being introduced in this PR.
Tokens\Collections: deprecate the parameterTypeTokensBC() method
This method is no longer needed.
Tokens\Collections: deprecate the propertyTypeTokensBC() method
This method is no longer needed.
Tokens\Collections: deprecate the returnTypeTokensBC() method
This method is no longer needed.
Tokens\Collections: remove remaining work-arounds for PHPCS < 3.7.1