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

Collections: deprecate all properties for methods #311

Merged
merged 17 commits into from
Apr 19, 2022

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Apr 19, 2022

Over the last three PHP versions, PHP has steadily kept on introducing new tokens.

In the context of this class, the introduction of a new token means that a collection can no longer be a property and must be changed to a method with some logic instead.

With this in mind, all properties in the Collections class are being deprecated in favour of methods, to prevent the BC-breaks this kind of change would cause if left till later.

The deprecated properties will be removed (or made private) before the 1.0.0 version is tagged. The deprecation in the upcoming alpha gives standards which have started to implement the use of PHPCSUtils a little time to switch over though.

👉🏻 Note: in most cases, the method name is 100% the same as the property name, so switching over to the new methods should be a case of removing the $ sign and adding parentheses () after the name.

Commit details

Note: Unless noted differently, each commit includes only perfunctory unit tests for the new methods, as the methods don't contain any actual logic.
For now, it is just safeguarded that a) the methods are available and can be called and b) that the method is in line with the now deprecated property.

Where applicable, each commit also includes replacing any references to the deprecated properties in the PHPCSUtils codebase to now call the functions instead.

Collections: deprecate $alternativeControlStructureSyntax* in favour of alternativeControlStructureSyntax*()

Collections: remove $arrayOpenTokensBC in favour of arrayOpenTokensBC()

Note: as this property has been introduced during the alpha4 dev cycle, this property is being outright removed instead of being deprecated.

Includes only a perfunctory unit test for the new method, as the arrayOpenTokensBC() method doesn't contain any actual logic.
For now, it is just safeguarded that the method is available, can be called and returns the expected type of return value.

Collections: deprecate $arrayTokens[BC] in favour of arrayTokens[BC]()

Collections: deprecate $classModifierKeywords in favour of classModifierKeywords()

Collections: deprecate $closedScopes in favour of closedScopes()

Collections: deprecate $controlStructureTokens in favour of controlStructureTokens()

Collections: deprecate $incrementDecrementOperators in favour of incrementDecrementOperators()

Collections: deprecate $listTokens[BC] in favour of listTokens[BC]()

Collections: deprecate $magicConstants in favour of BCTokens::magicConstants()

Note: As PR #172 already introduced a method for the same in the BCTokens class as PHPCS 3.5.6 introduced a Tokens property for the same, no replacement has been added to the Collections class.

Includes replacing any references to this property in the PHPCSUtils codebase to now call the function in BCTokens instead.

Collections: deprecate $namespaceDeclarationClosers in favour of namespaceDeclarationClosers()

Collections: deprecate $OOCan(Implement|Extend) in favour of ooCan(Implement|Extend)()

Collections: deprecate $OO(Constant|Property)Scopes in favour of oo(Constant|Property)Scopes()

Collections: deprecate $OOHierarchyKeywords in favour of ooHierarchyKeywords()

Collections: deprecate $propertyModifierKeywords in favour of propertyModifierKeywords()

Collections: deprecate $shortArrayTokens[BC] in favour of shortArrayTokens[BC]()

Collections: deprecate $shortListTokens[BC] in favour of shortListTokens[BC]()

Collections: deprecate $textStingStartTokens in favour of textStingStartTokens()

…of alternativeControlStructureSyntax*()

Over the last three PHP versions, PHP has steadily kept on introducing new tokens.

In the context of this class, the introduction of a new token means that a collection can no longer be a property and must be changed to a method with some logic instead.

With this in mind, all properties in the `Collections` class are being deprecated in favour of methods, to prevent the BC-breaks this kind of change would cause if left till later.

The deprecated properties will be removed (or made `private`) before the `1.0.0` version is tagged. The deprecation in the upcoming alpha gives standards which have started to implement the use of PHPCSUtils a little time to switch over though.

Includes only perfunctory unit tests for the new methods, as the `alternativeControlStructureSyntax*()` methods don't contain any actual logic.
For now, it is just safeguarded that a) the methods are available and can be called and b) that the method is in line with the now deprecated property.
jrfnl added 15 commits April 19, 2022 08:09
Over the last three PHP versions, PHP has steadily kept on introducing new tokens.

In the context of this class, the introduction of a new token means that a collection can no longer be a property and must be changed to a method with some logic instead.

With this in mind, all properties in the `Collections` class are being deprecated in favour of methods, to prevent the BC-breaks this kind of change would cause if left till later.

The deprecated properties will be removed (or made `private`) before the `1.0.0` version is tagged. The deprecation in the upcoming alpha gives standards which have started to implement the use of PHPCSUtils a little time to switch over though.

**_Note: as this property has been introduced during the `alpha4` dev cycle, this property is being outright removed instead of being deprecated._**

