code: public function getImportUseIndexes($perNamespace = false)
      {
          $tokens = $this->tokens;
  
          $tokens->rewind();
  
          $uses = [];
          $namespaceIndex = 0;
  
          for ($index = 0, $limit = $tokens->count(); $index < $limit; ++$index) {
              $token = $tokens[$index];
  
              if ($token->isGivenKind(T_NAMESPACE)) {
                  $nextTokenIndex = $tokens->getNextTokenOfKind($index, [';', '{']);
                  $nextToken = $tokens[$nextTokenIndex];
  
                  if ($nextToken->equals('{')) {
                      $index = $nextTokenIndex;
                  }
  
                  if ($perNamespace) {
                      ++$namespaceIndex;
                  }
  
                  continue;
              }
  
              if ($token->isGivenKind(T_USE)) {
                  $uses[$namespaceIndex][] = $index;
              }
          }
  
          if (!$perNamespace && isset($uses[$namespaceIndex])) {
              return $uses[$namespaceIndex];
          }
  
          return $uses;
      }
docs: Get indexes of namespace uses.
  
  @param bool $perNamespace Return namespace uses per namespace
  
  @return int[]|int[][]