You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This seems like a bug to me. You should be able to name your classes anything you want, especially within a namespace.
If you were going to run sniffs on class names (which I can't think of any use cases for) they'd be better off in their own DiscouragedPHPClasses sniff.
Consider the following test.php:
<?phpnamespaceFoo;
class System {
// Things
}
class Serialize {
// Things
}
And WordPress_Sniffs_PHP_DiscouragedPHPFunctionsSniff will throw:
FILE: test.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------
5 | WARNING | system() found. PHP system calls are often disabled
| | by server admins.
9 | WARNING | serialize() found. Serialized data has known
| | vulnerability problems with Object Injection. JSON is
| | generally a better approach for serializing data. See
| | https://www.owasp.org/index.php/PHP_Object_Injection
----------------------------------------------------------------------
The text was updated successfully, but these errors were encountered:
Yes, this is definitely a bug, the sniff needs to only flag function calls and not just any T_STRING. Adding T_CLASS to this list should fix the issue, I think.
This seems like a bug to me. You should be able to name your classes anything you want, especially within a namespace.
If you were going to run sniffs on class names (which I can't think of any use cases for) they'd be better off in their own
DiscouragedPHPClasses
sniff.Consider the following
test.php
:And
WordPress_Sniffs_PHP_DiscouragedPHPFunctionsSniff
will throw:The text was updated successfully, but these errors were encountered: