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

False syntax error on PHP 8.4 hooks #342

Open
allanmcarvalho opened this issue Feb 7, 2025 · 1 comment
Open

False syntax error on PHP 8.4 hooks #342

allanmcarvalho opened this issue Feb 7, 2025 · 1 comment
Labels
dependencies Pull requests that update a dependency file

Comments

@allanmcarvalho
Copy link

allanmcarvalho commented Feb 7, 2025

Pint Version

1.20

PHP Version

8.4.3

Description

Laravel Pint throws a false syntax error when in fact code works.

Steps To Reproduce

PHP Hooks error.

This is a valid php code, but fail on Pint

class Example {

    public ?int $intBoolean {
        get => $this->booleanValue === null ? null : (int) $this->booleanValue;
    }

    public function __construct(
        public ?boolean $booleanValue
    ) {}
}
   FAIL   ............................................................................................................................................. 217 files, 1 error  
  ! Example.php.                                                                                          Parse error: syntax error, unexpected token "public" on line 24.  
      1▕  class Example {
      2▕ 
      3▕     public ?int $intBoolean {
  ➜   4▕         get => $this->booleanValue === null ? null : (int) $this->booleanValue;
      5▕     }
      6▕ 
      7▕     public function __construct(
      8▕         public ?boolean $booleanValue

This is a valid code too, but pass.

class Example {

    public ?int $intBoolean {
        get => ($this->booleanValue === null ? null : (int) $this->booleanValue);
    }

    public function __construct(
        public ?boolean $booleanValue
    ) {}
}
@crynobone
Copy link
Member

Pending https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/milestone/173

@crynobone crynobone added the dependencies Pull requests that update a dependency file label Feb 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file
Projects
None yet
Development

No branches or pull requests

2 participants