Changeset View
Changeset View
Standalone View
Standalone View
src/parser/aast/api/AASTNode.php
| Show First 20 Lines • Show All 248 Lines • ▼ Show 20 Lines | foreach ($tokens as $id => $token) { | ||||
| unset($tokens[$id]); | unset($tokens[$id]); | ||||
| } | } | ||||
| } | } | ||||
| return implode('', mpull($tokens, 'getValue')); | return implode('', mpull($tokens, 'getValue')); | ||||
| } | } | ||||
| public function getIndentation() { | public function getIndentation() { | ||||
| $tokens = $this->getTokens(); | $tokens = $this->getTokens(); | ||||
| $left = head($tokens); | $head = head($tokens); | ||||
| $left = $head; | |||||
| while ($left && | while ($left && strpos($left->getValue(), "\n") === false) { | ||||
joshuaspence: Prefer to use `!$left->isSemantic()` | |||||
| (!$left->isAnyWhitespace() || | |||||
| strpos($left->getValue(), "\n") === false)) { | |||||
| $left = $left->getPrevToken(); | $left = $left->getPrevToken(); | ||||
| } | } | ||||
| if (!$left) { | if (!$left) { | ||||
| return null; | return null; | ||||
| } | } | ||||
| return preg_replace("/^.*\n/s", '', $left->getValue()); | $next = $left; | ||||
| while ($next->getTokenID() != $head->getTokenID() && | |||||
| !$next->isAnyWhitespace()) { | |||||
| $next = $next->getNextToken(); | |||||
| } | |||||
| if ($next->getTokenID() == $head->getTokenID()) { | |||||
| return null; | |||||
| } | |||||
| return str_replace("\n", '', $next->getValue()); | |||||
| } | } | ||||
| public function getDescription() { | public function getDescription() { | ||||
| $concrete = $this->getConcreteString(); | $concrete = $this->getConcreteString(); | ||||
| if (strlen($concrete) > 75) { | if (strlen($concrete) > 75) { | ||||
| $concrete = substr($concrete, 0, 36).'...'.substr($concrete, -36); | $concrete = substr($concrete, 0, 36).'...'.substr($concrete, -36); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 62 Lines • Show Last 20 Lines | |||||
Prefer to use !$left->isSemantic()