diff --git a/doc/2_Usage_of_basic_components.markdown b/doc/2_Usage_of_basic_components.markdown index fd01e57..cd0aef5 100644 --- a/doc/2_Usage_of_basic_components.markdown +++ b/doc/2_Usage_of_basic_components.markdown @@ -102,7 +102,7 @@ with them easier they are grouped into three categories: and thus can occur in other expressions. Examples of expressions are `$var` (`PhpParser\Node\Expr\Variable`) and `func()` (`PhpParser\Node\Expr\FuncCall`). * `PhpParser\Node\Scalar`s are nodes representing scalar values, like `'string'` - (`PhpParser\Node\Scalar\String`), `0` (`PhpParser\Node\Scalar\LNumber`) or magic constants + (`PhpParser\Node\Scalar\String_`), `0` (`PhpParser\Node\Scalar\LNumber`) or magic constants like `__FILE__` (`PhpParser\Node\Scalar\MagicConst\File`). All `PhpParser\Node\Scalar`s extend `PhpParser\Node\Expr`, as scalars are expressions, too. * There are some nodes not in either of these groups, for example names (`PhpParser\Node\Name`) @@ -224,7 +224,7 @@ use PhpParser\Node; class MyNodeVisitor extends PhpParser\NodeVisitorAbstract { public function leaveNode(Node $node) { - if ($node instanceof Node\Scalar\String) { + if ($node instanceof Node\Scalar\String_) { $node->value = 'foo'; } } diff --git a/grammar/rebuildParser.php b/grammar/rebuildParser.php index b76da59..96f9fea 100644 --- a/grammar/rebuildParser.php +++ b/grammar/rebuildParser.php @@ -139,13 +139,13 @@ function resolveMacros($code) { if ('parseEncapsed' == $name) { assertArgs(2, $args, $name); - return 'foreach (' . $args[0] . ' as &$s) { if (is_string($s)) { $s = Node\Scalar\String::parseEscapeSequences($s, ' . $args[1] . '); } }'; + return 'foreach (' . $args[0] . ' as &$s) { if (is_string($s)) { $s = Node\Scalar\String_::parseEscapeSequences($s, ' . $args[1] . '); } }'; } if ('parseEncapsedDoc' == $name) { assertArgs(1, $args, $name); - return 'foreach (' . $args[0] . ' as &$s) { if (is_string($s)) { $s = Node\Scalar\String::parseEscapeSequences($s, null); } } $s = preg_replace(\'~(\r\n|\n|\r)$~\', \'\', $s); if (\'\' === $s) array_pop(' . $args[0] . ');'; + return 'foreach (' . $args[0] . ' as &$s) { if (is_string($s)) { $s = Node\Scalar\String_::parseEscapeSequences($s, null); } } $s = preg_replace(\'~(\r\n|\n|\r)$~\', \'\', $s); if (\'\' === $s) array_pop(' . $args[0] . ');'; } throw new Exception(sprintf('Unknown macro "%s"', $name)); diff --git a/lib/PhpParser/Parser.php b/lib/PhpParser/Parser.php index 5ab9a47..a3c9db9 100644 --- a/lib/PhpParser/Parser.php +++ b/lib/PhpParser/Parser.php @@ -2289,7 +2289,7 @@ class Parser extends ParserAbstract } protected function reduceRule315($attributes) { - foreach ($this->semStack[$this->stackPos-(1-1)] as &$s) { if (is_string($s)) { $s = Node\Scalar\String::parseEscapeSequences($s, '`'); } }; $this->semValue = $this->semStack[$this->stackPos-(1-1)]; + foreach ($this->semStack[$this->stackPos-(1-1)] as &$s) { if (is_string($s)) { $s = Node\Scalar\String_::parseEscapeSequences($s, '`'); } }; $this->semValue = $this->semStack[$this->stackPos-(1-1)]; } protected function reduceRule316($attributes) { @@ -2525,11 +2525,11 @@ class Parser extends ParserAbstract } protected function reduceRule374($attributes) { - foreach ($this->semStack[$this->stackPos-(3-2)] as &$s) { if (is_string($s)) { $s = Node\Scalar\String::parseEscapeSequences($s, '"'); } }; $this->semValue = new Node\Scalar\Encapsed($this->semStack[$this->stackPos-(3-2)], $attributes); + foreach ($this->semStack[$this->stackPos-(3-2)] as &$s) { if (is_string($s)) { $s = Node\Scalar\String_::parseEscapeSequences($s, '"'); } }; $this->semValue = new Node\Scalar\Encapsed($this->semStack[$this->stackPos-(3-2)], $attributes); } protected function reduceRule375($attributes) { - foreach ($this->semStack[$this->stackPos-(3-2)] as &$s) { if (is_string($s)) { $s = Node\Scalar\String::parseEscapeSequences($s, null); } } $s = preg_replace('~(\r\n|\n|\r)$~', '', $s); if ('' === $s) array_pop($this->semStack[$this->stackPos-(3-2)]);; $this->semValue = new Node\Scalar\Encapsed($this->semStack[$this->stackPos-(3-2)], $attributes); + foreach ($this->semStack[$this->stackPos-(3-2)] as &$s) { if (is_string($s)) { $s = Node\Scalar\String_::parseEscapeSequences($s, null); } } $s = preg_replace('~(\r\n|\n|\r)$~', '', $s); if ('' === $s) array_pop($this->semStack[$this->stackPos-(3-2)]);; $this->semValue = new Node\Scalar\Encapsed($this->semStack[$this->stackPos-(3-2)], $attributes); } protected function reduceRule376($attributes) {