Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:46690 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 61120 invoked from network); 13 Jan 2010 14:50:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Jan 2010 14:50:20 -0000 Authentication-Results: pb1.pair.com header.from=mathieu.suen@easyflirt.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=mathieu.suen@easyflirt.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain easyflirt.com designates 91.199.255.56 as permitted sender) X-PHP-List-Original-Sender: mathieu.suen@easyflirt.com X-Host-Fingerprint: 91.199.255.56 python-06.easyrencontre.com Linux 2.6 Received: from [91.199.255.56] ([91.199.255.56:39419] helo=mail.easyflirt.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C1/81-00773-AADDD4B4 for ; Wed, 13 Jan 2010 09:50:19 -0500 Received: from [192.168.0.51] (office.easyrencontre.com [78.155.152.6]) by mail.easyflirt.com (Postfix) with ESMTPSA id 6730A6374EA; Wed, 13 Jan 2010 15:50:15 +0100 (CET) Message-ID: <4B4DDDAA.4070201@easyflirt.com> Date: Wed, 13 Jan 2010 15:50:18 +0100 User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: Etienne Kneuss CC: internals@lists.php.net References: <4B4DCC64.3030703@easyflirt.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Inconsistency redesign From: mathieu.suen@easyflirt.com ("mathieu.suen") Etienne Kneuss wrote: > Hello, > > On Wed, Jan 13, 2010 at 2:36 PM, mathieu.suen > wrote: > >> Hi, >> >> I came across this: >> >> echo sizeof(array()); >> echo sizeof(""); >> $a = ""; >> > > php.net/count: > "If var is not an array or an object with implemented Countable > interface, 1 will be returned. There is one exception, if var is NULL, > 0 will be returned." > The behavior might be documenting but it does not mean that's a good thing. I don't see the point of allowing sizeof on a var that is not an array or object that implement countable. > >> var_dump( empty($a)); >> $a = array(); >> var_dump(empty($a)); >> > > php.net/empty > > empty($var) is basically an !isset($var) || !$var > > it's not related to count in anyway. > > >> So funny! How something can have a size greater than 0 but still be empty? >> I think PHP is reinventing the inconsistency word. >> > > I think such comments are pretty useless. Try coming with a viable > solution as a patch instead. > > >> But then let assume that empty is just making a cast in array. >> > > If you assume wrong, you can derive all kind of madness. > > >> $a = ""; >> empty($a) //true >> empty((array)$a) //false >> >> Ok so empty is big ugly switch case on type. >> > > No, it's a boolean check, with type juggling involed, see above. > Ho yes but type juggling is pretty mush a big switch case > >> empty(0); //true >> empty(45); //false >> >> Wooow reinventing emptiness on number.... >> >> -- Mathieu Suen >> >> >> >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> >> > > > >