Re: [RFC] Property Accessors v1.2 : isset / unset "failable"
| From: | Stas Malyshev | Date: | Mon, 29 Oct 2012 19:14:44 +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-63705@lists.php.net to get a copy of this message | ||
Hi!
> 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? */
isset should return false, since $b is not set value. It should not
produce any warning. Of course (int) would produce 0 then ;)
> I mean specifically, there is no getter defined, therefore the result
> if isset is indeterminate and while I can see it not causing execution
No, the result is determinate - it's false. That's the point of isset()
in PHP and that's how it is used in existing code.
> 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).
isset() should always be legal. This is the way to check if $o->b is legal.
--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227