Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96948 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 39911 invoked from network); 17 Nov 2016 12:52:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Nov 2016 12:52:40 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@duncanc.co.uk; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=php@duncanc.co.uk; sender-id=unknown Received-SPF: error (pb1.pair.com: domain duncanc.co.uk from 74.125.82.44 cause and error) X-PHP-List-Original-Sender: php@duncanc.co.uk X-Host-Fingerprint: 74.125.82.44 mail-wm0-f44.google.com Received: from [74.125.82.44] ([74.125.82.44:37983] helo=mail-wm0-f44.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 28/BE-05303-618AD285 for ; Thu, 17 Nov 2016 07:52:39 -0500 Received: by mail-wm0-f44.google.com with SMTP id f82so144108159wmf.1 for ; Thu, 17 Nov 2016 04:52:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=duncanc-co-uk.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=0al6Gj89d6uu3sXD9WQa0kSrnryaXiw+bx/zVoalWeQ=; b=ADyOYJJRpAZlZh5tixMAfsB0q1NJN+QJsjn4OuVlKAgy0pvhXRhZoYbkKyYdVIlxm0 9WcRbNxakUAmNgxBgDP4dsA0pntmuVJLJ78oZ55Zbq/XlMv+yfqz0FdpKGkr8YyR+tJX dyMDKqoxMJDY4dNaIACM18gnLKUwhv8qkTizbxgwNv80WpgVQ86fAfkF1GtWJMijPyCa LAOSNrWqhNiZ7Ym+uVUhZloPEoawrwF8LFHe5mceQBDaNyNv5LgSNVIZabx4EtiviDA8 VCXePa869niJiYOCQDIAnRnhtV3JN/li0KK8XmL2y7RDyeErfda6Q8N5HIMk4nDwG6GO 7UoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=0al6Gj89d6uu3sXD9WQa0kSrnryaXiw+bx/zVoalWeQ=; b=eIW6TOmIHHWjOw4+sfblv9X/az6es0xzY4C67m/Y8jNdBd9+H8wlqp85HU2sAHnRSw +oXQN8m2xTd7euRINIf3D160qEqyplMxAbGWieB7zN5Xz1IAvPvIFz2jBGi2pHJl+a6q OfNqyaJRvqpQyqgLNRMD8hsy8Cq/Dd7jgQMGeEkOWbvi+cTWZigaUfQKj/nPvAydQ2AF xjkT243FlPmhOxmecErrxUMzy4Dh7qXc1PcfVYQ6Oc2zzBKAE2Eq1xBnCKVG1WU0HfcZ R+RveKQtzxTOpgKfS9VaXB0redxrRf49UsSVdFwdF/SMu8u8rDSYDaop3aOPqn9wjGL6 N4nA== X-Gm-Message-State: ABUngvfAeQcmLMA+E4w8zyk+6EPEcGHbUvzRjC/vX3hpTF9bpMCB4drmRKaqtMnBSNN4FQ== X-Received: by 10.28.227.9 with SMTP id a9mr4285317wmh.85.1479387154444; Thu, 17 Nov 2016 04:52:34 -0800 (PST) Received: from mail-wm0-f54.google.com (mail-wm0-f54.google.com. [74.125.82.54]) by smtp.gmail.com with ESMTPSA id c81sm3605275wmf.22.2016.11.17.04.52.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Nov 2016 04:52:33 -0800 (PST) Received: by mail-wm0-f54.google.com with SMTP id a197so308610869wmd.0 for ; Thu, 17 Nov 2016 04:52:33 -0800 (PST) X-Received: by 10.25.21.205 with SMTP id 74mr479514lfv.138.1479387152691; Thu, 17 Nov 2016 04:52:32 -0800 (PST) MIME-Version: 1.0 Received: by 10.114.202.135 with HTTP; Thu, 17 Nov 2016 04:52:32 -0800 (PST) X-Originating-IP: [195.99.194.20] Date: Thu, 17 Nov 2016 12:52:32 +0000 X-Gmail-Original-Message-ID: Message-ID: To: Internals Content-Type: multipart/alternative; boundary=001a11408008b8d4fc05417ea9e1 Subject: Countable Type Hint From: php@duncanc.co.uk (Craig Duncan) --001a11408008b8d4fc05417ea9e1 Content-Type: text/plain; charset=UTF-8 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 --001a11408008b8d4fc05417ea9e1--