Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101035 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 32369 invoked from network); 2 Nov 2017 22:22:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Nov 2017 22:22:50 -0000 Authentication-Results: pb1.pair.com smtp.mail=tendoaki@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=tendoaki@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.161.172 as permitted sender) X-PHP-List-Original-Sender: tendoaki@gmail.com X-Host-Fingerprint: 209.85.161.172 mail-yw0-f172.google.com Received: from [209.85.161.172] ([209.85.161.172:45990] helo=mail-yw0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7D/E6-09857-9BA9BF95 for ; Thu, 02 Nov 2017 17:22:50 -0500 Received: by mail-yw0-f172.google.com with SMTP id j4so935308ywb.2 for ; Thu, 02 Nov 2017 15:22:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=j+MbrILSPQ0pEvqtp4t2JdsGfWkLjvU4P0KVIlRfyuY=; b=RD9uFJDVggm+nStJ5h38G26qMS2stR7uyjQYzHeJqygW8t3PiDEvMSRJRra4zfKb9+ GI+EA1QWI4f2FdTl+xhSU9DgzcXXmRoJwyORjwM6pFXGB9LkTsC9zcFh9keU0Fb92x9A +5ZVFCz1VoHLgoElSm7BZXF4Rjw+4W2yR7As9q90KcLSA531BF54VpbQ7E5ID/Jm2I1H EkqC80ls+DE3qbFBhFY5ro/OJL8sVGQ6E95/ytKod8sCPCQZtT3+9hrawW8/8FlF1ygf QYjopuKQA30JVC5eG4ppD8L7T/XrQtWt127u6DyHI0u7ZfrszxB8ddT5XiykVHodcrLh hbdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=j+MbrILSPQ0pEvqtp4t2JdsGfWkLjvU4P0KVIlRfyuY=; b=VaFOIIjLeZa6JLLfLEjP5Szbq66iuwAZzeBkYfr8lM9ijc75Cz8CP/PQm6TWNKnnFB xpzWKQAAhm5KWswccmowHjcJHA5E46iNdMqRL/j2JJkE0/01R0eeAiKtF5S5Vj0w5AfM vD1Iq6KT8tXQpJZ7wO5s1R/ptN2Lh7Z7STITztF64z6o2B0w7qSFHU4e7nBJiUw16x3v nr3l1XVEjuPUaQzkg8ga8TQgyLxmyJmFpf4skDXyeZfwPdQAeA3/6rm8uHxrhzrMbALw OdsBg0fobiVBr6awURgG7iIsJVLpHepDNtPrXAw96AOSyWHaJWs8rGnUmT6nOiNJ97Of hcLg== X-Gm-Message-State: AMCzsaX1vAPj6JyO2xZ8TarTFJ34HooUKZNDC9MATdEHjPXwrK9Y0iDK PQVudQ94dazYlgVrHaZBrhObn+c0fJyQipLcYT4= X-Google-Smtp-Source: ABhQp+TeVtNQula2yXZ+sLeX0EpClq3yvaNWC4hDHTv4cX7vGZ+yxQLChQo0sXcxiE2I7kzjm2LwFLgLrWtVt3J82X8= X-Received: by 10.37.96.198 with SMTP id u189mr3375489ybb.516.1509661366931; Thu, 02 Nov 2017 15:22:46 -0700 (PDT) MIME-Version: 1.0 Received: by 10.37.139.141 with HTTP; Thu, 2 Nov 2017 15:22:46 -0700 (PDT) In-Reply-To: <2ddc5a35-6117-2507-2759-71f7996797c8@garfieldtech.com> References: <2C3A2443-8680-4FA7-BD25-872472506D03@gmail.com> <2ddc5a35-6117-2507-2759-71f7996797c8@garfieldtech.com> Date: Thu, 2 Nov 2017 18:22:46 -0400 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="001a1143f5de81d396055d076d8d" Subject: Re: [PHP-DEV] RFC - Array Of for PHP 7 From: tendoaki@gmail.com (Michael Morris) --001a1143f5de81d396055d076d8d Content-Type: text/plain; charset="UTF-8" On Thu, Nov 2, 2017 at 3:21 PM, Larry Garfield wrote: > > While I normally strongly agree with supporting all traversables, not > just arrays, in this case I don't think it works. Hmm.. You're right. Traversables would be best served by having another method to indicate their return type as part of the interface. Adding this to the existing traversable interface would be BC breaking. A new interface would be best and having another interface isn't without precedent - countable already exists. This new interface would the PHP engine on what to do. So, what about this syntax $a instanceof string[] If the engine sees this and it's an array, all the values are checked to see if it's a string. Else if $a references a generator, the return type definition of the generator will be checked, and a failure will occur if the generator doesn't declare its return type. Else if $a references an object and that object implements the SingleReturnType* interface then the method of that interface, getReturnType() is queried and it's return is checked to see if it matches. In the above case 'string' would need to be returned. I leave it to people smarter than me to find the holes in the above, but this moron thinks it might work. * Someone smarter than me can come up with a better name too :P --001a1143f5de81d396055d076d8d--