getCanonicalNameAsReferencedInFile() public method

Exemplo n.º 1
0
 /**
  * @param \PHP_CodeSniffer_File $phpcsFile
  * @param integer $openTagPointer
  * @return \SlevomatCodingStandard\Helpers\UseStatement[] canonicalName(string) => useStatement(\SlevomatCodingStandard\Helpers\UseStatement)
  */
 public static function getUseStatements(PHP_CodeSniffer_File $phpcsFile, $openTagPointer)
 {
     $names = [];
     foreach (self::getUseStatementPointers($phpcsFile, $openTagPointer) as $usePointer) {
         $name = self::getNameAsReferencedInClassFromUse($phpcsFile, $usePointer);
         $useStatement = new UseStatement($name, self::getFullyQualifiedTypeNameFromUse($phpcsFile, $usePointer), $usePointer);
         $names[$useStatement->getCanonicalNameAsReferencedInFile()] = $useStatement;
     }
     return $names;
 }
 /**
  * @param \PHP_CodeSniffer_File $phpcsFile
  * @param integer $openTagPointer
  * @return \SlevomatCodingStandard\Helpers\UseStatement[] canonicalName(string) => useStatement(\SlevomatCodingStandard\Helpers\UseStatement)
  */
 public static function getUseStatements(PHP_CodeSniffer_File $phpcsFile, $openTagPointer)
 {
     $names = [];
     $tokens = $phpcsFile->getTokens();
     foreach (self::getUseStatementPointers($phpcsFile, $openTagPointer) as $usePointer) {
         $nextTokenFromUsePointer = TokenHelper::findNextEffective($phpcsFile, $usePointer + 1);
         $type = UseStatement::TYPE_DEFAULT;
         if ($tokens[$nextTokenFromUsePointer]['code'] === T_STRING) {
             if ($tokens[$nextTokenFromUsePointer]['content'] === 'const') {
                 $type = UseStatement::TYPE_CONSTANT;
             } elseif ($tokens[$nextTokenFromUsePointer]['content'] === 'function') {
                 $type = UseStatement::TYPE_FUNCTION;
             }
         }
         $name = self::getNameAsReferencedInClassFromUse($phpcsFile, $usePointer);
         $useStatement = new UseStatement($name, self::getFullyQualifiedTypeNameFromUse($phpcsFile, $usePointer), $usePointer, $type);
         $names[$useStatement->getCanonicalNameAsReferencedInFile()] = $useStatement;
     }
     return $names;
 }