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

From: Date: Mon, 11 Apr 2011 02:22:58 +0000
Subject: proposed access modifier "silent" ... was: Re: [PHP-DEV] Implicit isset/isempty check on short-ternary operator
Groups: php.internals 
Request: Send a blank email to internals+get-51857@lists.php.net to get a copy of this message
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

« previous php.internals (#51857) next »