Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108236 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 82232 invoked from network); 24 Jan 2020 23:33:34 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 24 Jan 2020 23:33:34 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 374A91801FD for ; Fri, 24 Jan 2020 13:43:04 -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=-1.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RDNS_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS701 96.241.0.0/16 X-Spam-Virus: No X-Envelope-From: Received: from nebula.zort.net (unknown [96.241.205.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 24 Jan 2020 13:43:03 -0800 (PST) Received: from [10.0.1.2] (pulsar.zort.net [96.241.205.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by nebula.zort.net (Postfix) with ESMTPSA id DD09B2006B4CA; Fri, 24 Jan 2020 16:43:02 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.11.0 nebula.zort.net DD09B2006B4CA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zort.net; s=zort; t=1579902182; bh=aekM6hZUuOPg8VAk4jA+Psx5dakE9OThj1E9ShOYmc4=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=IPFsKZ/tCpsbcN2RwWLp4zpulaSvrdYQd09uQkT3rFBDKSHReotQu2umiUDVR08aV R3BbKTpw9ukWO26hjYKS0bOmJdRPAnCn0TZAb765RKLtSuiltSx13jW3e2xcqNFwBj V7KKF//pwLcslYHM7jVrclimBalH6Wz9dCN8D/ac= Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3608.40.2.2.4\)) In-Reply-To: Date: Fri, 24 Jan 2020 16:43:02 -0500 Cc: Nikita Popov , Aran Reeks , PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: References: To: Mike Schinkel X-Mailer: Apple Mail (2.3608.40.2.2.4) Subject: Re: [PHP-DEV] Typed array properties V2 From: jbafford@zort.net (John Bafford) > On Jan 24, 2020, at 14:27, Mike Schinkel wrote: >=20 > Thus far we have discussed that implementation of type checking for = arrays would be too costly from a performance perspective and that there = is no good solution that is not extremely complicated to implement. >=20 > Given that, can we consider an alternative? =20 >=20 > ALLOW the use of a syntax for typed arrays =E2=80=94 whether it be = type[] or [type] =E2=80=94 but only validate that it is an array and = that the "type" is in fact a type, but don't actually validate that each = element is the correct type.=20 >=20 > This would allow those of us who want to start documenting specific = usage using type hints to be able to do so instead of what we currently = have to do is PHPDoc one way and type hint with "array." It would also = allow IDEs like PhpStorm to add support. =20 >=20 > Is this something the PHP community would consider? >=20 > -Mike My opinion is that if you're going to declare the type of a variable, = you have to have some way of enforcing that the type _really_ is what = you say it is. Otherwise, the type information is basically a lie, and = you're much better off without it. If PHP's type system can't or won't = enforce the type fully as declared, then it's much better to have = phpdocs that assert what the type "really" is, like we do now.=20 I have some ideas on what might be reasonably performant array type = enforcement, but having not fully read the thread, I'll keep that to = myself until I have a chance to see that I have anything that's actually = novel. -John