forked from nikic/PHP-Parser
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[LNumber] Add rawValue attribute to LNumber to allow numeric separato…
…r etc. (nikic#832)
- Loading branch information
1 parent
a6e3466
commit d3eb10a
Showing
3 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace PhpParser\Node\Scalar; | ||
|
||
use PhpParser\Node\Stmt\Echo_; | ||
use PhpParser\ParserFactory; | ||
|
||
class NumberTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
public function testRawValue() | ||
{ | ||
$parser = (new ParserFactory())->create(ParserFactory::PREFER_PHP7); | ||
$nodes = $parser->parse('<?php echo 1_234;'); | ||
|
||
$echo = $nodes[0]; | ||
$this->assertInstanceOf(Echo_::class, $echo); | ||
|
||
/** @var Echo_ $echo */ | ||
$lLumber = $echo->exprs[0]; | ||
$this->assertInstanceOf(LNumber::class, $lLumber); | ||
|
||
/** @var LNumber $lnumber */ | ||
$this->assertSame(1234, $lLumber->value); | ||
$this->assertSame('1_234', $lLumber->getAttribute('rawValue')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters