> */ protected $hashAlgoFunctions = [ 'hash_file' => [ 'position' => 1, 'name' => 'algo', ], 'hash_hmac_file' => [ 'position' => 1, 'name' => 'algo', ], 'hash_hmac' => [ 'position' => 1, 'name' => 'algo', ], 'hash_init' => [ 'position' => 1, 'name' => 'algo', ], 'hash_pbkdf2' => [ 'position' => 1, 'name' => 'algo', ], 'hash' => [ 'position' => 1, 'name' => 'algo', ], ]; /** * Get the hash algorithm name from the parameter in a hash function call. * * @since 7.0.7 Logic moved from the `RemovedHashAlgorithms` sniff to the generic `Sniff` class. * @since 10.0.0 Moved from the base `Sniff` class to the `HashAlgorithmsTrait` * and changed significantly. * * @param string $functionName The token content (function name) which was matched. * @param array $parameters Array with information about the parameters. * * @return string|false The algorithm name without quotes if this was a relevant hash * function call or false if it was not. */ public function getHashAlgorithmParameter($functionName, array $parameters) { // Get the parameter which should contain the algorithm name from the parameter stack. $functionNameLc = \strtolower($functionName); $paramInfo = $this->hashAlgoFunctions[$functionNameLc]; $algoParam = PassedParameters::getParameterFromStack($parameters, $paramInfo['position'], $paramInfo['name']); if ($algoParam === false) { return false; } // Algorithm is a text string, so we need to remove the quotes. return TextStrings::stripQuotes(\strtolower($algoParam['clean'])); } }