Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96950 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45236 invoked from network); 17 Nov 2016 13:51:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Nov 2016 13:51:12 -0000 Authentication-Results: pb1.pair.com header.from=joshdifabio@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=joshdifabio@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.173 as permitted sender) X-PHP-List-Original-Sender: joshdifabio@gmail.com X-Host-Fingerprint: 209.85.217.173 mail-ua0-f173.google.com Received: from [209.85.217.173] ([209.85.217.173:33676] helo=mail-ua0-f173.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0A/9F-05303-DC5BD285 for ; Thu, 17 Nov 2016 08:51:09 -0500 Received: by mail-ua0-f173.google.com with SMTP id 20so142909441uak.0 for ; Thu, 17 Nov 2016 05:51:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qo7BRh7ctjgqYWVlvlsP171UPN5MWYM/Rd/R1M4wFok=; b=zgU3HbaCemLhYepKuZc31AJbmrVMsfrovR05QO39NiGEG1HOu1w1iAxl16w2tHKdof 7NbExEBNyb5jYFa9YEMN6Gd7O0+PSytw0GoF/9frhCzMNZOcxg9zUc55AJpNmkMzKaBj vSpRAcy44Da5RSG6eS4rcPcjgn640d17kqAsM0OxTQxEl8tSFNiVZOC2gKhVH8zFI2zS 7Gwg0f8xOtKDLx6Td09YgAQGZI00DjPEs8kb964zSOwpdjIQyoDTauX+p3GNUjsT/hho SrrAWOHQIRzlO27Yl4TIXmEjBTcAOrpOB8G2Nlkn/H6WMabrCj4JAiyUN2zoWrKJ8JDa JUkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qo7BRh7ctjgqYWVlvlsP171UPN5MWYM/Rd/R1M4wFok=; b=l89vhZ/xar7aJWZzzeo4qq+n37FFklt+zHBjO33n18ux52mR6WX+v/PJECUmK1Znmu BgfvxieVIfoXLK10x4/pbqt3Vp2HVrsYvhPsmCywlxWfrDPxdBTfXALpDm8f/WBGFfT+ KuaUAkLpYslttKcLJKtn5ZF0YujpCc6+YqSdi+jRYeKqW8BjrnmIUPMxtFh2vpMuK0iD xftzNvu8X25UC3OM4uA/2TXwnNpo6+Ycc2PuAzQ1EII9K8wJ5Y40rpDfZPrTPjw9I/yP qU4dGVoQRLOXygFNdocn7PM1qqoL4t9T06mDnj6m/SD4IQM/x9Pu9WFtxXJ7N+fL58D1 p+rg== X-Gm-Message-State: AKaTC02vnSOcOo3yLRTMRKgxFmkOAJNxTZ+3U5RCMVaiNzUKT8bznnVLfdzDEcGuZuYtqRv3bdLagJ9dURtTvQ== X-Received: by 10.159.40.97 with SMTP id c88mr1779876uac.17.1479390666694; Thu, 17 Nov 2016 05:51:06 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 17 Nov 2016 13:50:56 +0000 Message-ID: To: Levi Morrison , Craig Duncan Cc: Internals Content-Type: multipart/alternative; boundary=94eb2c0483c02c26c605417f7bac Subject: Re: [PHP-DEV] Countable Type Hint From: joshdifabio@gmail.com (Josh Di Fabio) --94eb2c0483c02c26c605417f7bac Content-Type: text/plain; charset=UTF-8 On Thu, Nov 17, 2016 at 1:00 PM Levi Morrison wrote: > On Thu, Nov 17, 2016 at 5:52 AM, Craig Duncan wrote: > > Hi everybody > > > > Following on from the recent rfc for *count()* ( > > https://wiki.php.net/rfc/counting_non_countables) and the one for > *iterable* > > (https://wiki.php.net/rfc/iterable) it would be useful if there was a > > `countable` type hint: > > > > function foo(countable $thing) > > { > > if (count($thing) > 0) { > > # ... > > } > > } > > > > However I think this it is much more useful when combined with > *iterable*, > > maybe something like (arraylike = iterable && countable) > > > > function handle_records(arraylike $result) > > { > > if (count($result) === 0) { > > handle_empty(); > > return; > > } > > > > foreach ($result as $value) { > > handle_value($value); > > } > > } > > > > Does anybody have any thoughts on this? > > Should I bring *countable* to RFC? > > Should I bring *arraylike* to RFC? > > > > Thanks, > > Craig > > It's definitely not doable with the name `countable`. > Class/Trait/Interface names are case insensitive. This means > `countable` already has meaning and it is unambiguously the interface. > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php What's the benefit of such an interface? Why not simply ask for `int $count` in your param list instead? --94eb2c0483c02c26c605417f7bac--