,error_levels?:string[]}> */ public function providerValidCodeParse(): iterable { return [ 'example' => [ ' "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();', [], [], '8.1' ], 'enumValue' => [ 'value === "h") {}', [], [], '8.1' ], 'enumCases' => [ ' "Red", Suit::Clubs, Suit::Spades => "Black", }; }', [], [], '8.1' ], 'literalExpressionAsCaseValue' => [ 'value; ', 'assertions' => [ // xxx: we should be able to do better when we reference a case explicitly, like above '$z===' => '1|2', ], [], '8.1' ], 'namePropertyFromOutside' => [ 'name; ', 'assertions' => [ '$a===' => '"DRAFT"', ], [], '8.1' ], 'namePropertyFromInside' => [ 'name; } } ', 'assertions' => [], [], '8.1' ], 'valuePropertyFromInside' => [ 'value; } } echo Status::DRAFT->get(); ', 'assertions' => [], [], '8.1' ], 'wildcardEnumAsParam' => [ ' [], [], '8.1', ], 'wildcardEnumAsReturn' => [ ' [], [], '8.1', ], 'wildcardConstantsOnEnum' => [ ' [], [], '8.1', ], 'constantOfAVariableEnumClassString' => [ ' [ '$_z===' => '3', ], [], '8.1', ], 'constantOfAVariableEnumInstance' => [ ' [ '$_z===' => '3', ], [], '8.1', ], 'EnumCaseInAttribute' => [ ' [], [], '8.1', ], 'casesOnEnumWithNoCasesReturnEmptyArray' => [ ' [ '$_z===' => 'array', ], [], '8.1', ], 'backedEnumFromReturnsInstanceOfThatEnum' => [ ' [], [], '8.1', ], 'backedEnumTryFromReturnsInstanceOfThatEnum' => [ ' [], [], '8.1', ], 'backedEnumFromReturnsSpecificCase' => [ ' [ '$_z===' => 'enum(Status::Closed)', ], [], '8.1', ], 'backedEnumTryFromReturnsSpecificCase' => [ ' [ '$_z===' => 'enum(Status::Closed)|null', ], [], '8.1', ], 'backedEnumFromReturnsUnionOfCases' => [ ' [ '$_z===' => 'enum(Status::Closed)|enum(Status::Open)', ], [], '8.1', ], 'backedEnumTryFromReturnsUnionOfCases' => [ ' [ '$_z===' => 'enum(Status::Closed)|enum(Status::Open)|null', ], [], '8.1', ], ]; } /** * @return iterable */ public function providerInvalidCodeParse(): iterable { return [ 'enumValueIsNot' => [ 'value === "a") {}', 'error_message' => 'TypeDoesNotContainType', [], false, '8.1' ], 'enumValueNotBacked' => [ 'value;', 'error_message' => 'UndefinedPropertyFetch', [], false, '8.1' ], 'badSuit' => [ ' 'UndefinedConstant', [], false, '8.1' ], 'cantCompareToSuitTwice' => [ ' 'RedundantCondition', [], false, '8.1' ], 'insufficientMatches' => [ ' "Red", Suit::Clubs => "Black", }; } }', 'error_message' => 'UnhandledMatchCondition', [], false, '8.1' ], 'insufficientMatchesForCases' => [ ' "Red", Suit::Clubs => "Black", }; }', 'error_message' => 'UnhandledMatchCondition', [], false, '8.1' ], 'invalidBackingType' => [ ' 'InvalidEnumBackingType', [], false, '8.1', ], 'duplicateValues' => [ ' 'DuplicateEnumCaseValue', [], false, '8.1', ], 'duplicateCases' => [ ' 'DuplicateEnumCase', [], false, '8.1', ], 'caseWithAValueOfANonBackedEnum' => [ ' 'InvalidEnumCaseValue', [], false, '8.1', ], 'caseWithoutAValueOfABackedEnum' => [ ' 'InvalidEnumCaseValue', [], false, '8.1', ], 'caseTypeMismatch' => [ ' 'InvalidEnumCaseValue', [], false, '8.1', ], 'propsOnEnum' => [ ' 'NoEnumProperties', [], false, '8.1', ], 'enumInstantiation' => [ ' 'UndefinedClass', [], false, '8.1', ], 'enumsAsAttributes' => [ ' 'InvalidAttribute', [], false, '8.1', ], 'deprecatedAttribute' => [ ' 'DeprecatedConstant', [], false, '8.1', ], ]; } }