Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96949 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 41577 invoked from network); 17 Nov 2016 12:59:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Nov 2016 12:59:46 -0000 Authentication-Results: pb1.pair.com header.from=morrison.levi@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.177 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.213.177 mail-yb0-f177.google.com Received: from [209.85.213.177] ([209.85.213.177:32964] helo=mail-yb0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 34/1F-05303-1C9AD285 for ; Thu, 17 Nov 2016 07:59:45 -0500 Received: by mail-yb0-f177.google.com with SMTP id a184so53163098ybb.0 for ; Thu, 17 Nov 2016 04:59:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=514eUA/oMcN+/7zqGzDmKtFsyHCBQupygDOVmMNcT4g=; b=SceWeAFxX69K1HtHPeWNbxLA0oSGWZ101kWgrt9O978uRX59Vgj4G4hIUHSX95vnnh Nxh1QVzchrj+H8WbbtLo3kKZcx0C/n+h7yuIg3ta4N9LUTYJFkueqHNJsviXrZ7SR5Rg 38T8ym/Z3Ub2bJRYI1DxeTnc0BQQCct82GJigyUj/MZUoK6qo4EoaHCEQjpRzRzPD5Pv gApjBWFquHRtnSCLEa8UEVCQkbLVcL+freb4PW2w+4spgeBBGsv/qIMMuaRi4pKTq822 cahsWnMbLDEUxHzk9K40s/7KToR11nzoAxDfGz6gaCVzcibVlxRzqzh2sRimAdIZIgqj wQLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=514eUA/oMcN+/7zqGzDmKtFsyHCBQupygDOVmMNcT4g=; b=B5nrR6RdmUeFhsag8sYy6S3RA3/TZDJFl044aUPk/c/DPnYJ7CM71Qu7iCte9RgYVo cmUOaAsNJJG/LZL+TUDDtWht7OB51LmfrId0DMPqShd+WaRtHOk/C+e6CW7Mko+Lxwx0 CpA12+XkckSf6KpCTfRyD/QeYPgZ9/DCeRZhfNueBV21DcBO+o7gTztUsNquq6juKIgI mIpsUJkUK/jIQhKeJpRpUR1Jm7t7ePTOhtO+CPDZb8pbEfeMD1Z95sW7bUWnSDV/wfJI DwfLSq/iwS2aedT2cS/GobvoWpk+GZBrUiCHoHZPng0HVlE/3/za7IgCubyvMr8kN6Ue Zl4w== X-Gm-Message-State: ABUngvcpeSt00ZWGFZeO13bV6rijt0lkq4j7VxENla5KV+JlrNEp0HJ6Djq4vTJIZEx0gRtY/kuIzNkIPZlSBQ== X-Received: by 10.13.199.193 with SMTP id j184mr2554109ywd.339.1479387582526; Thu, 17 Nov 2016 04:59:42 -0800 (PST) MIME-Version: 1.0 Sender: morrison.levi@gmail.com Received: by 10.13.235.81 with HTTP; Thu, 17 Nov 2016 04:59:42 -0800 (PST) In-Reply-To: References: Date: Thu, 17 Nov 2016 05:59:42 -0700 X-Google-Sender-Auth: h2pfsDu_1sNcYWKGDkmYgO363x4 Message-ID: To: Craig Duncan Cc: Internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Countable Type Hint From: levim@php.net (Levi Morrison) 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.