,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' ], ]; } /** * @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', ], ]; } }