-
-
Notifications
You must be signed in to change notification settings - Fork 154
Support PHP 8.4 Asymmetric Property visibility #2926
Copy link
Copy link
Closed
Labels
Description
phpactor version: master@a0bd607423e09f7c6bea63e2b97127dd71f28e9b
Asymmetric properties don't parse and also cause issues with the parsing of other parts of the file like methods.
The below is a screenshot of the amended excerpt from the php manual. https://www.php.net/manual/en/language.oop5.visibility.php#language.oop5.visibility-members-aviz
<?php
class Book
{
public function __construct(
public private(set) string $title,
public protected(set) string $author,
protected private(set) int $pubYear,
) {}
public function methodThatNowWontParse(): void
{}
}
class SpecialBook extends Book
{
public function update(string $author, int $year): void
{
$this->author = $author; // OK
$this->pubYear = $year; // Fatal Error
}
}
$b = new Book('How to PHP', 'Peter H. Peterson', 2024);
$b->methodThatNowWontParse();
echo $b->title; // Works
echo $b->author; // Works
echo $b->pubYear; // Fatal Error
$b->title = 'How not to PHP'; // Fatal Error
$b->author = 'Pedro H. Peterson'; // Fatal Error
$b->pubYear = 2023; // Fatal Error
The feature of asymmetric rules is less important than the bug of the syntax affecting other parsing.
Thanks
Reactions are currently unavailable