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

Commenting/CoversTag: flag deprecated syntaxes, bug fix and various other improvements #330

Merged
merged 6 commits into from
Nov 4, 2023

Conversation

jrfnl
Copy link
Collaborator

@jrfnl jrfnl commented Nov 4, 2023

Commenting/CoversTag: add some extra tests

... for situations previously not (yet) covered by tests.

Commenting/CoversTag: minor tweaks

  • Ensure (make it obvious) that $data is always available.
  • Use the correct data type for the stack pointers retrieved via the explode().
  • Defense in depth tweak.
  • Improve the readability of the code a little.

Commenting/CoversTag: make non-interface methods private

As the sniff class is now final (since PR #319), there is no need for any protected methods, so let's make these private.

Commenting/CoversTag: improve XML documentation

Update external reference links and minor textual improvements.

Commenting/CoversTag: bug fix - allow for <[!]visibility> format without class name

This is perfectly valid when used in combination with a @coversDefaultClass class level tag, but would be flagged by the sniff (false positives).

Fixed now. Includes tests.

Commenting/CoversTag: flag deprecated @covers tag formats

PHPUnit 9.0 (soft) deprecated the use of ClassName<*> type @covers annotations. Support for these type of annotation has been removed completely in PHPUnit 10.0.0.

This commit adds a new warning to the sniff, which will detect the use of these deprecated formats and flag them.

The choice for warning vs error is deliberate. The Yoast repos, for now, do not use PHPUnit 10.x yet, so for now, a warning is sufficient.
Once the repos would be upgraded to start using PHPUnit 10.x, this sniff should be updated and the warning changed to an error.

Includes tests.
Includes a new section in the XML docs about this new warning.

Refs:

jrfnl added 6 commits November 4, 2023 02:05
... for situations previously not (yet) covered by tests.
* Ensure (make it obvious) that `$data` is always available.
* Use the correct data type for the stack pointers retrieved via the `explode()`.
* Defense in depth tweak.
* Improve the readability of the code a little.
As the sniff class is now `final` (since PR 319), there is no need for any `protected` methods, so let's make these `private`.
Update external reference links and minor textual improvements.
…out class name

This is perfectly valid when used in combination with a `@coversDefaultClass` class level tag, but would be flagged by the sniff (false positives).

Fixed now. Includes tests.
PHPUnit 9.0 (soft) deprecated the use of `ClassName<*>` type `@covers` annotations. Support for these type of annotation has been removed completely in PHPUnit 10.0.0.

This commit adds a new _warning_ to the sniff, which will detect the use of these deprecated formats and flag them.

The choice for _warning_ vs _error_ is deliberate. The Yoast repos, for now, do not use PHPUnit 10.x yet, so for now, a warning is sufficient.
Once the repos would be upgraded to start using PHPUnit 10.x, this sniff should be updated and the `warning` changed to an `error`.

Includes tests.
Includes a new section in the XML docs about this new warning.

Refs:
* sebastianbergmann/phpunit 3630 (PHPUnit 9.0 deprecation).
* sebastianbergmann/phpunit 3631 (PHPUnit 10.0 removal).
@coveralls
Copy link

Coverage Status

coverage: 97.624% (+0.5%) from 97.146%
when pulling cd94f23 on JRF/yoastcs-coverstag-various-improvements
into 06cf5d2 on develop.

@jrfnl jrfnl merged commit 9d00928 into develop Nov 4, 2023
25 checks passed
@jrfnl jrfnl deleted the JRF/yoastcs-coverstag-various-improvements branch November 4, 2023 01:18
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.

2 participants