-
Notifications
You must be signed in to change notification settings - Fork 3
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/TestsHaveCoversTag: support PHP 8.1 + 8.2, bug fix and various other improvements #331
Merged
jrfnl
merged 9 commits into
develop
from
JRF/yoastcs-testshavecoverstag-various-improvements
Nov 4, 2023
Merged
Commenting/TestsHaveCoversTag: support PHP 8.1 + 8.2, bug fix and various other improvements #331
jrfnl
merged 9 commits into
develop
from
JRF/yoastcs-testshavecoverstag-various-improvements
Nov 4, 2023
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
Add some more variation of class/method prefixes to the tests to better safeguard the handling of those.
... to allow for additional test case files to be added.
... for situations previously not (yet) covered by tests.
As the sniff class is now `final` (since PR 319), there is no need for any `protected` methods, so let's make these `private`.
…notice during live coding [1] When scanning code during live coding in an IDE, the `ObjectDeclarations::getName()` method could return `null`. This fix prevents a PHP 8.1 "substr(): Passing null to parameter #1 ($string) of type string is deprecated" deprecation notice in that situation. Includes test.
…notice during live coding [2] When scanning code during live coding/while scanning code containing a parse error, the `FunctionDeclarations::getName()` method could return `null`. This fix prevents a PHP 8.1 "stripos(): Passing null to parameter #1 ($string) of type string is deprecated" deprecation notice in that situation. Includes test.
…obal function Test functions in the context of PHPUnit tests **must** be OO methods in a child class of the PHPUnit native `TestCase` class. Global functions will never be run as tests, so can be disregarded for the purposes of this sniff without further examination. Includes test.
* Remove an unnecessary condition. * Remove a `return` which will never receive a value to return. * Bow out earlier if something useful was found. No need to continue examining. * Minor doc updates for future reference.
While probably rare, the sniff should still find the docblock for a test class marked as `readonly` without breaking on the `readonly` keyword. Fixed now. Includes tests.
jrfnl
force-pushed
the
JRF/yoastcs-testshavecoverstag-various-improvements
branch
from
November 4, 2023 01:15
39f8b89
to
d36d2ae
Compare
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.
Commenting/TestsHaveCoversTag: minor test improvements
Add some more variation of class/method prefixes to the tests to better safeguard the handling of those.
Commenting/TestsHaveCoversTag: rename test case file
... to allow for additional test case files to be added.
Commenting/TestsHaveCoversTag: add some extra tests
... for situations previously not (yet) covered by tests.
Commenting/TestsHaveCoversTag: make non-interface methods private
As the sniff class is now
final
(since PR #319), there is no need for anyprotected
methods, so let's make theseprivate
.Commenting/TestsHaveCoversTag: bug fix - prevent PHP 8.1 deprecation notice during live coding [1]
When scanning code during live coding in an IDE, the
ObjectDeclarations::getName()
method could returnnull
.This fix prevents a PHP 8.1 "substr(): Passing null to parameter #1 ($string) of type string is deprecated" deprecation notice in that situation.
Includes test.
Commenting/TestsHaveCoversTag: bug fix - prevent PHP 8.1 deprecation notice during live coding [2]
When scanning code during live coding/while scanning code containing a parse error, the
FunctionDeclarations::getName()
method could returnnull
.This fix prevents a PHP 8.1 "stripos(): Passing null to parameter #1 ($string) of type string is deprecated" deprecation notice in that situation.
Includes test.
Commenting/TestsHaveCoversTag: bug fix - prevent false positive on global function
Test functions in the context of PHPUnit tests must be OO methods in a child class of the PHPUnit native
TestCase
class.Global functions will never be run as tests, so can be disregarded for the purposes of this sniff without further examination.
Includes test.
Commenting/TestsHaveCoversTag: minor tweaks
return
which will never receive a value to return.Commenting/TestsHaveCoversTag: handle PHP 8.2 readonly classes
While probably rare, the sniff should still find the docblock for a test class marked as
readonly
without breaking on thereadonly
keyword.Fixed now. Includes tests.