-
Notifications
You must be signed in to change notification settings - Fork 13
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
2.x | Tests: add attributes for annotations #189
Merged
hellofromtonya
merged 4 commits into
2.x
from
feature/2.x/add-attributes-for-annotations
Sep 6, 2024
Merged
2.x | Tests: add attributes for annotations #189
hellofromtonya
merged 4 commits into
2.x
from
feature/2.x/add-attributes-for-annotations
Sep 6, 2024
Conversation
This file contains 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
PHPUnit 10 introduced attributes as replacements for docblock annotations. PHPUnit 11 deprecates the use of docblock annotations in favour of attributes. If both an attribute as well as an annotation are found, no PHPUnit deprecation warning will be thrown. However, between PHPUnit 10.0 and PHPUnit 11.3.2, if the `failOnDeprecation` is set to `true` (which it is for this library as the builds should fail on deprecations in PHP), builds will _also_ fail on deprecation notices from PHPUnit itself. This behaviour was (finally) changed in PHPUnit 10.5.32 and 11.3.3 (released this week), but that's insufficient for our needs. For this library running the tests on high/low PHPUnit on each PHP version is imperative. It is also not the job of this library to decide the target PHPUnit versions for the consumer projects, so we cannot raise the minimum PHPUnit 11 version to 11.3.3. This means that without the attributes, the test runs for the package would fail on PHPUnit 11.0.0 - 11.3.2. As these attributes are already available in PHPUnit 10, it makes sense then to add them for both the 2.x branch, as well as the (upcoming) 3.x branch. This commit adds the `Covers*` attributes in all the appropriate places. The `@covers` annotations remain as code coverage also still needs to be measure on PHP 5.6 - 8.0 using PHPUnit 5.x - 9.x. These can be removed once the codebase has a PHP 8.1/PHPUnit 10 minimum requirement. Note: due to the syntax for attributes, these can be safely added as they are ignored as comments on PHP < 8.0. Along the same line, if there is no "listener" for the attributes (PHP 8.0/PHPUnit 9.x), they are ignored by PHP as well.
PHPUnit 10 introduced attributes as replacements for docblock annotations. PHPUnit 11 deprecates the use of docblock annotations in favour of attributes. If both an attribute as well as an annotation are found, no PHPUnit deprecation warning will be thrown. However, between PHPUnit 10.0 and PHPUnit 11.3.2, if the `failOnDeprecation` is set to `true` (which it is for this library as the builds should fail on deprecations in PHP), builds will _also_ fail on deprecation notices from PHPUnit itself. This behaviour was (finally) changed in PHPUnit 10.5.32 and 11.3.3 (released this week), but that's insufficient for our needs. For this library running the tests on high/low PHPUnit on each PHP version is imperative. It is also not the job of this library to decide the target PHPUnit versions for the consumer projects, so we cannot raise the minimum PHPUnit 11 version to 11.3.3. This means that without the attributes, the test runs for the package would fail on PHPUnit 11.0.0 - 11.3.2. As these attributes are already available in PHPUnit 10, it makes sense then to add them for both the 2.x branch, as well as the (upcoming) 3.x branch. This commit adds the `DataProvider` attributes in all the appropriate places. The `@dataProvider` annotations remain as the tests also still need to run on PHP 5.6 - 8.0 using PHPUnit 5.x - 9.x. These can be removed once the codebase has a PHP 8.1/PHPUnit 10 minimum requirement. Note: due to the syntax for attributes, these can be safely added as they are ignored as comments on PHP < 8.0. Along the same line, if there is no "listener" for the attributes (PHP 8.0/PHPUnit 9.x), they are ignored by PHP as well.
PHPUnit 10 introduced attributes as replacements for docblock annotations. PHPUnit 11 deprecates the use of docblock annotations in favour of attributes. If both an attribute as well as an annotation are found, no PHPUnit deprecation warning will be thrown. However, between PHPUnit 10.0 and PHPUnit 11.3.2, if the `failOnDeprecation` is set to `true` (which it is for this library as the builds should fail on deprecations in PHP), builds will _also_ fail on deprecation notices from PHPUnit itself. This behaviour was (finally) changed in PHPUnit 10.5.32 and 11.3.3 (released this week), but that's insufficient for our needs. For this library running the tests on high/low PHPUnit on each PHP version is imperative. It is also not the job of this library to decide the target PHPUnit versions for the consumer projects, so we cannot raise the minimum PHPUnit 11 version to 11.3.3. This means that without the attributes, the test runs for the package would fail on PHPUnit 11.0.0 - 11.3.2. As these attributes are already available in PHPUnit 10, it makes sense then to add them for both the 2.x branch, as well as the (upcoming) 3.x branch. This commit adds the `Requires*` attributes in all the appropriate places. The `@requires` annotations remain as the tests also still need to run on PHP 5.6 - 8.0 using PHPUnit 5.x - 9.x. These can be removed once the codebase has a PHP 8.1/PHPUnit 10 minimum requirement. Note: due to the syntax for attributes, these can be safely added as they are ignored as comments on PHP < 8.0. Along the same line, if there is no "listener" for the attributes (PHP 8.0/PHPUnit 9.x), they are ignored by PHP as well.
PHPUnit 10 introduced attributes as replacements for docblock annotations. PHPUnit 11 deprecates the use of docblock annotations in favour of attributes. If both an attribute as well as an annotation are found, no PHPUnit deprecation warning will be thrown. However, between PHPUnit 10.0 and PHPUnit 11.3.2, if the `failOnDeprecation` is set to `true` (which it is for this library as the builds should fail on deprecations in PHP), builds will _also_ fail on deprecation notices from PHPUnit itself. This behaviour was (finally) changed in PHPUnit 10.5.32 and 11.3.3 (released this week), but that's insufficient for our needs. For this library running the tests on high/low PHPUnit on each PHP version is imperative. It is also not the job of this library to decide the target PHPUnit versions for the consumer projects, so we cannot raise the minimum PHPUnit 11 version to 11.3.3. This means that without the attributes, the test runs for the package would fail on PHPUnit 11.0.0 - 11.3.2. As these attributes are already available in PHPUnit 10, it makes sense then to add them for both the 2.x branch, as well as the (upcoming) 3.x branch. This commit adds the `Before/After*` attributes in all the appropriate places. The `@before/after*` annotations remain as the tests also still need to run on PHP 5.6 - 8.0 using PHPUnit 5.x - 9.x. These can be removed once the codebase has a PHP 8.1/PHPUnit 10 minimum requirement. Note: due to the syntax for attributes, these can be safely added as they are ignored as comments on PHP < 8.0. Along the same line, if there is no "listener" for the attributes (PHP 8.0/PHPUnit 9.x), they are ignored by PHP as well.
hellofromtonya
approved these changes
Sep 6, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jrfnl Amazing work!
hellofromtonya
deleted the
feature/2.x/add-attributes-for-annotations
branch
September 6, 2024 17:19
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.
PHPUnit 10 introduced attributes as replacements for docblock annotations.
PHPUnit 11 deprecates the use of docblock annotations in favour of attributes.
If both an attribute as well as an annotation are found, no PHPUnit deprecation warning will be thrown.
However, between PHPUnit 10.0 and PHPUnit 11.3.2, if the
failOnDeprecation
is set totrue
(which it is for this library as the builds should fail on deprecations in PHP), builds will also fail on deprecation notices from PHPUnit itself.This behaviour was (finally) changed in PHPUnit 10.5.32 and 11.3.3 (released this week), but that's insufficient for our needs.
For this library running the tests on high/low PHPUnit on each PHP version is imperative. It is also not the job of this library to decide the target PHPUnit versions for the consumer projects, so we cannot raise the minimum PHPUnit 11 version to 11.3.3.
This means that without the attributes, the test runs for the package would fail on PHPUnit 11.0.0 - 11.3.2.
As these attributes are already available in PHPUnit 10, it makes sense then to add them for both the 2.x branch, as well as the (upcoming) 3.x branch.
Note: due to the syntax for attributes, these can be safely added as they are ignored as comments on PHP < 8.0.
Along the same line, if there is no "listener" for the attributes (PHP 8.0/PHPUnit 9.x), they are ignored by PHP as well.
Tests: add Covers* attributes
This commit adds the
Covers*
attributes in all the appropriate places.The
@covers
annotations remain as code coverage also still needs to be measure on PHP 5.6 - 8.0 using PHPUnit 5.x - 9.x.These can be removed once the codebase has a PHP 8.1/PHPUnit 10 minimum requirement.
Tests: add DataProvider attributes
This commit adds the
DataProvider
attributes in all the appropriate places.The
@dataProvider
annotations remain as the tests also still need to run on PHP 5.6 - 8.0 using PHPUnit 5.x - 9.x.These can be removed once the codebase has a PHP 8.1/PHPUnit 10 minimum requirement.
Tests: add Requires* attributes
This commit adds the
Requires*
attributes in all the appropriate places.The
@requires
annotations remain as the tests also still need to run on PHP 5.6 - 8.0 using PHPUnit 5.x - 9.x.These can be removed once the codebase has a PHP 8.1/PHPUnit 10 minimum requirement.
Tests: add Before/After[Class] attributes
This commit adds the
Before/After*
attributes in all the appropriate places.The
@before/after*
annotations remain as the tests also still need to run on PHP 5.6 - 8.0 using PHPUnit 5.x - 9.x.These can be removed once the codebase has a PHP 8.1/PHPUnit 10 minimum requirement.