phpcs-security-audit icon indicating copy to clipboard operation
phpcs-security-audit copied to clipboard

Add support for native function imports

Open smrhoney opened this issue 4 years ago • 0 comments

The following code fails to scan due to line 6 (use function usort).

<?php
namespace Demo;

use function strlen;
use function usort;
use function var_dump;


$data = [
    "test-one",
    "test-three",
    "test-two",
    "test-four",
];

$sortCallback = function ($a, $b) {
    $lA = strlen($a);
    $lB = strlen($b);

    if ($lA == $lB) {
        return 0;
    }

    return  $lA < $lB ? -1 : 1;
};

usort($data, $sortCallback);
var_dump($data);

Getting error: An error occurred during processing; checking has been aborted. The error message was: Undefined index: parenthesis_closer in ...\Sniffs\BadFunctions\CallbackFunctionsSniff.php on line 34

Can you allow for native function imports?

smrhoney avatar Jul 27 '21 19:07 smrhoney