code: private function hasPossibleReferenceToThis(Tokens $tokens, $startIndex, $endIndex)
      {
          for ($i = $startIndex; $i < $endIndex; ++$i) {
              if ($tokens[$i]->isGivenKind(T_VARIABLE) && '$this' === strtolower($tokens[$i]->getContent())) {
                  return true; // directly accessing '$this'
              }
  
              if ($tokens[$i]->isGivenKind([
                  T_INCLUDE,                    // loading additional symbols we cannot analyze here
                  T_INCLUDE_ONCE,               // "
                  T_REQUIRE,                    // "
                  T_REQUIRE_ONCE,               // "
                  CT::T_DYNAMIC_VAR_BRACE_OPEN, // "$h = ${$g};" case
                  T_EVAL,                       // "$c = eval('return $this;');" case
              ])) {
                  return true;
              }
  
              if ($tokens[$i]->equals('$')) {
                  $nextIndex = $tokens->getNextMeaningfulToken($i);
                  if ($tokens[$nextIndex]->isGivenKind(T_VARIABLE)) {
                      return true; // "$$a" case
                  }
              }
          }
  
          return false;
      }
docs: Returns 'true' if there is a possible reference to '$this' within the given tokens index range.
  
  @param Tokens $tokens
  @param int    $startIndex
  @param int    $endIndex
  
  @return bool