[ 'fooFoo(); } }', ], 'accessibleProtectedMethodFromTrait' => [ 'fooFoo(); } }', ], 'accessiblePublicMethodFromTrait' => [ 'fooFoo(); } }', ], 'accessiblePrivatePropertyFromTrait' => [ 'fooFoo; $this->fooFoo = "hello"; } }', ], 'accessibleProtectedPropertyFromTrait' => [ 'fooFoo; $this->fooFoo = "hello"; } }', ], 'accessiblePublicPropertyFromTrait' => [ 'fooFoo; $this->fooFoo = "hello"; } }', ], 'accessibleProtectedMethodFromInheritedTrait' => [ 'fooFoo(); } }', ], 'accessiblePublicMethodFromInheritedTrait' => [ 'fooFoo(); } }', ], 'staticClassMethodFromWithinTrait' => [ ' [ 'fooFoo("hello");', ], 'redefinedTraitMethodWithAlias' => [ 'barBar(); } }', ], 'traitSelf' => [ 'g();', 'assertions' => [ '$a' => 'A', ], ], 'parentTraitSelf' => [ 'g();', 'assertions' => [ '$a' => 'A', ], ], 'directStaticCall' => [ ' [ 'foo(); } }', ], 'instanceOfTraitUser' => [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ 'getA(); }', ], 'useAndMap' => [ ' [ ' [ 'foo(); } } class A { use T; public function foo(string $s = null) : void { } }', ], 'aliasedMethodInternalCallNoReplacement' => [ 'bar(); } public function bar() : int { return 3; } } class A { use T { bar as bat; } public function baz() : int { return $this->bar(); } }', ], 'aliasedMethodInternalCallWithLocalDefinition' => [ 'bar(); } public function bar() : int { return 3; } } class A { use T { bar as bat; } public function bar() : string { return "hello"; } public function baz() : string { return $this->bar(); } }', ], 'aliasedPrivateMethodInternalCallWithLocalDefinition' => [ 'bar(); } } trait T2 { private function bar() : int { return 3; } } class A { use T1; private function baz() : int { return $this->bar(); } }', ], ]; } /** * @return array */ public function providerFileCheckerInvalidCodeParse() { return [ 'inaccessiblePrivateMethodFromInheritedTrait' => [ 'fooFoo(); } }', 'error_message' => 'InaccessibleMethod', ], 'undefinedTrait' => [ ' 'UndefinedTrait', ], 'missingPropertyType' => [ 'foo = 5; } }', 'error_message' => 'MissingPropertyType - src/somefile.php:3 - Property T::$foo does not have a ' . 'declared type - consider null|int', ], 'missingPropertyTypeWithConstructorInit' => [ 'foo = 5; } }', 'error_message' => 'MissingPropertyType - src/somefile.php:3 - Property T::$foo does not have a ' . 'declared type - consider int', ], 'missingPropertyTypeWithConstructorInitAndNull' => [ 'foo = 5; } public function makeNull(): void { $this->foo = null; } }', 'error_message' => 'MissingPropertyType - src/somefile.php:3 - Property T::$foo does not have a ' . 'declared type - consider null|int', ], 'missingPropertyTypeWithConstructorInitAndNullDefault' => [ 'foo = 5; } }', 'error_message' => 'MissingPropertyType - src/somefile.php:3 - Property T::$foo does not have a ' . 'declared type - consider int|null', ], 'redefinedTraitMethodInSubclass' => [ ' 'MethodSignatureMismatch', ], 'missingTraitPropertyType' => [ ' 'MissingPropertyType', ], ]; } }