Skip to content

Commit 805723a

Browse files
committed
PHP 8.0 | Generic/LowerCaseType: 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 46715ed commit 805723a

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,11 @@ class TypedProperties
7373
private ClassName|/*comment*/Float|STRING|False $unionTypeC;
7474
public sTRing | aRRaY | FaLSe $unionTypeD;
7575
}
76+
77+
class ConstructorPropertyPromotionWithTypes {
78+
public function __construct(protected Float|Int $x, public ?STRING &$y = 'test', private mixed $z) {}
79+
}
80+
81+
class ConstructorPropertyPromotionAndNormalParams {
82+
public function __construct(public Int $promotedProp, ?Int $normalArg) {}
83+
}

src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc.fixed

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,11 @@ class TypedProperties
7373
private ClassName|/*comment*/float|string|false $unionTypeC;
7474
public string | array | false $unionTypeD;
7575
}
76+
77+
class ConstructorPropertyPromotionWithTypes {
78+
public function __construct(protected float|int $x, public ?string &$y = 'test', private mixed $z) {}
79+
}
80+
81+
class ConstructorPropertyPromotionAndNormalParams {
82+
public function __construct(public int $promotedProp, ?int $normalArg) {}
83+
}

src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ public function getErrorList()
6363
72 => 2,
6464
73 => 3,
6565
74 => 3,
66+
78 => 3,
67+
82 => 2,
6668
];
6769

6870
}//end getErrorList()

0 commit comments

Comments
 (0)