Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved new methods to StaticTypeFactory
- Loading branch information
1 parent
69958e2
commit 5b88a8b
Showing
7 changed files
with
71 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters