Re: Return type hints

From: Date: Wed, 13 Sep 2006 21:47:45 +0000
Subject: Re: Return type hints
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-25675@lists.php.net to get a copy of this message
--- Start --- class Something { public function __construct() {
    // Oops, forgot to initialise $this->something...
} public function f() {
    return $this->something;
} private $something; } error_reporting(E_ALL); $something=new Something; echo $something->f()+10; // Prints "10".
If you can't trust the return values of your methods, I would use: $var = $something->f(); if($var!==NULL){
    echo $var+10; // Prints "10".
} However, its crap like this that reminds me why I don't use PHP OOP for all my code. I can find no non-OOP code that behaves this way. Even my favorite PHP trick, using settype() to initialize vars, does not set the var to NULL. -- Brian Moon ------------- http://dealnews.com/ Its good to be cheap =)

« previous php.internals (#25675) next »