Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108175 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 71192 invoked from network); 17 Jan 2020 09:43:29 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 17 Jan 2020 09:43:29 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 78A1B180505 for ; Thu, 16 Jan 2020 23:51:00 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_05,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 16 Jan 2020 23:50:56 -0800 (PST) Received: by mail-lf1-f54.google.com with SMTP id l18so17620565lfc.1 for ; Thu, 16 Jan 2020 23:50:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=M6ZbRr6/R+XVC8bDWOxDWSCMsCKYBMeaFz3M9ZzmAu0=; b=ZvMasRjGAt3SdaG0ujFaSiJvwXsVydLTyojCHuhhEltMiva0Of5Qg/t98yikoCTF3c sw7H/ubuFVErQH1Wj2Hz+aMjlBuURK2dM7PC1nyc3IV/BnWeXeJms9ZPz47ewjxszgMY rPRAy36RQ42Ak4qNOAyR93iABkPE2W711XQlFMXwHxgxMhDfPjX9MT9t5bnSAk5C0xV0 AyjVcCYiuBDu2j8npuE1souILc6ZzaNRyb9ZSNcdGXWP9oJQZLCbO/P8TCG1yTVCWklc E7TEbAJK3et4v7p7TaBBmJwvWJvbhtx/au1Dyd0Uv3IG2ZQSsDaDKWC8D9i3PKBtQceM zmZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=M6ZbRr6/R+XVC8bDWOxDWSCMsCKYBMeaFz3M9ZzmAu0=; b=MwmkB/IEaK2dW0QE6N6yGwE94C2hRy6NdHmK1SkKmi7Mg7tk8gcbH+0qEEDHgAO4C2 xYC0zo5h/DY8GJjXzopFVS5gE7skyLdrmYeLv6fjmh6rm1AsO443wgeTcE2RTCEf9dl1 PzxZO1BMMoZ+t5fUwHLhOzRzoC2wDsCiTE7EOBxxdhkLJMGwYK1EvIOu6njm1eMQEM5k JbqP7/Wgz9mWKdaBE/MRdFbh4QafQqbmiTTNPJxkDDQseQLFw4V7AebKY0rVOPpUoio8 8rIosyCtQgVq0yKyz04noAEiw0f3g7mtAyEdtKXmCCbYLyhjJLV49nOohilw1tD2GHp6 vqfA== X-Gm-Message-State: APjAAAXIL3MsO3no8KGjp/cvtDUBG7kNMnW9RiI1QmcxWZMvZnj/LN/a yJhadmzHaRWqGIQH+ckhPwsUZjtVqpKCNiAhekRoAQ== X-Google-Smtp-Source: APXvYqyy3aNE3S5Qii+csu5uOrg2P2FKMciEiQzCbQvhNAv4nnXtjKCG52SXR6NkDggn5kil4sCSbiBfpgbYQByqxLE= X-Received: by 2002:ac2:5147:: with SMTP id q7mr4708755lfd.87.1579247451934; Thu, 16 Jan 2020 23:50:51 -0800 (PST) MIME-Version: 1.0 Date: Fri, 17 Jan 2020 07:50:40 +0000 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary="00000000000062a3c3059c51331a" Subject: Typed array properties V2 From: cdtreeks@gmail.com (Aran Reeks) --00000000000062a3c3059c51331a Content-Type: text/plain; charset="UTF-8" Hi Internals, I'd like to kick off a conversation to capture everyone else's thoughts on tweaking / improving typed properties for arrays (for a PHP 8.x release). With all the work done lately to greatly improve the type support in PHP (which is amazing by the way), I'm finding for the most part, I'm no longer needing to Docblock as much of my code which is lovely. That said, there's a common use case that keeps me going back to them which I think would be a good thing for PHP to try and solve as a language feature - better typing of arrays to type their properties. IDEs like PHPStorm handle this structure already hence sticking to that as a starting point... @returns []int This would designate the return of an array where all its keys are that of the int type, but it works for any type. With that in mind, it might also make sense to allow a shorthand array alias for array types anyway - array -> []. To use actual PHP examples, this would mean the following would be supported: // Typed array properties ...values would follow any existing PHO type function returnsIntArray(): []int; function returnsClassArray(): []Class; // The same outcome function returnsArray(): array; function returnsArray(): []; I welcome all your thoughts on this proposal. Many thanks, Aran --00000000000062a3c3059c51331a--