You can use the slash to make sure you are using the native PHP function or constant and not the function / constant with the same name defined in a namespace of the project.
namespace test;
function array_push($arr, $str) {
return $str;
}
$arr = [];
var_dump(array_push($arr, 'Hello World')); // array_push defined in namespace test
var_dump(\array_push($arr, 'Hello World')); // native array_push function
demo: https://ideone.com/3xoFhm
Another case why you can use the \
slash is to speed up the resolving (as mentioned on the PHP-CS-Fixer documentation). PHP doesn't need to use the autoloader to find the function or constant declaration. So with leading \
PHP can use native function without additional checks.
You can toggle this option on the PHP-CS-Fixer with the native_function_invocation
(for functions) and native_constant_invocation
(for constants) option. You can find an explanation of the options on the following page: https://github.com/FriendsOfPHP/PHP-CS-Fixer