Re: [RFC] Allow non-variable arguments to empty() and isset()

From: Date: Thu, 12 Apr 2012 22:42:34 +0000
Subject: Re: [RFC] Allow non-variable arguments to empty() and isset()
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-59805@lists.php.net to get a copy of this message
On Thu, Apr 12, 2012 at 2:42 PM, Nikita Popov <nikita.ppv@googlemail.com>wrote: > > As per the comments I created an RFC, proposing to allow arbitrary > expressions to be passed to empty() and isset(): > > https://wiki.php.net/rfc/empty_isset_exprs > > The patch is available as a PR: > > https://github.com/php/php-src/pull/54 > > Nikita > > PS: I added isset() too, to address the consistency concerns mentioned on > IRC. > > Just to be clear, under the new behavior, calling "empty" or "isset" on undefined variables and undefined array indices shouldn't produce a notice when E_NOTICE is set, correct? Basically, the change isn't regressive. <?php error_reporting(E_ALL); echo empty($foo) ? "\$foo isn't set\n" : "foo: $foo\n"; # result: "$foo isn't set", and no "Undefined variable" notice. From my reading of the patch this is true, but I want to make sure I'm not missing something. If this is so, how about adding appropriate regression tests to empty_with_expr.phpt and empty_with_isset.phpt?

« previous php.internals (#59805) next »