Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60438 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 84077 invoked from network); 3 May 2012 20:29:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 May 2012 20:29:33 -0000 Authentication-Results: pb1.pair.com smtp.mail=hermanradtke@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=hermanradtke@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.42 as permitted sender) X-PHP-List-Original-Sender: hermanradtke@gmail.com X-Host-Fingerprint: 209.85.215.42 mail-lpp01m010-f42.google.com Received: from [209.85.215.42] ([209.85.215.42:49912] helo=mail-lpp01m010-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5F/A1-08916-CAAE2AF4 for ; Thu, 03 May 2012 16:29:33 -0400 Received: by lahd3 with SMTP id d3so313541lah.29 for ; Thu, 03 May 2012 13:29:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=rWU0pK8qH2187ZIYY4tvaOYZubIf/WPmK7KD9PoPfgE=; b=xYhng7/Q3FwckZtvjhU782+0XKRSSlTN3cbdtPRrdfN8q3tuKPl8etYCB1EKTIJenS xi1OWe9VsnNQrNUQCDI77WuMCQBQz0CMKkAQojL62So7+3bh8h2xobNlUnkwt4SJ8xfW C4zAeW76P9elaq7fl98q+BnQuL23hvnMReuiLCrqoLus2LgpPW4H7nMsA9ZqDQ/j/srd egJTVsld5Ab76HmOrdL3nClIdcRANtYozNUyUSx8Vf+sdtDdDpbbtdAe7EgxpS3alr28 Ull+sbz+Zgrei7wtR86nrmJRQrtIyzgBzc1P3m3O3fe35bsEmuWpRrwhY06U1UPKOyLQ 1HTA== MIME-Version: 1.0 Received: by 10.112.88.66 with SMTP id be2mr1692857lbb.36.1336076969195; Thu, 03 May 2012 13:29:29 -0700 (PDT) Received: by 10.112.129.41 with HTTP; Thu, 3 May 2012 13:29:29 -0700 (PDT) In-Reply-To: References: <4FA23115.9030807@lsces.co.uk> Date: Thu, 3 May 2012 13:29:29 -0700 Message-ID: To: Patrick ALLAERT Cc: Lester Caine , PHP internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] Allow non-variable arguments to empty() and isset() From: hermanradtke@gmail.com (Herman Radtke) >> I just can't help feeling that it is the wrong use of both. If the funct= ion >> is returning a value, then it's returning a value that needs to be used >> somewhere so the work flow handles that. If the function returns nothing >> instead that just seems wrong and needs to be handled better. I'm used t= o >> getting back 'false' if the function failed and just check for that so w= hy >> would there be any logical reason for using isset or empty to check a >> function return? > > Use case: > > // Function definition: > function getFriends() > { > =C2=A0 =C2=A0// SQL SELECT or Fetching from XML or Fetching from LDAP or = ... > =C2=A0 =C2=A0return $resultsAsArray; > } > > // Looping on results: > foreach ( getFriends() as $friend ) > { > =C2=A0 =C2=A0echo $friend["name"], "\n"; > } > > // Case where the results are actually not iterated: > $amIAssocial =3D empty( getFriends() ); This is the exact same thing: $amIAssocial =3D !getFriends(); Earlier, I sent this to Lester only: Most people don't realize that an empty array is already falsy so they feel the need to use empty. That is the only use-case the RFC gives for making this change. From the RFC: "For example if func() is expected to return an array, it feels more natural to verify it's emptiness using empty() instead of !." --=20 Herman Radtke hermanradtke@gmail.com | http://hermanradtke.com