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