[ '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' => [ // xxx: we should be able to do better when we reference a case explicitly, like above '$z===' => '1|2', ], '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', ], ]; } /** * */ 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', ], ]; } }