Skip to content

Add support for PHP 8.4 private(set) visibility modifier #368

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

Open
HGtronic opened this issue Apr 18, 2025 · 1 comment
Open

Add support for PHP 8.4 private(set) visibility modifier #368

HGtronic opened this issue Apr 18, 2025 · 1 comment

Comments

@HGtronic
Copy link

Pint Version

1.22

PHP Version

8.4

Description

The package currently fails to parse code that uses the new private(set) visibility modifier introduced in PHP 8.4. This results in the following error
Parse error: syntax error, unexpected token "private(set)" on line 10

Steps To Reproduce

Use the following code snippet in a project:

final readonly class AddressDTO
{
    public function __construct(
        private(set) ?string $country = null,
        private(set) ?string $state = null,
        private(set) ?string $street = null,
        private(set) ?string $number = null,
        private(set) ?string $zip = null
    ) {}
}

Run pint on the file.

@braxey
Copy link

braxey commented Apr 18, 2025

I just ran into a related issue. Pint doesn't support assymetric visibility.

<?php

namespace App\Dtos;

use App\Constants\PostFilter;
use App\Constants\PostOrder;
use Illuminate\Http\Request;

class GetPostsDto
{
    public private(set) string $searchTerm;
    public private(set) string $order;
    public private(set) string $filter;
    public private(set) int $pageNumber;

    public function __construct(Request $request)
    {
        $this->searchTerm = (string) $request->input('search');
        $this->order = (string) $request->input('order', PostOrder::RECENT);
        $this->filter = (string) $request->input('filter', PostFilter::PUBLISHED);
        $this->pageNumber = (int) $request->input('page', 1);
    }
}

Pint fails this file with Fatal error: Multiple access type modifiers are not allowed on line 13.

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

2 participants