Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Checks if a value exists in an array
<?php in_array(mixed $needle, array $haystack, bool $strict = false): bool
<?php }
if (\in_array($tokens[$stackPtr - 1]['code'], [\T_PARENT, \T_STATIC], true)) {
return '';
}
<?php $isError = false;
if (isset($this->newDirectives[$directive]['valid_values'])) {
if (\in_array($value, $this->newDirectives[$directive]['valid_values']) === false) {
$isError = true;
}
} elseif (isset($this->newDirectives[$directive]['valid_value_callback'])) {
<?php return true;
}
return \in_array($value, $encodings, true);
}
}
<?php if (\is_array($this->functionWhitelist) === true) {
$this->functionWhitelist = \array_map('strtolower', $this->functionWhitelist);
return \in_array($content, $this->functionWhitelist, true);
}
return false;
<?php continue;
}
} elseif ($foundFunctionName === 'func_get_args' && isset($paramNamesSubset)) {
if (\in_array($tokens[$j]['content'], $paramNamesSubset, true) === false) {
continue;
}
<?php continue;
}
} elseif (\in_array($tokens[$j]['content'], $paramNames, true) === false) {
continue;
}
<?php protected function isEndOfUseStatement($token)
{
return \in_array($token['code'], [\T_CLOSE_CURLY_BRACKET, \T_SEMICOLON, \T_COMMA], true);
}
}
<?php $prevToken = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
if ($prevToken !== false
&& \in_array($tokens[$prevToken]['code'], [\T_DOUBLE_COLON, \T_OBJECT_OPERATOR], true) === false
) {
if ($tokens[$prevToken]['code'] === \T_BITWISE_AND) {
<?php $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($variable + 1), $varEnd, true);
if ($next !== false
&& \in_array($tokens[$next]['code'], [\T_OPEN_SQUARE_BRACKET, \T_OBJECT_OPERATOR, \T_DOUBLE_COLON], true) === true
) {
$phpcsFile->addError(
'Global with variable variables is not allowed since PHP 7.0. Found %s',
<?php $prevToken = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true, null, true);
if ($prevToken === false || \in_array($tokens[$prevToken]['code'], [\T_DOLLAR, \T_OBJECT_OPERATOR, \T_DOUBLE_COLON], true) === false) {
return;
}