,error_levels?:string[]}> */ public function providerValidCodeParse() { return [ 'accessiblePrivateMethodFromTrait' => [ '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' => [ ' [ 'foo(); } } } class A { use T; } class B { use T; public function foo() : void {} }', ], 'staticClassTraitUser' => [ 'foo(); } } } class A { use T; } class B { use T; public function foo() : void {} }', ], 'isAClassTraitUserStringClass' => [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ '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(); } }', ], 'allMethodsReplaced' => [ 'foo(); } } class C { use T; protected function foo(string $s) : void {} public function bat() : void { $this->foo("bat"); } }', ], 'aliasedPrivateMethodInternalCallWithLocalDefinition' => [ 'bar(); } } trait T2 { private function bar() : int { return 3; } } class A { use T1; private function baz() : int { return $this->bar(); } }', ], 'traitClassConst' => [ ' [ 'getConstants(); $callback = /** @param mixed $v */ function ($v) : bool { return \is_int($v) || \is_string($v); }; if (is_a($type, \Bat::class, true)) { $callback = /** @param mixed $v */ function ($v) : bool { return \is_int($v) && 0 === ($v & $v - 1) && $v > 0; }; } return array_filter($values, $callback); } } class Bar { use Foo; } class Bat { use Foo; }' ], 'nonMemoizedAssertions' => [ 'value === $this->value) {} } } } class O {} class A extends O { use T; /** @var string */ private $value; public function __construct(string $string) { $this->value = $string; } } class B extends O { use T; /** @var bool */ private $value; public function __construct(bool $bool) { $this->value = $bool; } }' ], 'manyTraitAliases' => [ 'fine(); $b->good(); Bar::foo(); Bar::foobar(); $b::foo(); $b::foobar(); $b->foo(); $b->foobar(); $b->bad();' ], 'inheritedProtectedTraitMethodAccess' => [ 'bar(); } }' ], 'inheritedPublicTraitMethodAccess' => [ 'bar();' ], 'allowImplementMethodMadePublicInClass' => [ ' [ ' [ ' [ ' [ ' [ ' */ public function providerInvalidCodeParse() { return [ 'inaccessiblePrivateMethodFromInheritedTrait' => [ 'fooFoo(); } }', 'error_message' => 'InaccessibleMethod', ], 'undefinedTrait' => [ ' 'UndefinedTrait', ], 'missingPropertyType' => [ 'foo = 5; } }', 'error_message' => 'MissingPropertyType - src' . DIRECTORY_SEPARATOR . 'somefile.php:3:32 - Property T::$foo does not have a ' . 'declared type - consider int|null', ], 'missingPropertyTypeWithConstructorInit' => [ 'foo = 5; } }', 'error_message' => 'MissingPropertyType - src' . DIRECTORY_SEPARATOR . 'somefile.php:3:32 - 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' . DIRECTORY_SEPARATOR . 'somefile.php:3:32 - Property T::$foo does not have a ' . 'declared type - consider int|null', ], 'missingPropertyTypeWithConstructorInitAndNullDefault' => [ 'foo = 5; } }', 'error_message' => 'MissingPropertyType - src' . DIRECTORY_SEPARATOR . 'somefile.php:3:32 - Property T::$foo does not have a ' . 'declared type - consider int|null', ], 'redefinedTraitMethodInSubclass' => [ ' 'MethodSignatureMismatch', ], 'missingTraitPropertyType' => [ ' 'MissingPropertyType', ], 'nestedTraitWithBadReturnType' => [ ' 'InvalidReturnType', ], 'replaceTraitMethod' => [ 'foo(); } } class C { use T; protected function foo(string $s) : void {} }', 'error_message' => 'TooFewArguments', ], 'traitMethodMadePrivate' => [ 'traitFoo(); } } class D extends C { public function bar() : void { $this->traitFoo(); // should fail } }', 'error_message' => 'InaccessibleMethod' ], 'preventTraitPropertyType' => [ ' 'UndefinedClass' ], ]; } }