Includes only a perfunctory unit test for the new method, as the `arrayOpenTokensBC()` method doesn't contain any actual logic.
For now, it is just safeguarded that the method is available, can be called and returns the expected type of return value.

Includes replacing any references to this property in the PHPCSUtils codebase to now call the function instead.
Over the last three PHP versions, PHP has steadily kept on introducing new tokens.

In the context of this class, the introduction of a new token means that a collection can no longer be a property and must be changed to a method with some logic instead.

With this in mind, all properties in the `Collections` class are being deprecated in favour of methods, to prevent the BC-breaks this kind of change would cause if left till later.

The deprecated properties will be removed (or made `private`) before the `1.0.0` version is tagged. The deprecation in the upcoming alpha gives standards which have started to implement the use of PHPCSUtils a little time to switch over though.

Includes only perfunctory unit tests for the new methods, as the `arrayTokens[BC]()` methods don't contain any actual logic.
For now, it is just safeguarded that a) the methods are available and can be called and b) that the method is in line with the now deprecated property.

Includes replacing any references to this property in the PHPCSUtils codebase to now call the function instead.
…ierKeywords()

Over the last three PHP versions, PHP has steadily kept on introducing new tokens.

In the context of this class, the introduction of a new token means that a collection can no longer be a property and must be changed to a method with some logic instead.

With this in mind, all properties in the `Collections` class are being deprecated in favour of methods, to prevent the BC-breaks this kind of change would cause if left till later.

The deprecated properties will be removed (or made `private`) before the `1.0.0` version is tagged. The deprecation in the upcoming alpha gives standards which have started to implement the use of PHPCSUtils a little time to switch over though.

Includes only a perfunctory unit test for the new method, as the `classModifierKeywords()` method doesn't contain any actual logic.
For now, it is just safeguarded that a) the method is available and can be called and b) that the method is in line with the now deprecated property.

Includes replacing any references to this property in the PHPCSUtils codebase to now call the function instead.
Over the last three PHP versions, PHP has steadily kept on introducing new tokens.

In the context of this class, the introduction of a new token means that a collection can no longer be a property and must be changed to a method with some logic instead.

With this in mind, all properties in the `Collections` class are being deprecated in favour of methods, to prevent the BC-breaks this kind of change would cause if left till later.

The deprecated properties will be removed (or made `private`) before the `1.0.0` version is tagged. The deprecation in the upcoming alpha gives standards which have started to implement the use of PHPCSUtils a little time to switch over though.

Includes only a perfunctory unit test for the new method, as the `closedScopes()` method doesn't contain any actual logic.
For now, it is just safeguarded that a) the method is available and can be called and b) that the method is in line with the now deprecated property.

Includes replacing any references to this property in the PHPCSUtils codebase to now call the function instead.
…ructureTokens()

Over the last three PHP versions, PHP has steadily kept on introducing new tokens.

In the context of this class, the introduction of a new token means that a collection can no longer be a property and must be changed to a method with some logic instead.

With this in mind, all properties in the `Collections` class are being deprecated in favour of methods, to prevent the BC-breaks this kind of change would cause if left till later.

The deprecated properties will be removed (or made `private`) before the `1.0.0` version is tagged. The deprecation in the upcoming alpha gives standards which have started to implement the use of PHPCSUtils a little time to switch over though.

Includes only a perfunctory unit test for the new method, as the `controlStructureTokens()` method doesn't contain any actual logic.
For now, it is just safeguarded that a) the method is available and can be called and b) that the method is in line with the now deprecated property.

Includes replacing any references to this property in the PHPCSUtils codebase to now call the function instead.
…ementDecrementOperators()

Over the last three PHP versions, PHP has steadily kept on introducing new tokens.

In the context of this class, the introduction of a new token means that a collection can no longer be a property and must be changed to a method with some logic instead.

With this in mind, all properties in the `Collections` class are being deprecated in favour of methods, to prevent the BC-breaks this kind of change would cause if left till later.

The deprecated properties will be removed (or made `private`) before the `1.0.0` version is tagged. The deprecation in the upcoming alpha gives standards which have started to implement the use of PHPCSUtils a little time to switch over though.

Includes only a perfunctory unit test for the new method, as the `incrementDecrementOperators()` method doesn't contain any actual logic.
For now, it is just safeguarded that a) the method is available and can be called and b) that the method is in line with the now deprecated property.

Includes replacing any references to this property in the PHPCSUtils codebase to now call the function instead.
Over the last three PHP versions, PHP has steadily kept on introducing new tokens.

In the context of this class, the introduction of a new token means that a collection can no longer be a property and must be changed to a method with some logic instead.

With this in mind, all properties in the `Collections` class are being deprecated in favour of methods, to prevent the BC-breaks this kind of change would cause if left till later.

