1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-11-26 20:04:48 +01:00

Replace another Scalar\String occurance

Also canonicalize NameResover tests to avoid those pesky CRLF
issues.
This commit is contained in:
Nikita Popov 2015-03-21 18:47:20 +01:00
parent 1a627872f0
commit 7ec277e1e1
3 changed files with 14 additions and 4 deletions

View File

@ -747,7 +747,7 @@ ctor_arguments:
common_scalar:
T_LNUMBER { $$ = Scalar\LNumber[Scalar\LNumber::parse($1)]; }
| T_DNUMBER { $$ = Scalar\DNumber[Scalar\DNumber::parse($1)]; }
| T_CONSTANT_ENCAPSED_STRING { $$ = Scalar\String[Scalar\String_::parse($1)]; }
| T_CONSTANT_ENCAPSED_STRING { $$ = Scalar\String_[Scalar\String_::parse($1)]; }
| T_LINE { $$ = Scalar\MagicConst\Line[]; }
| T_FILE { $$ = Scalar\MagicConst\File[]; }
| T_DIR { $$ = Scalar\MagicConst\Dir[]; }

View File

@ -2309,7 +2309,7 @@ class Parser extends ParserAbstract
}
protected function reduceRule320($attributes) {
$this->semValue = new Node\Scalar\String(Node\Scalar\String_::parse($this->semStack[$this->stackPos-(1-1)]), $attributes);
$this->semValue = new Node\Scalar\String_(Node\Scalar\String_::parse($this->semStack[$this->stackPos-(1-1)]), $attributes);
}
protected function reduceRule321($attributes) {

View File

@ -10,6 +10,10 @@ use PhpParser\Node\Expr;
class NameResolverTest extends \PHPUnit_Framework_TestCase
{
private function canonicalize($string) {
return str_replace("\r\n", "\n", $string);
}
/**
* @covers PhpParser\NodeVisitor\NameResolver
*/
@ -133,7 +137,10 @@ EOC;
$stmts = $parser->parse($code);
$stmts = $traverser->traverse($stmts);
$this->assertSame($expectedCode, $prettyPrinter->prettyPrint($stmts));
$this->assertSame(
$this->canonicalize($expectedCode),
$prettyPrinter->prettyPrint($stmts)
);
}
/**
@ -220,7 +227,10 @@ EOC;
$stmts = $parser->parse($code);
$stmts = $traverser->traverse($stmts);
$this->assertSame($expectedCode, $prettyPrinter->prettyPrint($stmts));
$this->assertSame(
$this->canonicalize($expectedCode),
$prettyPrinter->prettyPrint($stmts)
);
}
public function testNoResolveSpecialName() {