Various sniffs: start using new PHPCSUtils 1.1.0 TypeString utility#1837
Merged
Various sniffs: start using new PHPCSUtils 1.1.0 TypeString utility#1837
Conversation
…tils 1.1.0 TypeString utility
PHPCSUtils introduces a new `PHPCSUtils\Utils\TypeString` utility class, which allows for consistent analysis of type strings.
This commit starts using this new utility in the `NewParamTypeDeclarations` sniff.
Includes minor adjustments to the tests:
* One test will no longer be flagged as it is not a valid type in PHP. In my opinion, this is fine as PHPCompatibility is not about detecting invalid code.
Note: this test has not been added to the `dataNewDNFTypesNoFalsePositives()` data provider, as the type includes `null` and that's flagged on PHP < 8.2 for other reasons and that aspect of the test is still valid.
* One test has been updated to safeguard that nullable "long form" types will still be flagged correctly.
…Utils 1.1.0 TypeString utility
PHPCSUtils introduces a new `PHPCSUtils\Utils\TypeString` utility class, which allows for consistent analysis of type strings.
This commit starts using this new utility in the `NewReturnTypeDeclarations` sniff.
Includes minor adjustments to the tests:
* One test will no longer be flagged as it is not a valid type in PHP. In my opinion, this is fine as PHPCompatibility is not about detecting invalid code.
This test will now be checked via the "no false positives for DNF types" test.
…ng utility
PHPCSUtils introduces a new `PHPCSUtils\Utils\TypeString` utility class, which allows for consistent analysis of type strings.
This commit starts using this new utility in the `NewTypedProperties` sniff.
Includes minor adjustments to the tests:
* One test will no longer be flagged as it is not a valid type in PHP. In my opinion, this is fine as PHPCompatibility is not about detecting invalid code.
This test will now be checked via the "no false positives for DNF types" test.
* One test has been updated to safeguard that nullable "long form" types will still be flagged correctly.
PHPCSUtils introduces a new `PHPCSUtils\Utils\TypeString` utility class, which allows for consistent analysis of type strings. This commit starts using this new utility in the `NewClasses` sniff. Includes minor improvements to the tests related to this.
…tility PHPCSUtils introduces a new `PHPCSUtils\Utils\TypeString` utility class, which allows for consistent analysis of type strings. This commit starts using this new utility in the `RemovedClasses` sniff. Includes minor improvements to the tests related to this.
… utility PHPCSUtils introduces a new `PHPCSUtils\Utils\TypeString` utility class, which allows for consistent analysis of type strings. This commit starts using this new utility in the `NewInterfaces` sniff.
…tion ... by using the PHPCSUtils 1.1.0 TypeString::isNullable()` method.
wimg
approved these changes
Aug 13, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PHPCSUtils introduces a new
PHPCSUtils\Utils\TypeStringutility class, which allows for consistent analysis of type strings.FunctionDeclarations/NewParamTypeDeclarations: start using new PHPCSUtils 1.1.0 TypeString utility
This commit starts using this new utility in the
NewParamTypeDeclarationssniff.Includes minor adjustments to the tests:
Note: this test has not been added to the
dataNewDNFTypesNoFalsePositives()data provider, as the type includesnulland that's flagged on PHP < 8.2 for other reasons and that aspect of the test is still valid.FunctionDeclarations/NewReturnTypeDeclarations: start using new PHPCSUtils 1.1.0 TypeString utility
This commit starts using this new utility in the
NewReturnTypeDeclarationssniff.Includes minor adjustments to the tests:
This test will now be checked via the "no false positives for DNF types" test.
Classes/NewTypedProperties: start using new PHPCSUtils 1.1.0 TypeString utility
This commit starts using this new utility in the
NewTypedPropertiessniff.Includes minor adjustments to the tests:
This test will now be checked via the "no false positives for DNF types" test.
Classes/NewClasses: start using new PHPCSUtils 1.1.0 TypeString utility
This commit starts using this new utility in the
NewClassessniff.Includes minor improvements to the tests related to this.
Classes/RemovedClasses: start using new PHPCSUtils 1.1.0 TypeString utility
This commit starts using this new utility in the
RemovedClassessniff.Includes minor improvements to the tests related to this.
Interfaces/NewInterfaces: start using new PHPCSUtils 1.1.0 TypeString utility
This commit starts using this new utility in the
NewInterfacessniff.FunctionDeclarations/RemovedImplicitlyNullableParam: minor simplification
... by using the PHPCSUtils 1.1.0 TypeString::isNullable()` method.