It appears (PHP 5.3) that if you are overriding a class method, it is okay to you can add additional parameters, as long as they have default values.
For example, consider the class:
class test1 {
public function stuff() {
echo "Hi";
}
}
The following class extends "test1" and will produce an E_STRICT warning.
class test2 extends test1 {
public function stuff($name) {
echo "Hi $name";
}
}
But, the following does not produce an E_STRICT warning.
class test3 extends test1 {
public function stuff($name = "") {
echo "Hi $name";
}
}
While class "test3" doesn't produce an E_STRICT warning, I have been under the impression that PHP does not allow method signatures to be overloaded overridden. So, I have to ask. Is my observation a bug/flaw or actually correct intended behavior?
Further, if a default argument parameter is okay, why is a non-default argument parameter not okay?