Commenting/TestsHaveCoversTag: support PHP 8.1 + 8.2, bug fix and various other improvements #331
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.