Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51864 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26050 invoked from network); 11 Apr 2011 17:17:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Apr 2011 17:17:39 -0000 Authentication-Results: pb1.pair.com smtp.mail=dmgx.michael@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=dmgx.michael@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.170 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: dmgx.michael@gmail.com X-Host-Fingerprint: 74.125.82.170 mail-wy0-f170.google.com Received: from [74.125.82.170] ([74.125.82.170:50865] helo=mail-wy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id ED/30-24294-2B733AD4 for ; Mon, 11 Apr 2011 13:17:39 -0400 Received: by wyb34 with SMTP id 34so5351186wyb.29 for ; Mon, 11 Apr 2011 10:17:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=HAKxXtLEHUS0zMYN8jOwsBJaJ9+OtpJ9cp4LBmiSNaQ=; b=YdKIEou68n7uIoTjhFXLi9DHPLsfhgK+LWtgzP4uEsv7+dzuebyzlErwUDtRzUhfNx QUT8XayPv87VCuW7sSV5R7YYViCv0uCOd+UZw7zItMjW5ujYRZxlM9Tn+VXRHypyilZi qnbeV2SOzqrHjbWshG9QnPebA0ORy8FxaHX5w= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=hUCrIYXE39ON9bdWPRMwRQpvvN9ASZLfOgFGw0PZT3eoZPmKHgREVXKny8WUtVaaNh l+PPWmc+lVvIk+px5sCCp5SwzwlUNzPJF6GR+m8UfvLnn7hxSXZZ8lB26nCV8Xyu0PQf JKugD693ccW50pnfCozS+fg/+VZ3YxEbkhEQ8= MIME-Version: 1.0 Received: by 10.216.145.200 with SMTP id p50mr2975582wej.79.1302542255971; Mon, 11 Apr 2011 10:17:35 -0700 (PDT) Received: by 10.216.17.66 with HTTP; Mon, 11 Apr 2011 10:17:35 -0700 (PDT) In-Reply-To: <20110411133657.GK7113@crousti> References: <4DA26602.6080303@lorenso.com> <20110411133657.GK7113@crousti> Date: Mon, 11 Apr 2011 13:17:35 -0400 Message-ID: To: Internals Mailing List Content-Type: multipart/alternative; boundary=0016e6d58d4478e03704a0a7c056 Subject: Re: [PHP-DEV] proposed access modifier "silent" ... was: Re: [PHP-DEV] Implicit isset/isempty check on short-ternary operator From: dmgx.michael@gmail.com (Michael Morris) --0016e6d58d4478e03704a0a7c056 Content-Type: text/plain; charset=ISO-8859-1 I might come off rather crumudgeonly here, but these last few threads I've seen going across to silence notices have a common theme - "I wanna be a lazier coder." Which is fine - set the PHP error level to not show them. But don't ask the engine to be rewritten to encourage bad coding practices which failing to properly initialize variables is a prime example of. It's this sort of thinking that got register_globals and magic_quotes put into the language no doubt. In the long run it's an extremely bad idea and needs to be avoided. -1 On Mon, Apr 11, 2011 at 9:36 AM, Etienne Kneuss wrote: > On Apr 10 21:22:58, 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: > > Short answer is no. See below. > > > > > 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. > > This is not really possible without some major changes. You've to > understand that arguments are evaluated before the function/method call. > The notices are thus emited before even considering the function/method > call. > > This is exactly why isset and empty are not functions, but language > constructs, so that they can work with variables in a special way. > > > > > 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 > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --0016e6d58d4478e03704a0a7c056--