website/errors/trait.duplicateMethod.md
<?php declare(strict_types = 1);
trait MyTrait
{
public function doSomething(): void
{
}
public function doSomething(): void
{
}
}
class Foo
{
use MyTrait;
}
A trait declares the same method more than once. PHP does not allow two methods with the same name in a single trait. This is a fatal error.
Remove the duplicate method declaration, keeping only one:
trait MyTrait
{
public function doSomething(): void
{
}
-
- public function doSomething(): void
- {
- }
}
If the duplicate methods were intended to have different behavior, rename one of them:
trait MyTrait
{
public function doSomething(): void
{
}
- public function doSomething(): void
+ public function doSomethingElse(): void
{
}
}