public function isDeclaredAt()

in src/Fixers/ClientUpgradeFixer/ClientVar.php [41:62]


    public function isDeclaredAt(Tokens $tokens, int $index): bool
    {
        if ($tokens[$index]->getContent() !== $this->varName) {
            // The token does not contain this client var
            return false;
        }

        $token = $tokens[$index];
        if ($token->isGivenKind(T_VARIABLE)
            || ($token->isGivenKind(T_STRING) && $tokens[$index - 1]->isGivenKind(T_OBJECT_OPERATOR))
        ) {
            if ($this->parent) {
                // look back to ensure the parent matches
                if ($tokens[$index - 2]->getContent() !== $this->parent) {
                    return false;
                }
            }
            $this->startIndex = $index;
            return true;
        }
        return false;
    }