Re: Method check - Can someone create a RFC for it?
| From: | Sanford Whiteman | Date: | Wed, 20 Mar 2013 18:49:46 +0000 |
| Subject: | Re: Method check - Can someone create a RFC for it? | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-66726@lists.php.net to get a copy of this message | ||
> Create something like $foo->bar?() or $foo->bar()?, where you don't
> care whether the function exists, or if $foo is an object. If it
> doesn't exist you just return null.
[1] Don't do this.
[2] What everyone else said.
[3] If you feel you must, this at least "colors within the lines" a
bit more than '@' by forcing you to set a class as wildcard-able:
class bitbucket {
function __call($name,$arguments){
return "default value";
}
function __get($name){
return new self;
}
}
class myClass extends bitbucket {}
$myInst = new MyClass;
print $myInst->noExist->nexistePas(); // "default value"
[4] Goto [1].
-- S.