/** * If $constant is the start of the constant defining $key, updat its value to $value * * @param Collection $tokens * @param Token $constant * @param string $key * @param mixed $value */ private function handleConstant(Collection $tokens, Token $constant, $key, $value) { $lineEnd = false; $found = false; $index = $constant->getIndex(); $tokens->rewind(); while ($lineEnd === false && ($constantToken = $tokens->getNext($index))) { if ($constantToken->getValue() === ';') { $lineEnd = true; } if ($constantToken->getType() === T_STRING && $constantToken->getValue() === $key) { $found = true; } elseif ($found === true) { $this->attemptUpdate($constantToken, $value); } $index++; } }
/** * @param Collection $collection * @return LineTokenData[] */ protected function getInvalidStartTokens(Collection $collection) { $data = []; foreach ($collection as $tag) { if (T_OPEN_TAG !== $tag->getType()) { continue; } $value = $tag->getValue(); $next = $collection->getNext(); $whitespaceToken = null; if ($next->getType() === T_WHITESPACE) { $value = $value . $next->getValue(); $whitespaceToken = $next; } $num = count(explode("\n", $value)); if ($num !== 3) { $data[] = new LineTokenData($num, $tag, $whitespaceToken); } } return $data; }