note 85906 added to language.types.type-juggling
| From: | lucazd at gmail dot com | Date: | Wed, 24 Sep 2008 04:20:17 +0000 |
| Subject: | note 85906 added to language.types.type-juggling | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-144659@lists.php.net to get a copy of this message | ||
@alexgr (20-Jun-2008)
Correct me if I'm wrong, but that is not a cast, it might be useful sometimes, but the IDE will
not reflect what's really happening:
<?php
class MyObject {
/**
* @param MyObject $object
* @return MyObject
*/
static public function cast(MyObject $object) {
return $object;
}
/** Does nothing */
function f() {}
}
class X extends MyObject {
/** Throws exception */
function f() { throw new exception(); }
}
$x = MyObject::cast(new X);
$x->f(); // Your IDE tells 'f() Does nothing'
?>
However, when you run the script, you will get an exception.
----
Server IP: 201.216.232.3
Probable Submitter: 190.225.129.104
----
Manual Page -- http://www.php.net/manual/en/language.types.type-juggling.php
Edit -- https://master.php.net/note/edit/85906
Del: integrated -- https://master.php.net/note/delete/85906/integrated
Del: useless -- https://master.php.net/note/delete/85906/useless
Del: bad code -- https://master.php.net/note/delete/85906/bad+code
Del: spam -- https://master.php.net/note/delete/85906/spam
Del: non-english -- https://master.php.net/note/delete/85906/non-english
Del: in docs -- https://master.php.net/note/delete/85906/in+docs
Del: other reasons-- https://master.php.net/note/delete/85906
Reject -- https://master.php.net/note/reject/85906
Search -- https://master.php.net/manage/user-notes.php