[ ' [ ' [ 'barBar();', ], 'staticInvocation' => [ ' [ ' [ ' [ 'sub(new DateInterval("P1D")); $b = (new DateTimeImmutable())->modify("+3 hours");', 'assertions' => [ '$yesterday' => 'MyDate', '$b' => 'DateTimeImmutable', ], ], 'magicCall' => [ 'bar();', ], 'canBeCalledOnMagic' => [ 'maybeUndefinedMethod();', 'assertions' => [], 'error_levels' => ['PossiblyUndefinedMethod'], ], 'canBeCalledOnMagicWithMethod' => [ 'bar();', 'assertions' => [], ], 'invokeCorrectType' => [ ' [ 'createElement("foo"); $newnode = $doc->appendChild($node); $newnode->setAttribute("bar", "baz");', ], 'nonStaticSelfCall' => [ 'call());', ], 'simpleXml' => [ '"); $a = $xml->asXML(); $b = $xml->asXML("foo.xml");', 'assertions' => [ '$a' => 'string|false', '$b' => 'string|bool', ], ], 'datetimeformatNotFalse' => [ 'format($format); if (false !== $formatted) {} function takesString(string $s) : void {} takesString($formatted);' ], 'domElement' => [ 'getElementsByTagName("bar"); $b = $a->item(0); if (!$b) { return null; } return $b->getAttribute("bat"); }', ], 'reflectionParameter' => [ 'getType(); if ($type === null) { return "mixed"; } return $type->getName(); }' ], ]; } /** * @return array */ public function providerFileCheckerInvalidCodeParse() { return [ 'staticInvocation' => [ ' 'InvalidStaticInvocation', ], 'parentStaticCall' => [ ' 'InvalidStaticInvocation', ], 'mixedMethodCall' => [ 'barBar();', 'error_message' => 'MixedMethodCall', 'error_levels' => [ 'MissingPropertyType', 'MixedAssignment', ], ], 'invalidMethodCall' => [ 'someMethod();', 'error_message' => 'InvalidMethodCall', ], 'possiblyInvalidMethodCall' => [ 'methodOfA(); } }', 'error_message' => 'PossiblyInvalidMethodCall', ], 'selfNonStaticInvocation' => [ ' 'NonStaticSelfCall', ], 'noParent' => [ ' 'ParentNotFound', ], 'coercedClass' => [ ' 'LessSpecificReturnStatement', 'error_levels' => ['MixedInferredReturnType', 'MixedReturnStatement'], ], 'undefinedVariableStaticCall' => [ ' 'UndefinedGlobalVariable', ], 'staticCallOnString' => [ ' 'MixedAssignment', ], 'possiblyNullFunctionCall' => [ 'foo();', 'error_message' => 'InvalidScope', ], 'possiblyFalseReference' => [ 'bar();', 'error_message' => 'PossiblyFalseReference', ], 'undefinedParentClass' => [ ' 'MissingDependency - src' . DIRECTORY_SEPARATOR . 'somefile.php:7', ], 'variableMethodCallOnArray' => [ '$b();', 'error_message' => 'InvalidMethodCall', ], 'intVarStaticCall' => [ ' 'UndefinedClass', ], 'intVarNewCall' => [ ' 'UndefinedClass', ], 'invokeTypeMismatch' => [ ' 'InvalidScalarArgument', ], 'explicitInvokeTypeMismatch' => [ '__invoke(1);', 'error_message' => 'InvalidScalarArgument', ], 'undefinedMethodPassedAsArg' => [ 'foo(bar());', 'error_message' => 'UndefinedFunction' ], 'noIntersectionMethod' => [ 'zugzug(); }', 'error_message' => 'UndefinedMethod - src/somefile.php:7 - Method (B&A)::zugzug does not exist' ], ]; } }