$token) { if ($token[0] === T_STRING && strtolower($token[1]) === 'match') { $previousNonSpaceToken = $this->getPreviousNonSpaceToken($tokens, $i); if ($previousNonSpaceToken !== null && $previousNonSpaceToken[0] === T_OBJECT_OPERATOR) { continue; } $tokens[$i][0] = Emulative::T_MATCH; } } return $tokens; } /** * @param mixed[] $tokens * @return mixed[]|null */ private function getPreviousNonSpaceToken(array $tokens, int $start) { for ($i = $start - 1; $i >= 0; --$i) { if ($tokens[$i][0] === T_WHITESPACE) { continue; } return $tokens[$i]; } return null; } }