code: public function isAnonymousClass($index)
      {
          $tokens = $this->tokens;
          $token = $tokens[$index];
  
          if (!$token->isClassy()) {
              throw new \LogicException(sprintf('No classy token at given index %d.', $index));
          }
  
          if (!$token->isGivenKind(T_CLASS)) {
              return false;
          }
  
          return $tokens[$tokens->getPrevMeaningfulToken($index)]->isGivenKind(T_NEW);
      }
docs: Check if there is an anonymous class under given index.
  
  @param int $index
  
  @return bool