Re: [RFC] Property Accessors v1.2 : isset / unset "failable"
| From: | David Muir | Date: | Mon, 29 Oct 2012 01:57:16 +0000 |
| Subject: | Re: [RFC] Property Accessors v1.2 : isset / unset "failable" | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-63698@lists.php.net to get a copy of this message | ||
On 29/10/12 03:02, Clint Priest wrote:
So... to be explicit here, you think in this situation:
class a {
public $b {
set($x) { $this->b = $x; }
}
}
$o = new a();
if(!isset($o->b)) {
/* delete files */
}
echo (int)isset($o->b); /* This should return false and not emit any sort of warning/notice? */
I mean specifically, there is no getter defined, therefore the result if isset is indeterminate and while I can see it not causing execution to stop I don't see it being a good idea to not warn the developer that what they've attempted is not correct. Without a getter, isset() is not a legal call (since the value cannot be retrieved).
I agree with Pierre, isset() should never throw a warning/notice. The primary use of isset (that I've seen in various code-bases) is to avoid warnings/notices. Only rarely do I see it used in an expression to control application logic. The above example should not give a warning, and should return false. As far as an application is concerned, $o->b doesn't exist because it can't be read.
David