Mercurial > hg > cmmr2012-drupal-site
comparison vendor/psy/psysh/src/Command/TimeitCommand/TimeitVisitor.php @ 4:a9cd425dd02b
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:11:55 +0000 |
parents | c75dbcec494b |
children |
comparison
equal
deleted
inserted
replaced
3:307d7a7fd348 | 4:a9cd425dd02b |
---|---|
73 * {@inheritdoc} | 73 * {@inheritdoc} |
74 */ | 74 */ |
75 public function afterTraverse(array $nodes) | 75 public function afterTraverse(array $nodes) |
76 { | 76 { |
77 // prepend a `markStart` call | 77 // prepend a `markStart` call |
78 array_unshift($nodes, $this->maybeExpression($this->getStartCall())); | 78 \array_unshift($nodes, $this->maybeExpression($this->getStartCall())); |
79 | 79 |
80 // append a `markEnd` call (wrapping the final node, if it's an expression) | 80 // append a `markEnd` call (wrapping the final node, if it's an expression) |
81 $last = $nodes[count($nodes) - 1]; | 81 $last = $nodes[\count($nodes) - 1]; |
82 if ($last instanceof Expr) { | 82 if ($last instanceof Expr) { |
83 array_pop($nodes); | 83 \array_pop($nodes); |
84 $nodes[] = $this->getEndCall($last); | 84 $nodes[] = $this->getEndCall($last); |
85 } elseif ($last instanceof Expression) { | 85 } elseif ($last instanceof Expression) { |
86 array_pop($nodes); | 86 \array_pop($nodes); |
87 $nodes[] = new Expression($this->getEndCall($last->expr), $last->getAttributes()); | 87 $nodes[] = new Expression($this->getEndCall($last->expr), $last->getAttributes()); |
88 } elseif ($last instanceof Return_) { | 88 } elseif ($last instanceof Return_) { |
89 // nothing to do here, we're already ending with a return call | 89 // nothing to do here, we're already ending with a return call |
90 } else { | 90 } else { |
91 $nodes[] = $this->maybeExpression($this->getEndCall()); | 91 $nodes[] = $this->maybeExpression($this->getEndCall()); |
132 * | 132 * |
133 * @return PhpParser\Node\Expr|PhpParser\Node\Stmt\Expression | 133 * @return PhpParser\Node\Expr|PhpParser\Node\Stmt\Expression |
134 */ | 134 */ |
135 private function maybeExpression($expr, $attrs = []) | 135 private function maybeExpression($expr, $attrs = []) |
136 { | 136 { |
137 return class_exists('PhpParser\Node\Stmt\Expression') ? new Expression($expr, $attrs) : $expr; | 137 return \class_exists('PhpParser\Node\Stmt\Expression') ? new Expression($expr, $attrs) : $expr; |
138 } | 138 } |
139 } | 139 } |