Skip to content

Commit 43feac1

Browse files
committed
PHP 8.0 | PEAR/ValidDefaultValue: add tests with constructor property promotion
The sniff already handles this correctly. This just adds some tests to confirm it and safeguard it for the future.
1 parent 6e0df17 commit 43feac1

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.inc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,5 +100,20 @@ $closure = function(array $arg2=array(), array $arg1) {}
100100

101101
$fn = fn($a = [], $b) => $a[] = $b;
102102

103+
class OnlyConstructorPropertyPromotion {
104+
public function __construct(
105+
public string $name = '',
106+
protected $bar
107+
) {}
108+
}
109+
110+
class ConstructorPropertyPromotionMixedWithNormalParams {
111+
public function __construct(
112+
public string $name = '',
113+
?int $optionalParam = 0,
114+
mixed $requiredParam,
115+
) {}
116+
}
117+
103118
// Intentional syntax error. Must be last thing in the file.
104119
function

src/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ public function getErrorList()
3535
91 => 1,
3636
99 => 1,
3737
101 => 1,
38+
106 => 1,
39+
114 => 1,
3840
];
3941

4042
}//end getErrorList()

0 commit comments

Comments
 (0)