-
Notifications
You must be signed in to change notification settings - Fork 43
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
php include_once space inserted in associative array key value #42
Comments
this line has unmatched single quote, maybe js-beautify can't parse correctly. I have no idea. |
Sorry I don't see the unmatched single quote here onclick='changeDepartment("<?php echo $DeptID; ?>","<?php echo str_replace("' ", "\\ ", $DeptName); ?> ", "<?php echo $DeptShortName; ?>", 1, "<?php echo $DeptState ?>"); ' This is not really unmatched because when the php is rendered it would be removed. But I can confirm that this single quote the cause of the issue. Example that does not produce the problem.
My concern is that |
single quote in this parts :
because this extension do html format first, and then run php-cs-fixer. so js-beautify can't format the code correctly. you can test your code here: http://jsbeautifier.org/
|
Ok, that makes it clear. The issue is that the code we send to js-beautify needs to have php stripped out so that the formatting pass doesn't include code that is valid in php but not valid for js-beautify. Maybe it would be possible for this plugin to strip out code between php tags, then send to js-beautfiy, then reinsert the embedded php. I did a bit of research and it looks like And it looks like there was an attempt to treat php tags as strings, but I guess it doesn't work in this case. |
And also something you should track is the newly announced prettier plugin ecosystem, specifically https://github.com/prettier/plugin-php. Although they are currently very early on, maybe it would be viable to switch to using prettier since js-beautify seems to be untenable for html / js beautification of php. Currently prettier html support is not implemented, see prettier/prettier#1882 for progress on that. |
When fixing the following example, an extra space is inserted in the key
$_SERVER['DOCUMENT_ROOT']
so that it becomes$_SERVER['DOCUMENT_ROOT ']
Example:
Output:
The text was updated successfully, but these errors were encountered: