Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51857 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 29455 invoked from network); 11 Apr 2011 02:23:06 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Apr 2011 02:23:06 -0000 Authentication-Results: pb1.pair.com header.from=dante@lorenso.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=dante@lorenso.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lorenso.com from 209.85.213.42 cause and error) X-PHP-List-Original-Sender: dante@lorenso.com X-Host-Fingerprint: 209.85.213.42 mail-yw0-f42.google.com Received: from [209.85.213.42] ([209.85.213.42:41347] helo=mail-yw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DC/00-29000-80662AD4 for ; Sun, 10 Apr 2011 22:23:05 -0400 Received: by ywh1 with SMTP id 1so2445555ywh.29 for ; Sun, 10 Apr 2011 19:23:01 -0700 (PDT) Received: by 10.236.106.198 with SMTP id m46mr5624067yhg.191.1302488581310; Sun, 10 Apr 2011 19:23:01 -0700 (PDT) Received: from Dante-Lorensos-MacBook-Pro.local (99-147-138-4.lightspeed.allntx.sbcglobal.net [99.147.138.4]) by mx.google.com with ESMTPS id p3sm2292569yhp.89.2011.04.10.19.22.59 (version=SSLv3 cipher=OTHER); Sun, 10 Apr 2011 19:23:00 -0700 (PDT) Message-ID: <4DA26602.6080303@lorenso.com> Date: Sun, 10 Apr 2011 21:22:58 -0500 Reply-To: dante@lorenso.com User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.15) Gecko/20110303 Lightning/1.0b2 Thunderbird/3.1.9 MIME-Version: 1.0 To: Internals Mailing List Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: proposed access modifier "silent" ... was: Re: [PHP-DEV] Implicit isset/isempty check on short-ternary operator From: dante@lorenso.com ("D. Dante Lorenso") 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