Skip to content

Commit

Permalink
PHP 8.0 | Generic/LowerCaseType: add tests with Constructor Property …
Browse files Browse the repository at this point in the history
…Promotion

The sniff already handles this correctly. This just adds some tests to confirm it and safeguard it for the future.
  • Loading branch information
jrfnl committed Mar 16, 2021
1 parent 46715ed commit 805723a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
}
2 changes: 2 additions & 0 deletions src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public function getErrorList()
72 => 2,
73 => 3,
74 => 3,
78 => 3,
82 => 2,
];

}//end getErrorList()
Expand Down

0 comments on commit 805723a

Please sign in to comment.