Skip to content

Commit b8f5f63

Browse files
committed
PHP 8.2 | Generic/LowerCaseType: allow for stand-alone true/false/null
As of PHP 8.2, `true`, `false` and `null` will be allowed as stand-alone types. The `true` and the `false` types are allowed to be nullable, the `null` type is not (but that's not the concern of the sniff). Also see: https://3v4l.org/ZpfID This commit adjusts the sniff to take `true` into account. `false` and `null` were already handled due to these previously already being allowed in union types. Includes unit tests. Refs: * https://wiki.php.net/rfc/null-false-standalone-types * https://wiki.php.net/rfc/true-type
1 parent 9b769b2 commit b8f5f63

File tree

4 files changed

+6
-0
lines changed

4 files changed

+6
-0
lines changed

src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class LowerCaseTypeSniff implements Sniff
3737
'mixed' => true,
3838
'static' => true,
3939
'false' => true,
40+
'true' => true,
4041
'null' => true,
4142
'never' => true,
4243
];

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

+2
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,5 @@ function intersectionReturnTypes ($var): \Package\ClassName&\Package\Other_Class
9292

9393
$arrow = fn (int $a, string $b, bool $c, array $d, Foo\Bar $e) : int => $a * $b;
9494
$arrow = fn (Int $a, String $b, BOOL $c, Array $d, Foo\Bar $e) : Float => $a * $b;
95+
96+
$cl = function (False $a, TRUE $b, Null $c): ?True {}

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

+2
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,5 @@ function intersectionReturnTypes ($var): \Package\ClassName&\Package\Other_Class
9292

9393
$arrow = fn (int $a, string $b, bool $c, array $d, Foo\Bar $e) : int => $a * $b;
9494
$arrow = fn (int $a, string $b, bool $c, array $d, Foo\Bar $e) : float => $a * $b;
95+
96+
$cl = function (false $a, true $b, null $c): ?true {}

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

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public function getErrorList()
6767
82 => 2,
6868
85 => 1,
6969
94 => 5,
70+
96 => 4,
7071
];
7172

7273
}//end getErrorList()

0 commit comments

Comments
 (0)