[ 'code' => ' "Red", Suit::Clubs, Suit::Spades => "Black", }; } public function shape(): string { return "Rectangle"; } } function paint(Colourful $c): void {} function deal(Suit $s): void { if ($s === Suit::Clubs) { echo $s->color(); } } paint(Suit::Clubs); deal(Suit::Spades); Suit::Diamonds->shape();', 'assertions' => [], 'ignored_issues' => [], 'php_version' => '8.1', ], 'enumValue' => [ 'code' => 'value === "h") {}', 'assertions' => [], 'ignored_issues' => [], 'php_version' => '8.1', ], 'enumCases' => [ 'code' => ' "Red", Suit::Clubs, Suit::Spades => "Black", }; }', 'assertions' => [], 'ignored_issues' => [], 'php_version' => '8.1', ], 'literalExpressionAsCaseValue' => [ 'code' => 'value; ', 'assertions' => [ '$z===' => '2', ], 'ignored_issues' => [], 'php_version' => '8.1', ], 'EnumCaseValue #8568' => [ 'code' => 'value; ', 'assertions' => [ '$z===' => '1|2', ], 'ignored_issues' => [], 'php_version' => '8.1', ], 'EnumUnionAsCaseValue #8568' => [ 'code' => 'value; ', 'assertions' => [ '$z===' => '1|2', ], 'ignored_issues' => [], 'php_version' => '8.1', ], 'matchCaseOnEnumValue #8812' => [ 'code' => 'value => 1, SomeType::BAR->value => 2, }; } ', 'assertions' => [], 'ignored_issues' => [], 'php_version' => '8.1', ], 'namePropertyFromOutside' => [ 'code' => 'name; ', 'assertions' => [ '$a===' => "'DRAFT'", ], 'ignored_issues' => [], 'php_version' => '8.1', ], 'namePropertyFromInside' => [ 'code' => 'name; } } ', 'assertions' => [], 'ignored_issues' => [], 'php_version' => '8.1', ], 'valuePropertyFromInside' => [ 'code' => 'value; } } echo Status::DRAFT->get(); ', 'assertions' => [], 'ignored_issues' => [], 'php_version' => '8.1', ], 'wildcardEnumAsParam' => [ 'code' => ' [], 'ignored_issues' => [], 'php_version' => '8.1', ], 'wildcardEnumAsReturn' => [ 'code' => ' [], 'ignored_issues' => [], 'php_version' => '8.1', ], 'wildcardConstantsOnEnum' => [ 'code' => ' [], 'ignored_issues' => [], 'php_version' => '8.1', ], 'constantOfAVariableEnumClassString' => [ 'code' => ' [ '$_z===' => '3', ], 'ignored_issues' => [], 'php_version' => '8.1', ], 'constantOfAVariableEnumInstance' => [ 'code' => ' [ '$_z===' => '3', ], 'ignored_issues' => [], 'php_version' => '8.1', ], 'EnumCaseInAttribute' => [ 'code' => ' [], 'ignored_issues' => [], 'php_version' => '8.1', ], 'casesOnEnumWithNoCasesReturnEmptyArray' => [ 'code' => ' [ '$_z===' => 'array', ], 'ignored_issues' => [], 'php_version' => '8.1', ], 'backedEnumFromReturnsInstanceOfThatEnum' => [ 'code' => ' [], 'ignored_issues' => [], 'php_version' => '8.1', ], 'backedEnumTryFromReturnsInstanceOfThatEnum' => [ 'code' => ' [], 'ignored_issues' => [], 'php_version' => '8.1', ], 'backedEnumFromReturnsSpecificCase' => [ 'code' => ' [ '$_z===' => 'enum(Status::Closed)', ], 'ignored_issues' => [], 'php_version' => '8.1', ], 'backedEnumTryFromReturnsSpecificCase' => [ 'code' => ' [ '$_z===' => 'enum(Status::Closed)|null', ], 'ignored_issues' => [], 'php_version' => '8.1', ], 'backedEnumFromReturnsUnionOfCases' => [ 'code' => ' [ '$_z===' => 'enum(Status::Closed)|enum(Status::Open)', ], 'ignored_issues' => [], 'php_version' => '8.1', ], 'backedEnumTryFromReturnsUnionOfCases' => [ 'code' => ' [ '$_z===' => 'enum(Status::Closed)|enum(Status::Open)|null', ], 'ignored_issues' => [], 'php_version' => '8.1', ], 'InterfacesWithProperties' => [ 'code' => ' $tag->name; static fn (\BackedEnum $tag): string|int => $tag->value; interface ExtendedUnitEnum extends \UnitEnum {} static fn (ExtendedUnitEnum $tag): string => $tag->name; interface ExtendedBackedEnum extends \BackedEnum {} static fn (ExtendedBackedEnum $tag): string|int => $tag->value; ', 'assertions' => [], 'ignored_issues' => [], 'php_version' => '8.1', ], 'EnumCollapsing' => [ 'code' => ' [ '$code' => 'Code|int', ], 'ignored_issues' => [], 'php_version' => '8.1', ], 'EnumCaseReconciliation' => [ 'code' => ' [ '$code1' => 'Code|null', '$code2' => 'null', ], 'ignored_issues' => [], 'php_version' => '8.1', ], 'constantAsACaseValueOfABackedEnum' => [ 'code' => 'value; ', 'assertions' => [ '$a===' => "'forty two'", ], 'ignored_issues' => [], 'php_version' => '8.1', ], 'methodInheritanceByInterfaces' => [ 'code' => ' [ '$a===' => 'list', '$b===' => 'I', '$c===' => 'I|null', ], 'ignored_issues' => [], 'php_version' => '8.1', ], 'reconcileCaseWithInterface' => [ 'code' => <<<'PHP' [], 'ignored_issues' => [], 'php_version' => '8.1', ], 'valueOfBackedEnum' => [ 'code' => <<<'PHP' $string */ $string = ''; /** @var value-of $anyString */ $anyString = ''; /** @var value-of $int */ $int = 0; /** @var value-of $anyInt */ $anyInt = 0; PHP, 'assertions' => [ '$string===' => '\'foo\'', '$anyString===' => '\'bar\'|\'foo\'', '$int===' => '1', '$anyInt===' => '1|2', ], 'ignored_issues' => [], 'php_version' => '8.1', ], 'nameTypeOnKnownCases' => [ 'code' => <<<'PHP' name; PHP, 'assertions' => [ '$_name===' => "'BIKE'|'BOAT'|'CAR'", ], 'ignored_issues' => [], 'php_version' => '8.1', ], 'nameTypeOnUnknownCases' => [ 'code' => <<<'PHP' name; /** @psalm-check-type-exact $_name='BIKE'|'BOAT'|'CAR' */; } PHP, 'assertions' => [], 'ignored_issues' => [], 'php_version' => '8.1', ], 'backedEnumCaseValueFromClassConstant' => [ 'code' => <<<'PHP' [], 'ignored_issues' => [], 'php_version' => '8.1', ], 'allowPropertiesOnIntersectionsWithEnumInterfaces' => [ 'code' => <<<'PHP' name; } if ($i instanceof UnitEnum) { echo $i->name; } if ($i instanceof UE) { echo $i->name; } if ($i instanceof BE) { echo $i->name; } } PHP, 'assertions' => [], 'ignored_issues' => [], 'php_version' => '8.1', ], 'stringBackedEnumCaseValueFromStringGlobalConstant' => [ 'code' => ' [], 'ignored_issues' => [], 'php_version' => '8.1', ], 'intBackedEnumCaseValueFromIntGlobalConstant' => [ 'code' => ' [], 'ignored_issues' => [], 'php_version' => '8.1', ], ]; } public function providerInvalidCodeParse(): iterable { return [ 'enumValueIsNot' => [ 'code' => 'value === "a") {}', 'error_message' => 'TypeDoesNotContainType', 'ignored_issues' => [], 'php_version' => '8.1', ], 'enumValueNotBacked' => [ 'code' => 'value;', 'error_message' => 'UndefinedPropertyFetch', 'ignored_issues' => [], 'php_version' => '8.1', ], 'badSuit' => [ 'code' => ' 'UndefinedConstant', 'ignored_issues' => [], 'php_version' => '8.1', ], 'cantCompareToSuitTwice' => [ 'code' => ' 'RedundantCondition', 'ignored_issues' => [], 'php_version' => '8.1', ], 'insufficientMatches' => [ 'code' => ' "Red", Suit::Clubs => "Black", }; } }', 'error_message' => 'UnhandledMatchCondition', 'ignored_issues' => [], 'php_version' => '8.1', ], 'insufficientMatchesForCases' => [ 'code' => ' "Red", Suit::Clubs => "Black", }; }', 'error_message' => 'UnhandledMatchCondition', 'ignored_issues' => [], 'php_version' => '8.1', ], 'invalidBackingType' => [ 'code' => ' 'InvalidEnumBackingType', 'ignored_issues' => [], 'php_version' => '8.1', ], 'invalidCaseTypeForBackedEnum' => [ 'code' => ' 'InvalidEnumCaseValue', 'ignored_issues' => [], 'php_version' => '8.1', ], 'duplicateValues' => [ 'code' => ' 'DuplicateEnumCaseValue', 'ignored_issues' => [], 'php_version' => '8.1', ], 'duplicateCases' => [ 'code' => ' 'DuplicateEnumCase', 'ignored_issues' => [], 'php_version' => '8.1', ], 'caseWithAValueOfANonBackedEnum' => [ 'code' => ' 'InvalidEnumCaseValue', 'ignored_issues' => [], 'php_version' => '8.1', ], 'caseWithoutAValueOfABackedEnum' => [ 'code' => ' 'InvalidEnumCaseValue', 'ignored_issues' => [], 'php_version' => '8.1', ], 'caseTypeMismatch' => [ 'code' => ' 'InvalidEnumCaseValue', 'ignored_issues' => [], 'php_version' => '8.1', ], 'propsOnEnum' => [ 'code' => ' 'NoEnumProperties', 'ignored_issues' => [], 'php_version' => '8.1', ], 'enumInstantiation' => [ 'code' => ' 'UndefinedClass', 'ignored_issues' => [], 'php_version' => '8.1', ], 'enumsAsAttributes' => [ 'code' => ' 'InvalidAttribute', 'ignored_issues' => [], 'php_version' => '8.1', ], 'deprecatedAttribute' => [ 'code' => ' 'DeprecatedConstant', 'ignored_issues' => [], 'php_version' => '8.1', ], 'forbiddenMethod' => [ 'code' => ' 'InvalidEnumMethod', 'ignored_issues' => [], 'php_version' => '8.1', ], 'forbiddenUnitEnumImplementation' => [ 'code' => ' 'InvalidInterfaceImplementation', 'ignored_issues' => [], 'php_version' => '8.1', ], 'forbiddenBackedEnumImplementation' => [ 'code' => ' 'InvalidInterfaceImplementation', 'ignored_issues' => [], 'php_version' => '8.1', ], 'forbiddenUnitEnumCasesMethod' => [ 'code' => ' 'InvalidEnumMethod', 'ignored_issues' => [], 'php_version' => '8.1', ], 'forbiddenBackedEnumCasesMethod' => [ 'code' => ' 'InvalidEnumMethod', 'ignored_issues' => [], 'php_version' => '8.1', ], 'forbiddenBackedEnumFromMethod' => [ 'code' => ' 'InvalidEnumMethod', 'ignored_issues' => [], 'php_version' => '8.1', ], 'forbiddenBackedEnumTryFromMethod' => [ 'code' => ' 'InvalidEnumMethod', 'ignored_issues' => [], 'php_version' => '8.1', ], 'functionCallWithInvalidCase' => [ 'code' => ' 'InvalidArgument', 'ignored_issues' => [], 'php_version' => '8.1', ], 'issue-7814-1' => [ 'code' => ' 'InvalidArgument', 'ignored_issues' => [], 'php_version' => '8.1', ], 'issue-7814-2' => [ 'code' => ' $_ */ function withA(WithState $_): void {} // Should be issue here. But nothing // Argument 1 of withA expects WithState, WithState provided withA(new WithState(State::C)); ', 'error_message' => 'InvalidArgument', 'ignored_issues' => [], 'php_version' => '8.1', ], 'backedEnumDoesNotPassNativeType' => [ 'code' => ' 'InvalidArgument', 'ignored_issues' => [], 'php_version' => '8.1', ], 'stringBackedEnumCaseValueFromClassConstant' => [ 'code' => ' 'InvalidEnumCaseValue', 'ignored_issues' => [], 'php_version' => '8.1', ], 'intBackedEnumCaseValueFromClassConstant' => [ 'code' => ' 'InvalidEnumCaseValue', 'ignored_issues' => [], 'php_version' => '8.1', ], 'invalidStringBackedEnumCaseValueFromStringGlobalConstant' => [ 'code' => ' 'InvalidEnumCaseValue', 'ignored_issues' => [], 'php_version' => '8.1', ], 'invalidIntBackedEnumCaseValueFromIntGlobalConstant' => [ 'code' => ' 'InvalidEnumCaseValue', 'ignored_issues' => [], 'php_version' => '8.1', ], 'invalidStringBackedEnumCaseValueFromIntGlobalConstant' => [ 'code' => ' 'InvalidEnumCaseValue', 'ignored_issues' => [], 'php_version' => '8.1', ], 'invalidIntBackedEnumCaseValueFromStringGlobalConstant' => [ 'code' => ' 'InvalidEnumCaseValue', 'ignored_issues' => [], 'php_version' => '8.1', ], ]; } }