Re: proposed access modifier "silent" ... was: Re: [PHP-DEV] Implicit isset/isempty check on short-ternary operator

From: Date: Mon, 11 Apr 2011 02:35:04 +0000
Subject: Re: proposed access modifier "silent" ... was: Re: [PHP-DEV] Implicit isset/isempty check on short-ternary operator
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-51858@lists.php.net to get a copy of this message
@. On Apr 10, 2011, at 9:22 PM, D. Dante Lorenso wrote: > The problem with implementing "ifsetor", "filled", or "??" in > userland is that the "not set" or "undefined" warning is fired before the > variable is passed to the underlying function/method. > > Is it possible to add a modifier that turns off warnings for undefined variables whenever that > specific method is called? Something like: > > class Utility { > public silent function filled() { > $args = func_get_args(); > foreach ($args as $arg) { > if (!empty($arg)) { return $arg; } > } > return false; > } > } > > $x = Utility::filled($my_undef, $x['undef'], $nosuch, 'default'); > > The modifier "silent" will turn all undefined or "not isset()" variables > into NULL values when being passed to the method and no warnings will be issued. > > Then, we can build our own damn functions as we see fit without the fuss. > > -- Dante > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.internals (#51858) next »