WordPress-Coding-Standards icon indicating copy to clipboard operation
WordPress-Coding-Standards copied to clipboard

Escape output sniff fix for static method calls

Open dingo-d opened this issue 1 year ago • 5 comments

As it currently is the following code

echo ClassName::someMethodName( $attributes, $test );

Would trigger the EscapeOutput sniff for the class name, but also for any attributes of the class method, except the first one.

The sniff should just trigger the class name, and bow out after that (what is inside the method is of no concern, as the output is all that matters).

I've added a test case and found the part that caused the issue (the *::class part didn't take into account static methods, only the *::class case).

This should fix it.

Adresses part of #1176

dingo-d avatar Aug 21 '23 21:08 dingo-d

The sniff should just trigger the class name, and bow out after that (what is inside the method is of no concern, as the output is all that matters).

Is that true though ?

Shouldn't the sniff skip over the method call, but then continue ?

Test case:

echo My::method($param), $somethingElse; // I'd expect two errors here, one for the method call, one for $somethingElse.

jrfnl avatar Aug 21 '23 21:08 jrfnl

Knew there must be edge cases I missed 😅

I'll work on this some more in the following days, I need to get some sleep 🙈

dingo-d avatar Aug 21 '23 21:08 dingo-d

@dingo-d Should this PR be moved back to draft for the time being ?

jrfnl avatar Aug 22 '23 06:08 jrfnl

@jrfnl The tests seem to be passing now, only the 2 seem to be stalling (or just taking an unusually long time).

dingo-d avatar Aug 28 '23 16:08 dingo-d

Any chance we can move this PR along?

dingo-d avatar Dec 11 '23 09:12 dingo-d