addFile( 'somefile.php', ',ignored_issues?:list}> */ public function providerValidCodeParse(): iterable { return [ 'overrideProtectedAccessLevelToPublic' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => 'foo(); } }', ], 'missingParentWithFunction' => [ 'code' => ' [], 'ignored_issues' => [ 'UndefinedClass', 'MissingReturnType', ], ], 'subclassWithSimplerArg' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ '$object' => 'Bar|Foo', ], ], 'instantiateClassAndIsA' => [ 'code' => 'bar(); }', ], 'returnStringAfterIsACheckWithClassConst' => [ 'code' => ' [ 'code' => ' [ 'code' => ' $array */ function foo(array $array, string $key) : void { foreach ($array as $i => $item) { $array[$key] = new class() {}; if ($array[$i] === $array[$key]) {} } }', ], 'getClassSelfClass' => [ 'code' => 'baz(); } return ""; } public function baz(): string { return "baz"; } }', ], 'staticClassComparison' => [ 'code' => 'baz(); } return ""; } public static function foo2(): string { if (static::class === D::class) { return static::bat(); } return ""; } } class D extends C { public function baz(): string { return "baz"; } public static function bat(): string { return "baz"; } }', ], 'isAStaticClass' => [ 'code' => 'baz(); } return ""; } public static function foo2(): string { if (is_a(static::class, D::class, true)) { return static::bat(); } return ""; } } class D extends C { public function baz(): string { return "baz"; } public static function bat(): string { return "baz"; } }', ], 'typedMagicCall' => [ 'code' => 'zugzug(); $b = (new A)->bar()->baz();', 'assertions' => [ '$a' => 'B', '$b' => 'string', ], ], 'abstractCallToInterfaceMethod' => [ 'code' => 'fooBar(); } }', ], 'noCrashWhenIgnoringUndefinedClass' => [ 'code' => ' [], 'ignored_issues' => [ 'UndefinedClass', ], ], 'noCrashWhenIgnoringUndefinedParam' => [ 'code' => ' [], 'ignored_issues' => [ 'UndefinedClass', 'InvalidArgument', ], ], 'noCrashWhenIgnoringUndefinedReturnIterableArg' => [ 'code' => ' [], 'ignored_issues' => [ 'UndefinedClass', 'MixedInferredReturnType', 'InvalidArgument', ], ], 'noCrashWhenIgnoringUndefinedReturnClassArg' => [ 'code' => ' [], 'ignored_issues' => [ 'UndefinedClass', 'MixedInferredReturnType', 'InvalidArgument', ], ], 'allowAbstractInstantiationOnPossibleChild' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [], 'ignored_issues' => ['PropertyNotSetInConstructor'], ], 'classAliasNoException' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => 'mock(); return $b; }' ], 'allowTraversableImplementationAlongWithIteratorAggregate' => [ 'code' => ' * @implements IteratorAggregate */ final class C implements Traversable, IteratorAggregate { public function getIterator() { yield 1; } } ', ], 'allowTraversableImplementationAlongWithIterator' => [ 'code' => ' * @implements Iterator<1, 1> */ final class C implements Traversable, Iterator { public function current() { return 1; } public function key() { return 1; } public function next() { } public function rewind() { } public function valid() { return false; } } ', ], 'allowTraversableImplementationOnAbstractClass' => [ 'code' => ' */ abstract class C implements Traversable {} ', ], 'allowIndirectTraversableImplementationOnAbstractClass' => [ 'code' => ' */ interface I extends Traversable {} abstract class C implements I {} ', ], ]; } /** * @return iterable,php_version?:string}> */ public function providerInvalidCodeParse(): iterable { return [ 'undefinedClass' => [ 'code' => ' 'UndefinedClass', ], 'wrongCaseClass' => [ 'code' => ' 'InvalidClass', ], 'wrongCaseClassWithCall' => [ 'code' => ' 'InvalidClass', ], 'invalidThisFetch' => [ 'code' => ' 'InvalidScope', ], 'invalidThisArgument' => [ 'code' => ' 'InvalidScope', ], 'undefinedConstant' => [ 'code' => ' 'UndefinedConstant', ], 'undefinedClassConstant' => [ 'code' => ' 'UndefinedConstant', ], 'overridePublicAccessLevelToPrivate' => [ 'code' => ' 'OverriddenMethodAccess', ], 'overridePublicAccessLevelToProtected' => [ 'code' => ' 'OverriddenMethodAccess', ], 'overrideProtectedAccessLevelToPrivate' => [ 'code' => ' 'OverriddenMethodAccess', ], 'overridePublicPropertyAccessLevelToPrivate' => [ 'code' => ' 'OverriddenPropertyAccess', ], 'overridePublicPropertyAccessLevelToProtected' => [ 'code' => ' 'OverriddenPropertyAccess', ], 'overrideProtectedPropertyAccessLevelToPrivate' => [ 'code' => ' 'OverriddenPropertyAccess', ], 'classRedefinition' => [ 'code' => ' 'DuplicateClass', ], 'classRedefinitionInNamespace' => [ 'code' => ' 'DuplicateClass', ], 'classRedefinitionInSeparateNamespace' => [ 'code' => ' 'DuplicateClass', ], 'abstractClassInstantiation' => [ 'code' => ' 'AbstractInstantiation', ], 'abstractClassMethod' => [ 'code' => ' 'UnimplementedAbstractMethod', ], 'abstractReflectedClassMethod' => [ 'code' => '> */ class DedupeIterator extends FilterIterator { /** * @param Iterator $i */ public function __construct(Iterator $i) { parent::__construct($i); } }', 'error_message' => 'UnimplementedAbstractMethod', ], 'missingParent' => [ 'code' => ' 'UndefinedClass', ], 'lessSpecificReturnStatement' => [ 'code' => ' 'LessSpecificReturnStatement', ], 'circularReference' => [ 'code' => ' 'CircularReference', ], 'preventAbstractInstantiationDefiniteClasss' => [ 'code' => ' 'AbstractInstantiation', ], 'preventExtendingInterface' => [ 'code' => ' 'UndefinedClass', ], 'preventImplementingClass' => [ 'code' => ' 'UndefinedInterface', ], 'classAliasAlreadyDefinedClass' => [ 'code' => ' 'TypeDoesNotContainType', ], 'cannotOverrideFinalType' => [ 'code' => ' 'MethodSignatureMismatch', ], 'preventFinalOverriding' => [ 'code' => 'foo();', 'error_message' => 'LessSpecificReturnStatement', ], 'preventTraversableImplementation' => [ 'code' => ' */ final class C implements Traversable {} ', 'error_message' => 'InvalidTraversableImplementation', ], 'preventIndirectTraversableImplementation' => [ 'code' => ' */ interface I extends Traversable {} final class C implements I {} ', 'error_message' => 'InvalidTraversableImplementation', ], 'detectMissingTemplateExtends' => [ 'code' => ' 'MissingTemplateParam', ], 'detectMissingTemplateImplements' => [ 'code' => ' 'MissingTemplateParam', ], 'detectMissingTemplateUse' => [ 'code' => ' 'MissingTemplateParam', ], 'detectMissingTemplateExtendsNative' => [ 'code' => ' 'MissingTemplateParam', ], 'detectMissingTemplateImplementsNative' => [ 'code' => ' 'MissingTemplateParam', ], ]; } }