Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Braces bug since 1.19.0 #352

Open
Seb33300 opened this issue Feb 27, 2025 · 3 comments
Open

Braces bug since 1.19.0 #352

Seb33300 opened this issue Feb 27, 2025 · 3 comments

Comments

@Seb33300
Copy link

Seb33300 commented Feb 27, 2025

Pint Version

1.19.0+

PHP Version

8.4

Description

Starting version 1.19.0 of Laravel Pint, I am facing a very strange bug where Laravel Pint detects false positive issue with braces.

I cannot reproduce the issue on version 1.18.3.

Steps To Reproduce

This issue occurs only with PHP 8.4. Not on PHP 8.3

The minimum reproducer I found:

<?php

if (false) {
    set();
}

Result:

Image

For some reason, the issue seems to be caused by set();.
If I replace set(); by se(); of sett();, pint pass successfully.

@Seb33300
Copy link
Author

Just created that PR to reproduce the issue: #353

@Seb33300
Copy link
Author

I suspect nikic/php-parser to be the root cause of that issue.
It was upgraded to 5.4.0 in Pint 1.19.0: 2128bf5

And in the changelog I can find something related to set:
https://github.com/nikic/PHP-Parser/releases/tag/v5.4.0

PropertyHook::getStmts() now correctly desugars short set hooks. set => $value will be expanded to set { $this->propertyName = $value; }. This requires the propertyName attribute on the hook to be set, which is now also set by the parser. If the attribute is not set, getStmts() will throw an error for short set hooks, as it is not possible to produce a correct desugaring.

@Seb33300
Copy link
Author

Seb33300 commented Mar 4, 2025

The issue may come from one of those package upgraded between Laravel Pint 1.18.3 and 1.19.0:

"name": "larastan/larastan",
"version": "v2.9.11",
"version": "v2.9.12",

"name": "phpstan/phpstan",
"version": "1.12.11",
"version": "1.12.13",

"name": "nikic/php-parser",
"version": "v5.3.1",
"version": "v5.4.0",

"name": "friendsofphp/php-cs-fixer",
"version": "v3.65.0",
"version": "v3.66.0",

Maintainer of nikic/php-parser said his changes are unrelated: nikic/PHP-Parser#1072

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant