Php-parser: Add to string node `raw` contain raw value with escaped special characters

Created on 19 Feb 2018  路  9Comments  路  Source: glayzzle/php-parser

Example we have $a= "foo\nbar":
value = foo\nbar;
raw = "foo\\nbar"

All popular parser do this https://astexplorer.net/#/gist/070b3c0b39f0af268d909e3ba9efa2a3/2ba4c9d3ab6b3e3cf31f6148a28966c638948790

Ref: https://github.com/prettier/plugin-php/pull/57

Thanks!

enhancement AST

Most helpful comment

I vote for raw - more concise

All 9 comments

Hi @evilebottnawi,

I agree with you as you can loos information without the raw attribute :

image

@ichiriac need help?

yes, any help would be verry appreciated

@ichiriac raw or rawValue property?

I vote for raw - more concise

@ichiriac can you help with this? we have a lot of work in prettier, it is problem have maximum priority

Also strange:

a = 'You deleted C:\\*.*?';

Contain: You deleted C:\*.*?

Not sure yet on single quotes, but \ is for escaping, so \\ resolves as a single \ - have a try on php cli but i'm almost sure it's correct

this feature is now implemented over literals nodes including :

  • Boolean
  • String
  • Number (attribute ignored for the moment as it's always the same - needs investigation)
  • Inline
  • Magic (value is allways uppercase)
  • Nowdoc
  • Encapsed

I need to better cover them with tests, I'll do it later

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alexander-akait picture alexander-akait  路  8Comments

alexander-akait picture alexander-akait  路  8Comments

chris-l picture chris-l  路  7Comments

alexander-akait picture alexander-akait  路  9Comments

alexander-akait picture alexander-akait  路  7Comments