Re: [RFC] Property Accessors v1.2 : isset / unset "failable"

From: Date: Sat, 27 Oct 2012 17:39:27 +0000
Subject: Re: [RFC] Property Accessors v1.2 : isset / unset "failable"
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-63667@lists.php.net to get a copy of this message
That's basically what #2 is getting at, my only question is, emit a warning or notice or not? Technically returning false on an invalid isset() call could be misleading without emitting some kind of notice or warning about it. On 10/26/2012 9:56 AM, Stas Malyshev wrote:
Hi!
  1.      If all cases can be tested for during compilation, prefer
     compile failures.
Not likely. isset($foo->$bar) is completely opaque since we don't know what $foo or $bar is.
  2.      Let the compilation occur and at runtime when a disallowed
     action is attempted, emit a warning and move on.
  3.      As is currently, either at compilation or at runtime we issue a
     fatal error and stop execution (probably least preferable if at runtime)
Actually, I think the right way is: 4. On isset(), if the value can be retrieved, return true. Otherwise, return false (including the case when the value can not be retrieved because of missing getter). Same holds for empty() but in reverse - if isset() would return false, it'd return true and vice versa. On unset($foo->bar), act exactly as if the code were $foo->bar = NULL; Of course, this applies only for automatic definition of isset/unset.
-- -Clint

« previous php.internals (#63667) next »