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