=> */ protected $target_functions = array( 'in_array' => true, 'array_search' => true, 'array_keys' => false, ); /** * Process the parameters of a matched function. * * @since 0.11.0 * * @param int $stackPtr The position of the current token in the stack. * @param string $group_name The name of the group which was matched. * @param string $matched_content The token content (function name) which was matched. * @param array $parameters Array with information about the parameters. * * @return void */ public function process_parameters( $stackPtr, $group_name, $matched_content, $parameters ) { // Check if the strict check is actually needed. if ( false === $this->target_functions[ $matched_content ] ) { if ( \count( $parameters ) === 1 ) { return; } } // We're only interested in the third parameter. if ( false === isset( $parameters[3] ) || 'true' !== strtolower( $parameters[3]['raw'] ) ) { $errorcode = 'MissingTrueStrict'; /* * Use a different error code when `false` is found to allow for excluding * the warning as this will be a conscious choice made by the dev. */ if ( isset( $parameters[3] ) && 'false' === strtolower( $parameters[3]['raw'] ) ) { $errorcode = 'FoundNonStrictFalse'; } $this->phpcsFile->addWarning( 'Not using strict comparison for %s; supply true for third argument.', ( isset( $parameters[3]['start'] ) ? $parameters[3]['start'] : $parameters[1]['start'] ), $errorcode, array( $matched_content ) ); return; } } }