function IncludeSystemSniff::getIncludedClassFromToken
Determines the included class name from given token.
Parameters
\PHP_CodeSniffer\Files\File $phpcsFile The file where this token was found.:
array $tokens The array of file tokens.:
int $stackPtr The position in the tokens array of the: potentially included class.
Return value
string|false
2 calls to IncludeSystemSniff::getIncludedClassFromToken()
- IncludeSystemSniff::processTokenOutsideScope in vendor/
squizlabs/ php_codesniffer/ src/ Standards/ MySource/ Sniffs/ Channels/ IncludeSystemSniff.php - Processes a token within the scope that this test is listening to.
- IncludeSystemSniff::processTokenWithinScope in vendor/
squizlabs/ php_codesniffer/ src/ Standards/ MySource/ Sniffs/ Channels/ IncludeSystemSniff.php - Processes the function tokens within the class.
File
-
vendor/
squizlabs/ php_codesniffer/ src/ Standards/ MySource/ Sniffs/ Channels/ IncludeSystemSniff.php, line 293
Class
Namespace
PHP_CodeSniffer\Standards\MySource\Sniffs\ChannelsCode
protected function getIncludedClassFromToken(File $phpcsFile, array $tokens, $stackPtr) {
if (strtolower($tokens[$stackPtr]['content']) === 'includesystem') {
$systemName = $phpcsFile->findNext(T_CONSTANT_ENCAPSED_STRING, $stackPtr + 1);
$systemName = trim($tokens[$systemName]['content'], " '");
return strtolower($systemName);
}
else {
if (strtolower($tokens[$stackPtr]['content']) === 'includeasset') {
$typeName = $phpcsFile->findNext(T_CONSTANT_ENCAPSED_STRING, $stackPtr + 1);
$typeName = trim($tokens[$typeName]['content'], " '");
return strtolower($typeName) . 'assettype';
}
else {
if (isset(Tokens::$includeTokens[$tokens[$stackPtr]['code']]) === true) {
$filePath = $phpcsFile->findNext(T_CONSTANT_ENCAPSED_STRING, $stackPtr + 1);
$filePath = $tokens[$filePath]['content'];
$filePath = trim($filePath, " '");
$filePath = basename($filePath, '.inc');
return strtolower($filePath);
}
}
}
return false;
}