I’m working with a basic class library where the parent class has a function…
function functionName($param) {
}
Then, in a child class extending this class I have…
function functionName($param, $param2, $param3) {
}
When I make calls using this child class, I end up with the following PHP notice…
Declaration of child_class::functionName() should be compatible with
that of parent_class::functionName()
The code still completes successfully, but the notice worries me and I’d like to get rid of it. I’ve found that if I add the additional parameters to the parent class’s version of the function then the problem goes away. These parameters are not necessary anywhere except for the in the extended class, though, so it seems strange to have to add that…doesn’t it?
Is there a better way to fix such an issue, or should I just make sure to add those same parameters in all instances of this function regardless of whether or not that particular class would actually need it?
Any information on this would be greatly appreciated. Thanks!
you need to have the exact same signatures if you’re inheriting a class.
A quick workaround can be done using func_get_args: