PEAR/FunctionCallSignature: minor tweaks + extra test#3667
PEAR/FunctionCallSignature: minor tweaks + extra test#3667jrfnl wants to merge 1 commit intosquizlabs:masterfrom
Conversation
|
Note: the test failure on PHP 8.2 is unrelated to this PR and also happening on Also note that this PR will conflict (on the tests) with PR #3636. I will rebase and fix the conflict depending on which PR gets merged first. |
This is related to the PHP 8.2 disjunctive normal types feature which changed the tokenization - see: php/php-src#9512 This needs to be fixed when support for DNF is added to the PHPCS tokenizer. |
GaryJones
left a comment
There was a problem hiding this comment.
Tested the fix for the original WPCS report, and all seems well. ✅
Found myself here while looking into the failure. This looks to caused by tokenization of function calls changing when the name is $var = readonly()So where the string |
The change in PHP was intentional to support disjunctive normal types for readonly properties, see the issue I linked above. class Dnf {
private readonly (B&C)|A $d;
} |
|
(and yeah, DNT is not going to be fun to sort out in the tokenizer.... I have a feeling we'll probably need to add |
Minor defensive coding and documentation improvements + an additional unit test.
b5aaa31 to
a63f040
Compare
|
Closing as replaced by PHPCSStandards/PHP_CodeSniffer#134 |
Originally reported in WordPress/WordPress-Coding-Standards#2083
The fixer for the
OpeningIndenterror for multi-line function calls could inadvertently remove a PHP close tag (or other inline HTML content) on the previous line if the first non-whitespace token on a line wasT_INLINE_HTML. In the case of a PHP close tag, this would cause a parse error in the file.This parse error would then result in the file being incorrectly tokenized for the second fixer loop, with the
<?phpafter the inline HTML being tokenized as below, which causes problems with other sniffs:Fixed now.
Includes unit test.
Includes minor defensive coding fix (
$first !== false) on line 345 and adding of an inline comment to clarify the code within the fixer.