From 805723a6a1a7e794ea42aa029d81e3d4030dc1a0 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 16 Mar 2021 18:31:24 +0100 Subject: [PATCH] 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. --- src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc | 8 ++++++++ .../Generic/Tests/PHP/LowerCaseTypeUnitTest.inc.fixed | 8 ++++++++ src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php | 2 ++ 3 files changed, 18 insertions(+) diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc b/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc index 28e696ccc9..8e2dca17e0 100644 --- a/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc +++ b/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc @@ -73,3 +73,11 @@ class TypedProperties private ClassName|/*comment*/Float|STRING|False $unionTypeC; public sTRing | aRRaY | FaLSe $unionTypeD; } + +class ConstructorPropertyPromotionWithTypes { + public function __construct(protected Float|Int $x, public ?STRING &$y = 'test', private mixed $z) {} +} + +class ConstructorPropertyPromotionAndNormalParams { + public function __construct(public Int $promotedProp, ?Int $normalArg) {} +} diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc.fixed b/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc.fixed index 302c0faf0a..6e03f7c2d5 100644 --- a/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc.fixed +++ b/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc.fixed @@ -73,3 +73,11 @@ class TypedProperties private ClassName|/*comment*/float|string|false $unionTypeC; public string | array | false $unionTypeD; } + +class ConstructorPropertyPromotionWithTypes { + public function __construct(protected float|int $x, public ?string &$y = 'test', private mixed $z) {} +} + +class ConstructorPropertyPromotionAndNormalParams { + public function __construct(public int $promotedProp, ?int $normalArg) {} +} diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php b/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php index 005c8280d9..d447e8f47e 100644 --- a/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php @@ -63,6 +63,8 @@ public function getErrorList() 72 => 2, 73 => 3, 74 => 3, + 78 => 3, + 82 => 2, ]; }//end getErrorList()