1: <?php declare(strict_types = 1);
2:
3: namespace PHPStan\Type;
4:
5: /**
6: * Bits of Type::getKindMask(): the kinds of values PHP tells apart by their
7: * type. A value is of exactly one kind, so two types whose masks share no bit
8: * share no value: their union cannot merge them into one member and their
9: * intersection is never.
10: *
11: * @api
12: */
13: final class TypeKind
14: {
15:
16: public const NULL = 1;
17: public const FALSE = 2;
18: public const TRUE = 4;
19: public const INT = 8;
20: public const FLOAT = 16;
21: public const STRING = 32;
22: public const ARRAY = 64;
23: public const OBJECT = 128;
24: public const RESOURCE = 256;
25:
26: public const BOOL = self::FALSE | self::TRUE;
27: public const ALL = self::NULL | self::BOOL | self::INT | self::FLOAT | self::STRING | self::ARRAY | self::OBJECT | self::RESOURCE;
28:
29: /**
30: * Whether no value is of both masks' kinds. A mask without kinds, as of
31: * never, overlaps with every mask: a type of no values is a subtype of
32: * any other, which union() and intersect() still have to see.
33: */
34: public static function areDisjoint(int $a, int $b): bool
35: {
36: return ($a & $b) === 0 && $a !== 0 && $b !== 0;
37: }
38:
39: }
40: