Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DNumber] Add rawValue attribute to hold the original value (#833)
- Loading branch information
1 parent
d3eb10a
commit 3bf0082
Showing
7 changed files
with
47 additions
and
7 deletions.
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
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
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,27 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace PhpParser\Node\Scalar; | ||
|
||
use PhpParser\Node\Stmt\Echo_; | ||
use PhpParser\ParserFactory; | ||
|
||
class DNumberTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
public function testRawValue() | ||
{ | ||
$parser = (new ParserFactory())->create(ParserFactory::PREFER_PHP7); | ||
$nodes = $parser->parse('<?php echo 1_234.56;'); | ||
|
||
$echo = $nodes[0]; | ||
$this->assertInstanceOf(Echo_::class, $echo); | ||
|
||
/** @var Echo_ $echo */ | ||
$lLumber = $echo->exprs[0]; | ||
$this->assertInstanceOf(DNumber::class, $lLumber); | ||
|
||
/** @var DNumber $dnumber */ | ||
$this->assertSame(1234.56, $lLumber->value); | ||
$this->assertSame('1_234.56', $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