1: <?php declare(strict_types = 1);
2:
3: namespace PHPStan\Reflection;
4:
5: /**
6: * Result of checking constants passed to a parameter against its allowed set.
7: *
8: * Returned by ExtendedParameterReflection::checkAllowedConstants(). Reports
9: * three kinds of problems: constants not in the allowed list, mutually exclusive
10: * constants combined in a bitmask, and bitmask usage on a single-value parameter.
11: *
12: * @api
13: */
14: final class AllowedConstantsResult
15: {
16:
17: /**
18: * @param list<ConstantReflection> $disallowedConstants
19: * @param list<list<string>> $violatedExclusiveGroups
20: */
21: public function __construct(
22: private array $disallowedConstants,
23: private array $violatedExclusiveGroups,
24: private bool $bitmaskNotAllowed,
25: )
26: {
27: }
28:
29: public function isOk(): bool
30: {
31: return $this->disallowedConstants === [] && $this->violatedExclusiveGroups === [] && !$this->bitmaskNotAllowed;
32: }
33:
34: public function isBitmaskNotAllowed(): bool
35: {
36: return $this->bitmaskNotAllowed;
37: }
38:
39: /**
40: * @return list<ConstantReflection>
41: */
42: public function getDisallowedConstants(): array
43: {
44: return $this->disallowedConstants;
45: }
46:
47: /**
48: * @return list<list<string>>
49: */
50: public function getViolatedExclusiveGroups(): array
51: {
52: return $this->violatedExclusiveGroups;
53: }
54:
55: }
56: