chris-l / php-unparser

A JavaScript based code generator, to unparse glayzzle/php-parser compatible AST back to code.
https://chris-l.github.io/php-unparser/
33 stars 12 forks source link

Compatability with php-parser 3.0 #17

Open nekosaur opened 6 years ago

nekosaur commented 6 years ago

It looks like there are some breaking changes in the coming php-parser 3.0 that results in php-unparser being unable to use its output to unparse. Specifically I had problems with simple string arrays.

<?

return [
  "xzczxc",
  "qweqweqwe"
];
Node: xzczxc
Node kind: undefined
{ Error: Bad AST structure
    at CodeGen.process (/home/vagrant/apps/translation-scripts/node_modules/php-unparser/node_translators/index.js:42:13)
    at /home/vagrant/apps/translation-scripts/node_modules/php-unparser/node_translators/array.js:11:19
    at Array.map (<anonymous>)
    at CodeGen.module.exports [as array] (/home/vagrant/apps/translation-scripts/node_modules/php-unparser/node_translators/array.js:19:25)
    at CodeGen.process (/home/vagrant/apps/translation-scripts/node_modules/php-unparser/node_translators/index.js:32:31)
    at /home/vagrant/apps/translation-scripts/node_modules/php-unparser/node_translators/array.js:11:19
    at Array.map (<anonymous>)
    at CodeGen.module.exports [as array] (/home/vagrant/apps/translation-scripts/node_modules/php-unparser/node_translators/array.js:19:25)
    at CodeGen.process (/home/vagrant/apps/translation-scripts/node_modules/php-unparser/node_translators/index.js:32:31)
    at CodeGen.module.exports [as return] (/home/vagrant/apps/translation-scripts/node_modules/php-unparser/node_translators/return.js:12:22) node: 'xzczxc' }
chris-l commented 6 years ago

Well, yes. I haven't seen the new parser yet, but for what @ichiriac said on his issues, it seemed like the changes he was planning to do would completely break the unparser on its current state.

ichiriac commented 6 years ago

Hi, yes actually v3 will not be backward compatible, but changes should be enough simple to implement. Remains some changes to implement before the v3 will be fully released and then I'll write a migration guide and send a PR on this project.