The deprecated properties will be removed (or made `private`) before the `1.0.0` version is tagged. The deprecation in the upcoming alpha gives standards which have started to implement the use of PHPCSUtils a little time to switch over though.

Includes only perfunctory unit tests for the new methods, as the `listTokens[BC]()` methods don't contain any actual logic.
For now, it is just safeguarded that a) the methods are available and can be called and b) that the method is in line with the now deprecated property.

Includes replacing any references to this property in the PHPCSUtils codebase to now call the function instead.
…nstants()

Over the last three PHP versions, PHP has steadily kept on introducing new tokens.

In the context of this class, the introduction of a new token means that a collection can no longer be a property and must be changed to a method with some logic instead.

With this in mind, all properties in the `Collections` class are being deprecated in favour of methods, to prevent the BC-breaks this kind of change would cause if left till later.

The deprecated properties will be removed (or made `private`) before the `1.0.0` version is tagged. The deprecation in the upcoming alpha gives standards which have started to implement the use of PHPCSUtils a little time to switch over though.

**Note**: As PR 172 already introduced a method for the same in the `BCTokens` class as PHPCS 3.5.6 introduced a `Tokens` property for the same, no replacement has been added to the `Collections` class.

Includes replacing any references to this property in the PHPCSUtils codebase to now call the function in `BCTokens` instead.
…spaceDeclarationClosers()

Over the last three PHP versions, PHP has steadily kept on introducing new tokens.

In the context of this class, the introduction of a new token means that a collection can no longer be a property and must be changed to a method with some logic instead.

With this in mind, all properties in the `Collections` class are being deprecated in favour of methods, to prevent the BC-breaks this kind of change would cause if left till later.

The deprecated properties will be removed (or made `private`) before the `1.0.0` version is tagged. The deprecation in the upcoming alpha gives standards which have started to implement the use of PHPCSUtils a little time to switch over though.

Includes only a perfunctory unit test for the new method, as the `namespaceDeclarationClosers()` method doesn't contain any actual logic.
For now, it is just safeguarded that a) the method is available and can be called and b) that the method is in line with the now deprecated property.

Includes replacing any references to this property in the PHPCSUtils codebase to now call the function instead.
…plement|Extend)()

Over the last three PHP versions, PHP has steadily kept on introducing new tokens.

In the context of this class, the introduction of a new token means that a collection can no longer be a property and must be changed to a method with some logic instead.

With this in mind, all properties in the `Collections` class are being deprecated in favour of methods, to prevent the BC-breaks this kind of change would cause if left till later.

The deprecated properties will be removed (or made `private`) before the `1.0.0` version is tagged. The deprecation in the upcoming alpha gives standards which have started to implement the use of PHPCSUtils a little time to switch over though.

Includes only perfunctory unit tests for the new methods, as the `ooCan(Implement|Extend)()` methods don't contain any actual logic.
For now, it is just safeguarded that a) the methods are available and can be called and b) that the method is in line with the now deprecated property.

Includes replacing any references to this property in the PHPCSUtils codebase to now call the function instead.
…onstant|Property)Scopes()

Over the last three PHP versions, PHP has steadily kept on introducing new tokens.

In the context of this class, the introduction of a new token means that a collection can no longer be a property and must be changed to a method with some logic instead.

With this in mind, all properties in the `Collections` class are being deprecated in favour of methods, to prevent the BC-breaks this kind of change would cause if left till later.

The deprecated properties will be removed (or made `private`) before the `1.0.0` version is tagged. The deprecation in the upcoming alpha gives standards which have started to implement the use of PHPCSUtils a little time to switch over though.

Includes only perfunctory unit tests for the new methods, as the `oo(Constant|Property)Scopes()` methods don't contain any actual logic.
For now, it is just safeguarded that a) the methods are available and can be called and b) that the method is in line with the now deprecated property.

Includes replacing any references to this property in the PHPCSUtils codebase to now call the function instead.
…eywords()

Over the last three PHP versions, PHP has steadily kept on introducing new tokens.

In the context of this class, the introduction of a new token means that a collection can no longer be a property and must be changed to a method with some logic instead.

With this in mind, all properties in the `Collections` class are being deprecated in favour of methods, to prevent the BC-breaks this kind of change would cause if left till later.

The deprecated properties will be removed (or made `private`) before the `1.0.0` version is tagged. The deprecation in the upcoming alpha gives standards which have started to implement the use of PHPCSUtils a little time to switch over though.

Includes only a perfunctory unit test for the new method, as the `ooHierarchyKeywords()` method doesn't contain any actual logic.
For now, it is just safeguarded that a) the method is available and can be called and b) that the method is in line with the now deprecated property.

Includes replacing any references to this property in the PHPCSUtils codebase to now call the function instead.
…yModifierKeywords()

Over the last three PHP versions, PHP has steadily kept on introducing new tokens.

In the context of this class, the introduction of a new token means that a collection can no longer be a property and must be changed to a method with some logic instead.

With this in mind, all properties in the `Collections` class are being deprecated in favour of methods, to prevent the BC-breaks this kind of change would cause if left till later.

The deprecated properties will be removed (or made `private`) before the `1.0.0` version is tagged. The deprecation in the upcoming alpha gives standards which have started to implement the use of PHPCSUtils a little time to switch over though.

Includes only a perfunctory unit test for the new method, as the `propertyModifierKeywords()` method doesn't contain any actual logic.
For now, it is just safeguarded that a) the method is available and can be called and b) that the method is in line with the now deprecated property.

Includes replacing any references to this property in the PHPCSUtils codebase to now call the function instead.
…okens[BC]()

Over the last three PHP versions, PHP has steadily kept on introducing new tokens.

In the context of this class, the introduction of a new token means that a collection can no longer be a property and must be changed to a method with some logic instead.

With this in mind, all properties in the `Collections` class are being deprecated in favour of methods, to prevent the BC-breaks this kind of change would cause if left till later.

The deprecated properties will be removed (or made `private`) before the `1.0.0` version is tagged. The deprecation in the upcoming alpha gives standards which have started to implement the use of PHPCSUtils a little time to switch over though.

Includes only perfunctory unit tests for the new methods, as the `shortArrayTokens[BC]()` methods don't contain any actual logic.
For now, it is just safeguarded that a) the methods are available and can be called and b) that the method is in line with the now deprecated property.

Includes replacing any references to this property in the PHPCSUtils codebase to now call the function instead.
…ens[BC]()

Over the last three PHP versions, PHP has steadily kept on introducing new tokens.

In the context of this class, the introduction of a new token means that a collection can no longer be a property and must be changed to a method with some logic instead.

With this in mind, all properties in the `Collections` class are being deprecated in favour of methods, to prevent the BC-breaks this kind of change would cause if left till later.

The deprecated properties will be removed (or made `private`) before the `1.0.0` version is tagged. The deprecation in the upcoming alpha gives standards which have started to implement the use of PHPCSUtils a little time to switch over though.

Includes only perfunctory unit tests for the new methods, as the `shortListTokens[BC]()` methods don't contain any actual logic.
For now, it is just safeguarded that a) the methods are available and can be called and b) that the method is in line with the now deprecated property.

Includes replacing any references to this property in the PHPCSUtils codebase to now call the function instead.
@jrfnl jrfnl force-pushed the collections/deprecate-most-properties-for-methods branch from b07139e to 18c7606 Compare April 19, 2022 06:10
@jrfnl jrfnl enabled auto-merge April 19, 2022 06:10
…artTokens()

Over the last three PHP versions, PHP has steadily kept on introducing new tokens.

In the context of this class, the introduction of a new token means that a collection can no longer be a property and must be changed to a method with some logic instead.

With this in mind, all properties in the `Collections` class are being deprecated in favour of methods, to prevent the BC-breaks this kind of change would cause if left till later.

The deprecated properties will be removed (or made `private`) before the `1.0.0` version is tagged. The deprecation in the upcoming alpha gives standards which have started to implement the use of PHPCSUtils a little time to switch over though.

Includes only a perfunctory unit test for the new method, as the `textStingStartTokens()` method doesn't contain any actual logic.
For now, it is just safeguarded that a) the method is available and can be called and b) that the method is in line with the now deprecated property.

Includes replacing any references to this property in the PHPCSUtils codebase to now call the function instead.
@jrfnl jrfnl force-pushed the collections/deprecate-most-properties-for-methods branch from 18c7606 to a44b016 Compare April 19, 2022 06:14
@jrfnl jrfnl merged commit 4d72dbc into develop Apr 19, 2022
@jrfnl jrfnl deleted the collections/deprecate-most-properties-for-methods branch April 19, 2022 06:19
@jrfnl
Copy link
Member Author

jrfnl commented Jun 7, 2022

Related #319 - one property + the replacement method contained a typo. This has been fixed in #319.

jrfnl added a commit that referenced this pull request Dec 24, 2022
Use the PHPCS native `Tokens::$magicConstants` property or the `PHPCSUtils\BackCompat\BCTokens::magicConstants()` method instead.

Follow up on #106, #172, #311.
jrfnl added a commit that referenced this pull request Dec 24, 2022
... and remove the remaining methods without logic (but which had a name change one way or the other).

Follow-up after #202, #311.

Includes updating the tests:
* Mostly remove method specific tests and move those to the `PropertyBasedTokenArraysTest`.
* For the "type" token arrays - update the order of the expected arrays.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant