note 110300 deleted from language.oop5.abstract by googleguy
| From: | googleguy@php.net | Date: | Tue, 09 Oct 2012 14:29:31 +0000 |
| Subject: | note 110300 deleted from language.oop5.abstract by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-191207@lists.php.net to get a copy of this message | ||
Note Submitter: olivier at m2mobi dot com
----
Extending abstract class with override of abstract method having additional parameters with default
value works while its not documented: is it borderline?
Example
<?php
<?php
abstract class AbstractMother
{
public abstract function methodWithOneArg( $arg );
}
class ConcreteChild extends AbstractMother
{
public function methodWithOneArg($arg, $arg2="I am the additional arg default value.")
{
echo $arg." ".$arg2 ;
}
}
$child = new ConcreteChild() ;
$child->methodWithOneArg( "I am the first arg.", "I am the additional arg.")
;
echo "<br>" ;
$child->methodWithOneArg("I am the first arg.") ;
?>
Will output:
I am the first arg. I am the additional arg.
I am the first arg. I am the additional arg default value.
no error is thrown