Cannot redeclare %s::%s()¶
Description¶
Each method in a class must have a distinct name. There can be not two methods with the same name.
The parent classes, or the traits, may have duplicate methods: these will be ignored.
One special case are the enumeration: the backed enumeration, with their type, import two methods to convert a value into one of the case: try
and tryFrom
. Then, these two methods are part of the definition of the enumeration, and it is not possible anymore to define them in the enumeration.
Example¶
<?php
class X {
function foo() {}
function foo() {}
}
enum E {
function try() {}
function tryFrom() {}
}
?>
Literal Examples¶
Cannot redeclare X::foo()
Cannot redeclare X::try()
Cannot redeclare X::tryFrom()
Solutions¶
Remove one of the duplicate function.
Rename one of the duplicate function.