forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStaticTypeFactory.php
More file actions
44 lines (34 loc) · 854 Bytes
/
Copy pathStaticTypeFactory.php
File metadata and controls
44 lines (34 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php declare(strict_types = 1);
namespace PHPStan\Type;
use PHPStan\Type\Constant\ConstantArrayType;
use PHPStan\Type\Constant\ConstantBooleanType;
use PHPStan\Type\Constant\ConstantFloatType;
use PHPStan\Type\Constant\ConstantIntegerType;
use PHPStan\Type\Constant\ConstantStringType;
class StaticTypeFactory
{
public static function falsey(): Type
{
static $falsey;
if ($falsey === null) {
$falsey = new UnionType([
new NullType(),
new ConstantBooleanType(false),
new ConstantIntegerType(0),
new ConstantFloatType(0.0),
new ConstantStringType(''),
new ConstantStringType('0'),
new ConstantArrayType([], []),
]);
}
return $falsey;
}
public static function truthy(): Type
{
static $truthy;
if ($truthy === null) {
$truthy = new MixedType(false, self::falsey());
}
return $truthy;
}
}