-
Notifications
You must be signed in to change notification settings - Fork 865
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PHP 8.4 Support: Asymmetric Visibility v2 (Part 3)
- #8035 - https://wiki.php.net/rfc#php_84 - https://wiki.php.net/rfc/asymmetric-visibility-v2 - Fix hints - `IncorrectConstructorPropertyPromotionHintError` - `UnusedVariableHint` - Add/Fix unit tests
- Loading branch information
Showing
11 changed files
with
303 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 20 additions & 5 deletions
25
...uctorPropertyPromotionHintError/testAbstractConstructor.php.testAbstractConstructor.hints
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,30 @@ | ||
abstract public function __construct(private ?int $incorrect1 = 1); | ||
abstract public function __construct(private ?int $incorrect1 = 1); // error1 | ||
---------------------------- | ||
HINT:Can't declare a promoted property in an abstract constructor. | ||
private $incorrect1, | ||
private $incorrect1, // error2 | ||
------------------- | ||
HINT:Can't declare a promoted property in an abstract constructor. | ||
private ?int $incorrect2 = 1 | ||
private ?int $incorrect2 = 1 // error3 | ||
---------------------------- | ||
HINT:Can't declare a promoted property in an abstract constructor. | ||
public function __construct(public int|string $incorrect1); | ||
public function __construct(public int|string $incorrect1); // error4 | ||
----------------------------- | ||
HINT:Can't declare a promoted property in an abstract constructor. | ||
public function __construct(int $test, protected $incorrect1); | ||
public function __construct(int $test, protected $incorrect1); // error5 | ||
--------------------- | ||
HINT:Can't declare a promoted property in an abstract constructor. | ||
abstract public function __construct(private(set) ?int $incorrect1 = 1); // error6 | ||
--------------------------------- | ||
HINT:Can't declare a promoted property in an abstract constructor. | ||
private(set) $incorrect1, // error7 | ||
------------------------ | ||
HINT:Can't declare a promoted property in an abstract constructor. | ||
private(set) ?int $incorrect2 = 1 // error8 | ||
--------------------------------- | ||
HINT:Can't declare a promoted property in an abstract constructor. | ||
public function __construct(public(set) int|string $incorrect1); // error9 | ||
---------------------------------- | ||
HINT:Can't declare a promoted property in an abstract constructor. | ||
public function __construct(int $test, protected(set) $incorrect1); // error10 | ||
-------------------------- | ||
HINT:Can't declare a promoted property in an abstract constructor. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 60 additions & 15 deletions
75
...torPropertyPromotionHintError/testOtherThanConstructor.php.testOtherThanConstructor.hints
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,90 @@ | ||
public function test1(private $incorrect1): void { | ||
public function test1(private $incorrect1): void { // error1 | ||
------------------- | ||
HINT:Can't declare a promoted property in a function/method other than a constructor. | ||
public static function test2(int $param1, public int $incorrect) { | ||
public static function test2(int $param1, public int $incorrect) { // error2 | ||
--------------------- | ||
HINT:Can't declare a promoted property in a function/method other than a constructor. | ||
abstract public function test1(private ?int $incorrect = 1); | ||
abstract public function test1(private ?int $incorrect = 1); // error3 | ||
--------------------------- | ||
HINT:Can't declare a promoted property in a function/method other than a constructor. | ||
public $incorrect1, | ||
public $incorrect1, // error4 | ||
------------------ | ||
HINT:Can't declare a promoted property in a function/method other than a constructor. | ||
private ?int $incorrect2 = 1 | ||
private ?int $incorrect2 = 1 // error5 | ||
---------------------------- | ||
HINT:Can't declare a promoted property in a function/method other than a constructor. | ||
public function test(public int|string $incorrect1): void; | ||
public function test(public int|string $incorrect1): void; // error6 | ||
----------------------------- | ||
HINT:Can't declare a promoted property in a function/method other than a constructor. | ||
public int|string $incorrect1, | ||
public int|string $incorrect1, // error7 | ||
----------------------------- | ||
HINT:Can't declare a promoted property in a function/method other than a constructor. | ||
protected $incorrect2 = "", | ||
protected $incorrect2 = "", // error8 | ||
-------------------------- | ||
HINT:Can't declare a promoted property in a function/method other than a constructor. | ||
$lambda1 = function (private $incorrect1) {}; | ||
$lambda1 = function (private $incorrect1) {}; // error9 | ||
------------------- | ||
HINT:Can't declare a promoted property in a function/method other than a constructor. | ||
private $incorrect1, | ||
private $incorrect1, // error10 | ||
------------------- | ||
HINT:Can't declare a promoted property in a function/method other than a constructor. | ||
protected int $incorrect2 = 1, | ||
protected int $incorrect2 = 1, // error11 | ||
----------------------------- | ||
HINT:Can't declare a promoted property in a function/method other than a constructor. | ||
$lambda3 = static function (public ?string $incorrect1 = "test"){}; | ||
$lambda3 = static function (public ?string $incorrect1 = "test"){}; // error12 | ||
----------------------------------- | ||
HINT:Can't declare a promoted property in a function/method other than a constructor. | ||
$arrow1 = fn(int $test, private ?int $incorrect1,): int => 1; | ||
$arrow1 = fn(int $test, private ?int $incorrect1,): int => 1; // error13 | ||
------------------------ | ||
HINT:Can't declare a promoted property in a function/method other than a constructor. | ||
private ?int $incorrect1, | ||
private ?int $incorrect1, // error14 | ||
------------------------ | ||
HINT:Can't declare a promoted property in a function/method other than a constructor. | ||
private string|int $incorrect2 | ||
private string|int $incorrect2 // error15 | ||
------------------------------ | ||
HINT:Can't declare a promoted property in a function/method other than a constructor. | ||
public function test1(private(set) $incorrect1): void { // error16 | ||
------------------------ | ||
HINT:Can't declare a promoted property in a function/method other than a constructor. | ||
public static function test2(int $param1, public(set) int $incorrect) { // error17 | ||
-------------------------- | ||
HINT:Can't declare a promoted property in a function/method other than a constructor. | ||
abstract public function test1(private(set) ?int $incorrect = 1); // error18 | ||
-------------------------------- | ||
HINT:Can't declare a promoted property in a function/method other than a constructor. | ||
public(set) $incorrect1, // error19 | ||
----------------------- | ||
HINT:Can't declare a promoted property in a function/method other than a constructor. | ||
private(set) ?int $incorrect2 = 1 // error20 | ||
--------------------------------- | ||
HINT:Can't declare a promoted property in a function/method other than a constructor. | ||
public function test(public(set) int|string $incorrect1): void; // error21 | ||
---------------------------------- | ||
HINT:Can't declare a promoted property in a function/method other than a constructor. | ||
public(set) int|string $incorrect1, // error22 | ||
---------------------------------- | ||
HINT:Can't declare a promoted property in a function/method other than a constructor. | ||
protected(set) $incorrect2 = "", // error23 | ||
------------------------------- | ||
HINT:Can't declare a promoted property in a function/method other than a constructor. | ||
$lambda1 = function (private(set) $incorrect1) {}; // error24 | ||
------------------------ | ||
HINT:Can't declare a promoted property in a function/method other than a constructor. | ||
private(set) $incorrect1, // error25 | ||
------------------------ | ||
HINT:Can't declare a promoted property in a function/method other than a constructor. | ||
protected(set) int $incorrect2 = 1, // error26 | ||
---------------------------------- | ||
HINT:Can't declare a promoted property in a function/method other than a constructor. | ||
$lambda3 = static function (public(set) ?string $incorrect1 = "test"){}; // error27 | ||
---------------------------------------- | ||
HINT:Can't declare a promoted property in a function/method other than a constructor. | ||
$arrow1 = fn(int $test, private(set) ?int $incorrect1,): int => 1; // error28 | ||
----------------------------- | ||
HINT:Can't declare a promoted property in a function/method other than a constructor. | ||
private(set) ?int $incorrect1, // error29 | ||
----------------------------- | ||
HINT:Can't declare a promoted property in a function/method other than a constructor. | ||
private(set) string|int $incorrect2 // error30 | ||
----------------------------------- | ||
HINT:Can't declare a promoted property in a function/method other than a constructor. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.