May not be a bug depending on what versions of PHP you intend to support. I just learned about this and ran it on my code base. We use PHP 7.1 and I got errors related to PHP's new array destructuring (see a couple sections down here: http://php.net/manual/en/migration71.new-features.php).
Input:
<?php
[ $a, $b ] = [ 1, 2 ];
?>
Output:
[error] test.php: SyntaxError: Parse Error : syntax error, unexpected '=', expecting ';' on line 2
[error] at parser.raiseError (/var/www/prettier/plugin-php/node_modules/php-parser/src/parser.js:261:15)
[error] at parser.error (/var/www/prettier/plugin-php/node_modules/php-parser/src/parser.js:301:15)
[error] at parser.expectEndOfStatement (/var/www/prettier/plugin-php/node_modules/php-parser/src/parser.js:330:10)
[error] at parser.read_statement (/var/www/prettier/plugin-php/node_modules/php-parser/src/parser/statement.js:348:14)
[error] at parser.read_top_statement (/var/www/prettier/plugin-php/node_modules/php-parser/src/parser/statement.js:74:21)
[error] at parser.read_start (/var/www/prettier/plugin-php/node_modules/php-parser/src/parser/main.js:17:19)
[error] at parser.parse (/var/www/prettier/plugin-php/node_modules/php-parser/src/parser.js:243:21)
[error] at engine.parseCode (/var/www/prettier/plugin-php/node_modules/php-parser/src/index.js:168:22)
[error] at Object.parse (/var/www/prettier/plugin-php/src/parser.js:16:17)
[error] at Object.parse (/var/www/prettier/plugin-php/node_modules/prettier/src/main/parser.js:75:19)
[error] at formatWithCursor (/var/www/prettier/plugin-php/node_modules/prettier/index.js:101:25)
[error] at Object.formatWithCursor (/var/www/prettier/plugin-php/node_modules/prettier/index.js:402:12)
[error] at format (/var/www/prettier/plugin-php/node_modules/prettier/src/cli/util.js:157:19)
[error] at eachFilename (/var/www/prettier/plugin-php/node_modules/prettier/src/cli/util.js:380:16)
[error] at filePaths.forEach.filePath (/var/www/prettier/plugin-php/node_modules/prettier/src/cli/util.js:322:7)
[error] at Array.forEach (<anonymous>)
error An unexpected error occurred: "Command failed.
Exit code: 2
Thanks! Let me know if there is anything I can do to help!
May not be a bug depending on what versions of PHP you intend to support. I just learned about this and ran it on my code base. We use PHP 7.1 and I got errors related to PHP's new array destructuring (see a couple sections down here: http://php.net/manual/en/migration71.new-features.php).
Input:
Output:
Thanks! Let me know if there is anything I can do to help!