phpmd
phpmd copied to clipboard
Unexpected token when using more varaibles in <?= ?> php echo statement
- PHPMD version: 2.12.0
- PHP Version: 8.0, 8.1
- Installation type: composer, in docker image
- Operating System / Distribution & Version: Alpine, ubuntu 20.04
Current Behavior
Unexpected token: ,, line: 6, col: 10, file:: /test.php
Expected Behavior
Analysis should work
Steps To Reproduce:
- Install PHPMD
composer require --dev phpmd/phpmd - create
test.phpfile with code example below - run
php vendor/bin/phpmd test.php ansi naming
Example code
<?php
$var1 = 'foo';
$var2 = 'bar';
?>
<?= $var1,$var2 ?>
Checks before submitting
- [x] Be sure that there isn't already an issue about this. See: Issues list
- [x] Be sure that there isn't already a pull request about this. See: Pull requests
- [x] I have added every step to reproduce the bug.
- [x] If possible I added relevant code examples.
- [x] This issue is about 1 bug and nothing more.
- [x] The issue has a descriptive title. For example: "JSON rendering failed on Windows for filenames with space".
Bug confirmed, meanwhile you can use:
<?php echo $var1,$var2; ?>
Or:
<?= $var1.$var2 ?>
I'm working on a fix, you can try composer require pdepend/pdepend:dev-fix/short-tags-multiple-variables (if you use PHPMD from composer) to preview it and support comas in <?= ?> tags.