[ ' [ ' [ ' [ '$a' => 'int', ], ], 'varCallableParamReturnType' => [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ '$a' => 'array{0:string, 1:string}', '$b' => 'array{0:string, 1:string}', '$c' => 'array{0:string, 1:string}', '$d' => 'array{0:string, 1:string}', '$e' => 'array{0:string, 1:string}', '$f' => 'array{0:string, 1:string}', ], ], 'arrayMapClosureVar' => [ ' [ '$a' => 'array{0:int, 1:int, 2:int}', ], ], 'arrayCallableMethod' => [ ' [ ' [ ' $b ? 1 : 0; } $arr = [5, 4, 3, 1, 2]; usort($arr, "fooBar"); } }', ], 'closureSelf' => [ 'subitems = array_map( function(self $i): self { return $i; }, $in ); } } new A([new A, new A]);', ], 'possiblyUndefinedFunction' => [ ' [ ' [ ' [ 'callMeMaybe("foo");', ], 'isCallableString' => [ ' [ ' [ ' [ ' [ '$a' => 'A', ], ], 'returnsTypedClosureWithSubclassParam' => [ ' [ '$a' => 'A', ], ], 'returnsTypedClosureWithParentReturn' => [ ' [ '$a' => 'A', ], ], 'returnsTypedCallableFromClosure' => [ ' [ '$a' => 'A', ], ], 'inferClosureTypeWithTypehint' => [ ' [ '$adder1' => 'Closure(int):Closure(int):int', '$adder2' => 'Closure(int):Closure(int):int', ], 'error_levels' => ['MissingClosureReturnType'], ], 'inferArrayMapReturnTypeWithoutTypehints' => [ ' [], 'error_levels' => ['MissingClosureReturnType'], ], 'inferArrayMapReturnTypeWithTypehints' => [ ' [ ' [ 'callable = $callable; } public function callTheCallableDirectly(): bool { return ($this->callable)(); } public function callTheCallableIndirectly(): bool { $r = $this->callable; return $r(); } }', ], 'invokableProperties' => [ 'invokable = $invokable; } public function callTheInvokableDirectly(): bool { return ($this->invokable)(); } public function callTheInvokableIndirectly(): bool { $r = $this->invokable; return $r(); } }', ], 'PHP71-mirrorCallableParams' => [ ' 0; }));', ], 'singleLineClosures' => [ ' [ '$a' => 'Closure():Closure():string(hello)', '$b' => 'string', ], ], 'nullableReturnTypeShorthand' => [ ' [ ' [ ' [ ' [ ' [ ' $b; } } f("strcmp"); f([new C, "m"]); f([C::class, "m"]);' ], 'callableWithSpaces' => [ ' [ ' [ ' 0; } } acceptsIntToBool(Closure::fromCallable(new NamedInvokable));' ], 'PHP71-closureFromCallableInvokableAnonymousClass' => [ ' 0; } }; acceptsIntToBool(Closure::fromCallable($anonInvokable));' ], ]; } /** * @return array */ public function providerInvalidCodeParse() { return [ 'wrongArg' => [ ' 'InvalidScalarArgument', ], 'noReturn' => [ ' 'InvalidReturnType', ], 'undefinedCallableClass' => [ 'getFoo()($argOne, $argTwo); } }', 'error_message' => 'InvalidFunctionCall', 'error_levels' => ['UndefinedClass', 'MixedInferredReturnType'], ], 'undefinedCallableMethodFullString' => [ ' 'UndefinedMethod', ], 'undefinedCallableMethodClassConcat' => [ ' 'UndefinedMethod', ], 'undefinedCallableMethodArray' => [ ' 'UndefinedMethod', ], 'undefinedCallableMethodArrayWithoutClass' => [ ' 'UndefinedMethod', ], 'undefinedCallableMethodClass' => [ ' 'UndefinedClass', ], 'undefinedCallableFunction' => [ ' 'UndefinedFunction', ], 'possiblyNullFunctionCall' => [ ' 'MixedReturnStatement', ], 'stringFunctionCall' => [ ' 'MixedAssignment', ], 'wrongParamType' => [ ' 'InvalidScalarArgument', ], 'missingClosureReturnType' => [ ' 'MissingClosureReturnType', ], 'wrongCallableReturnType' => [ ' 'InvalidReturnStatement', ], 'returnsTypedClosureWithBadReturnType' => [ ' 'InvalidReturnStatement', ], 'returnsTypedCallableWithBadReturnType' => [ ' 'InvalidReturnStatement', ], 'returnsTypedClosureWithBadParamType' => [ ' 'InvalidReturnStatement', ], 'returnsTypedCallableWithBadParamType' => [ ' 'InvalidReturnStatement', ], 'returnsTypedClosureWithBadCall' => [ ' 'InvalidArgument', ], 'returnsTypedClosureWithSubclassParam' => [ ' 'LessSpecificReturnStatement', ], 'returnsTypedClosureWithSubclassReturn' => [ ' 'LessSpecificReturnStatement', ], 'returnsTypedClosureFromCallable' => [ ' 'LessSpecificReturnStatement', ], 'undefinedVariable' => [ ' 'UndefinedVariable', ], 'voidReturningArrayMap' => [ ' 'TypeDoesNotContainType', ], 'checkCallableTypeString' => [ ' 'InvalidScalarArgument', ], 'checkCallableTypeArrayInstanceFirstArg' => [ ' $b; } } f([new C, "m"]);', 'error_message' => 'InvalidScalarArgument', ], 'checkCallableTypeArrayClassStringFirstArg' => [ ' $b; } } f([C::class, "m"]);', 'error_message' => 'InvalidScalarArgument', ], 'PHP71-closureFromCallableInvokableNamedClassWrongArgs' => [ ' 0; } } acceptsIntToBool(Closure::fromCallable(new NamedInvokable));', 'error_message' => 'InvalidScalarArgument', ], 'undefinedClassForCallable' => [ ' 'UndefinedClass', ], 'useDuplicateName' => [ ' 'DuplicateParam' ], 'callableWithSpaceAfterColonBadVarArg' => [ 'p = function (string $s, string $t): stdClass { return new stdClass; }; } }', 'error_message' => 'InvalidPropertyAssignmentValue', ], 'callableWithSpaceBeforeColonBadVarArg' => [ 'p = function (string $s, string $t): stdClass { return new stdClass; }; } }', 'error_message' => 'InvalidPropertyAssignmentValue', ], 'callableWithSpacesEitherSideOfColonBadVarArg' => [ 'p = function (string $s, string $t): stdClass { return new stdClass; }; } }', 'error_message' => 'InvalidPropertyAssignmentValue', ], ]; } }