prettier / prettier/plugin-php
`?->print()` not working
Open
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 1.9k
- Forks
- 139
- PR merge metrics
- No merged PRs in 30d
Description
Prettier 3.0.3
PHP Plugin 0.22.2
Input:
$unit = $unitNode?->print($context);
Output:
Error: test.php: SyntaxError: Parse Error : syntax error, unexpected 'print' (T_PRINT) on line 549
Error: 549 | $unit = $unitNode?->print($context);
Expected behavior:
It seems that print is the culprit. I would expect that I can call a print method the same way any other method with the conditional chaining before. This code seems to work in contrast:
$unit = $unitNode?->test($context);
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the reported parse error with the provided PHP snippet, then compare it with the working ?->test($context) example. Trace how the formatter parses or handles print in a conditional method call; done means the input formats successfully while preserving the print method call.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100