Rules for global classes/functions ?

Author: yann-eugoneCreated Nov 11, 2020Updated Mar 3, 2026
LabelsType: enhancement

Thank you for maintaining this awesome tool ! :)

I did not find resources for this particular case, but maybe there is. If so, I'm sorry for not finding it.

I'm looking for a sniff (or 2 sniffs) that will allow to control the usage of global classes/function.


Lets take for instance Exception class and get_class function.

You could either :

require to import these globals

php
use Exception;
use function get_class;

get_class($var);
throw new Exception();

require to use trailing backslashes

php
\get_class($var);
throw new \Exception();

Source: squizlabs/PHP_CodeSniffer