code: public function isLambda($index)
      {
          if (!$this->tokens[$index]->isGivenKind(T_FUNCTION)) {
              throw new \LogicException(sprintf('No T_FUNCTION at given index %d, got %s.', $index, $this->tokens[$index]->getName()));
          }
  
          $startParenthesisIndex = $this->tokens->getNextMeaningfulToken($index);
          $startParenthesisToken = $this->tokens[$startParenthesisIndex];
  
          // skip & for `function & () {}` syntax
          if ($startParenthesisToken->isGivenKind(CT::T_RETURN_REF)) {
              $startParenthesisIndex = $this->tokens->getNextMeaningfulToken($startParenthesisIndex);
              $startParenthesisToken = $this->tokens[$startParenthesisIndex];
          }
  
          return $startParenthesisToken->equals('(');
      }
docs: Check if the function under given index is a lambda.
  
  @param int $index
  
  @return bool