markTestSkipped('Cannot run test, base class "mysqli" does not exist!'); return; } $this->addFile( 'somefile.php', ' [ ' [ ' [ ' [ 'foo(); } }', ], 'missingParentWithFunction' => [ ' [], 'error_levels' => [ 'UndefinedClass', 'MissingReturnType', ], ], 'subclassWithSimplerArg' => [ ' [ ' [ ' [ '$object' => 'Foo|Bar', ], ], 'instantiateClassAndIsA' => [ 'bar(); }', ], 'returnStringAfterIsACheckWithClassConst' => [ ' [ ' [ ' $array * @psalm-suppress MixedAssignment */ function foo(array $array, string $key) : void { foreach ($array as $i => $item) { $array[$key] = new class() {}; if ($array[$i] === $array[$key]) {} } }', ], 'getClassSelfClass' => [ 'baz(); } return ""; } public function baz(): string { return "baz"; } }', ], 'staticClassComparison' => [ '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' => [ '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' => [ 'zugzug(); $b = (new A)->bar()->baz();', 'assertions' => [ '$a' => 'B', '$b' => 'string', ], ], 'abstractCallToInterfaceMethod' => [ 'fooBar(); } }', ], ]; } /** * @return array */ public function providerInvalidCodeParse() { return [ 'undefinedClass' => [ ' 'UndefinedClass', ], 'wrongCaseClass' => [ ' 'InvalidClass', ], 'wrongCaseClassWithCall' => [ ' 'InvalidClass', ], 'invalidThisFetch' => [ ' 'InvalidScope', ], 'invalidThisArgument' => [ ' 'InvalidScope', ], 'undefinedConstant' => [ ' 'UndefinedConstant', ], 'undefinedClassConstant' => [ ' 'UndefinedConstant', ], 'overridePublicAccessLevelToPrivate' => [ ' 'OverriddenMethodAccess', ], 'overridePublicAccessLevelToProtected' => [ ' 'OverriddenMethodAccess', ], 'overrideProtectedAccessLevelToPrivate' => [ ' 'OverriddenMethodAccess', ], 'overridePublicPropertyAccessLevelToPrivate' => [ ' 'OverriddenPropertyAccess', ], 'overridePublicPropertyAccessLevelToProtected' => [ ' 'OverriddenPropertyAccess', ], 'overrideProtectedPropertyAccessLevelToPrivate' => [ ' 'OverriddenPropertyAccess', ], 'classRedefinition' => [ ' 'DuplicateClass', ], 'classRedefinitionInNamespace' => [ ' 'DuplicateClass', ], 'classRedefinitionInSeparateNamespace' => [ ' 'DuplicateClass', ], 'abstractClassInstantiation' => [ ' 'AbstractInstantiation', ], 'abstractClassMethod' => [ ' 'UnimplementedAbstractMethod', ], 'abstractReflectedClassMethod' => [ ' 'UnimplementedAbstractMethod', ], 'missingParent' => [ ' 'UndefinedClass', ], 'lessSpecificReturnStatement' => [ ' 'LessSpecificReturnStatement', ], 'circularReference' => [ ' 'CircularReference', ], ]; } }