Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:46686 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 41668 invoked from network); 13 Jan 2010 13:50:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Jan 2010 13:50:25 -0000 Authentication-Results: pb1.pair.com smtp.mail=ekneuss@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ekneuss@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 72.14.220.155 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: ekneuss@gmail.com X-Host-Fingerprint: 72.14.220.155 fg-out-1718.google.com Received: from [72.14.220.155] ([72.14.220.155:56735] helo=fg-out-1718.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 95/6D-00773-C9FCD4B4 for ; Wed, 13 Jan 2010 08:50:24 -0500 Received: by fg-out-1718.google.com with SMTP id 16so53489fgg.11 for ; Wed, 13 Jan 2010 05:50:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to:cc :content-type; bh=Gs92J/mK0RxHYoXKmMHSXB3cjbbTADlwrvuYWzXJp8U=; b=ILF2iKIYhUz9MPL9ZzHdzyCRk741vv8aacexw9wx/ZZTzVUABnSgSiDjofzsg+bNRd gVe69FI2tcbDZzfzFLCvYLBDcx3D7Lt04ZQq8QFVzQuaZLLfcV7c8lQxpIys47jlyK0l GBEVdmG7MrGOGsxB1scHzr0e042uqEi/NdPa0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=l9XiIRTsHuogTb1GctVq3azN4Ipn9Gdj6D0ehQRuDY3mlw9YOpguNr6JQ3ppOXsWnk H6YIlzqoYRs2UaWSxwGvybE/zCBF/I/C3jaFoUGQJfi25GR0hQ0LwbqAS9619uMx9uVM YzaQDA597DVthlXiXM0kBKptSkn3aMhZeHJ9Q= MIME-Version: 1.0 Sender: ekneuss@gmail.com Received: by 10.86.6.30 with SMTP id 30mr910665fgf.62.1263390617591; Wed, 13 Jan 2010 05:50:17 -0800 (PST) In-Reply-To: <4B4DCC64.3030703@easyflirt.com> References: <4B4DCC64.3030703@easyflirt.com> Date: Wed, 13 Jan 2010 14:50:17 +0100 X-Google-Sender-Auth: 8145b2eb1ede1982 Message-ID: To: "mathieu.suen" Cc: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] Inconsistency redesign From: colder@php.net (Etienne Kneuss) 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." > 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. > > 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 > > -- Etienne Kneuss http://www.colder.ch