Category : traits

Context: Symfony 5.1 + Doctrine 2.4 but that seems to be rather a PHP-thing. Following situation: I have two basic traits: use SymfonyComponentValidatorConstraints as Assert; trait A { /** * @AssertCallback * @param ExecutionContextInterface $context * @param $payload */ // […stuff…] } trait B { /* […more stuff…] */ } and then one trait using ..

Read more

Let’s take a simple example: trait MyTrait { public function get(): void { var_dump(func_get_args()); } } class MyClass { use MyTrait; } // Running this: (new MyClass())->get( null, ‘loads of parameters’, [‘another’ => ‘one’], static function (string $param): string { return $param; } ); // Will result in: array (size=4) 0 => null 1 => ..

Read more