note 50443 added to language.oop5.typehinting
| From: | ryo at magi dot shadowlair dot info | Date: | Mon, 28 Feb 2005 18:53:49 +0000 |
| Subject: | note 50443 added to language.oop5.typehinting | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-85684@lists.php.net to get a copy of this message | ||
Although type-hinting prevents null values from being passed, setting a default null value is not a
parse error.
However, calling the function with a null parameter, or calling it without the parameter (thus using
the default value) will result in a fatal error:
<?php
function foo(MyClass $object = null) {
// this is a valid function definition
}
$o = new MyClass();
foo($o);
foo(null); // fatal error
foo(); // fatal error
?>
----
Manual Page -- http://www.php.net/manual/en/language.oop5.typehinting.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+50443
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50443&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50443&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50443&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50443&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50443&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+50443&report=yes
Search -- http://master.php.net/manage/user-notes.php