prettier / prettier/plugin-php
Bug: Prettier incorrectly adds parentheses when using new with a static property
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 1.9k
- Forks
- 139
- PR merge metrics
- No merged PRs in 30d
Description
Description:
When formatting code with Prettier in PHP 8.4, parentheses are incorrectly added to a static property when instantiating an object. This causes a syntax error and breaks the application.
Example:
Before Prettier:
$identifier = new Yii::$app->class([]);
After Prettier:
$identifier = new Yii::$app()->class([]);
Expected behavior:
Prettier should leave the code as-is without adding parentheses when using new on a static property.
Actual behavior:
Prettier adds () to the static property, resulting in invalid syntax.
Impact:
Code breaks when executed, causing runtime errors in applications using this pattern.
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
Start by reproducing the PHP 8.4 example from the issue with Prettier, comparing the code before and after formatting. Done means the static property in the new Yii::$app->class([]) pattern remains without added parentheses and the resulting PHP stays valid.
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
- 45/100