New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DNumber] Add rawValue attribute to hold the original value #833
Conversation
133e020
to
d50a25b
Compare
This PR will help using native node properties, instead of token + attribute hacking: |
b4c647a
to
f030437
Compare
/** | ||
* @param mixed[] $attributes | ||
*/ | ||
public static function fromString(string $str, array $attributes = []): DNumber | ||
{ | ||
$attributes['rawValue'] = $str; | ||
$float = self::parse($str); | ||
|
||
return new DNumber($float, $attributes); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method should mirror the LNumber::fromString()
https://github.com/nikic/PHP-Parser/pull/832/files#diff-dcef01e803010221926e1c1f1d388bd86cd219dc843253abf177cca48fb57ba1
We could add this to grammar itself, but it would require either custom method in AbstractParser
or some grammar coding. That would be both harder to maintain and inconsistent with LNumber
.
f030437
to
153fcb0
Compare
The value is now in Ready for review ✔️ |
👏 |
With this feature, tokens are now finally removed from @rectorphp 🥳 |
Mirror to #832