Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96955 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 54092 invoked from network); 17 Nov 2016 14:59:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Nov 2016 14:59:49 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.192.182 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.192.182 mail-pf0-f182.google.com Received: from [209.85.192.182] ([209.85.192.182:32783] helo=mail-pf0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E5/41-05303-4E5CD285 for ; Thu, 17 Nov 2016 09:59:48 -0500 Received: by mail-pf0-f182.google.com with SMTP id d2so49848757pfd.0 for ; Thu, 17 Nov 2016 06:59:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=dG6DZo8Y3Gf85d9JsQEFMQBeE2vigDIX+2k6OxSCVdw=; b=LXM8OWayOOMSb0W7UP+u+5nAIjejTeU174BuXorKf40fvi2sDRHWzX4kWkP0YlE0uK 07bfXH0mh6s+mkdYLjC/tvaDnH5O5d4ogyXEOAuAU6wus9CWfuORpHWweos9DwRilokI 5JUipdB2maMdjZ3eFEum8D65AfSj25oblA4Ewy5MPZdl0AqGQ3PfQfR7wOSNU/4aLL6l nIRF4PYvwjB6HnnC2bJvJFpjEeE8UAG4m3MGc27wpEqwIZRTsLVxIRrUVXHuzR7Nvx/k tSlytjF07GFcuQjskpV8miKcdf545h3Bia0FuF2ylWTnlZYmKplin0cKIUnWpz/2kmC0 86ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=dG6DZo8Y3Gf85d9JsQEFMQBeE2vigDIX+2k6OxSCVdw=; b=L8VYiVofb6Ynib1EgA9i2c9LpounICwmvYwK5kHUxcLiNkksGHvViO3mvt04d4ZAD9 vXwNKmeRF18ALKNCecs/HxZEBVlooDa29TisqjSmkss0SJpj1PBDHxkVQxJEHkGntowT NzzskC9WSXI61fhNJ3tnGQFSzrQWE4tZ0koMdYvL95fRWOgSI51LtRfY1QdEltXl4lb6 j2DvvLJIRSV3ygfGB7x7IoTra94/h+x3+51vRSW9lErJzAUnp2MiCNqf0UJPxLKZ8t1C QvyMd+68W9+DOv8pn7D8W6j42TqPG9a7t/KHmxYkq9lwVJ1CxrHIOapu1nUZJJzY5cmu GftA== X-Gm-Message-State: ABUngvf9gUS3eOxSPxx6spIT86CRWB/Xavg4CM3TetVe54TaoNZ2pvTUgT5YerFgu+lq5w== X-Received: by 10.98.80.140 with SMTP id g12mr5398918pfj.54.1479394785158; Thu, 17 Nov 2016 06:59:45 -0800 (PST) Received: from [192.168.0.67] ([93.188.182.58]) by smtp.gmail.com with ESMTPSA id 24sm8575096pfh.41.2016.11.17.06.59.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Nov 2016 06:59:44 -0800 (PST) To: internals@lists.php.net References: Message-ID: Date: Thu, 17 Nov 2016 14:59:10 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Countable Type Hint From: rowan.collins@gmail.com (Rowan Collins) On 17/11/2016 14:06, Josh Di Fabio wrote: > Apologies, I thought you were simply proposing the following: > > interface Countable > { > function count(): int; > } No, what Craig is proposing is a type hint that covers both the existing Countable interface and primitives which are naturally countable. If the union types RFC had passed, you'd be able to say "array|Traversable $foo"; a recent RFC lets you instead say "iterable $foo". The suggestion is to add a keyword which similarly acts as "array|Countable $foo". Unfortunately, as others have pointed out, it can't be called just "countable", because that's the name of the existing interface. The principle seems sound though, assuming we don't want to go down the route of treating arrays as implementing interfaces. Regards, -- Rowan Collins [IMSoP]