Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107948 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 20979 invoked from network); 24 Dec 2019 11:12:14 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 24 Dec 2019 11:12:14 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id 666162C068D for ; Tue, 24 Dec 2019 01:13:51 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp3.php.net X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_05,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: X-Spam-Virus: No Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp3.php.net (Postfix) with ESMTPS for ; Tue, 24 Dec 2019 01:13:47 -0800 (PST) Received: by mail-wm1-x32d.google.com with SMTP id q9so323321wmj.5 for ; Tue, 24 Dec 2019 01:13:47 -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=LRzrj/9u56txWoaZ8a2r1uVAsthupdSM+Ikd1FrTLgo=; b=asDRsD9LeWy6ZpxvofcproGJUDbS5horScfDGXaELS/Altd5pmxaqhwT3zKkRpFBnD xBfLQ2pOulm1+cyoSEJpaZHSHDD7YwuyCcQugbNJoRKbpnB4JN3ohm9BYs5LWYKiREb4 o3BO3vwOK7JOFiAQ7Y64EtGeC6A3ECoBNwPYMKks31AeiL0oKPrSVoO0vLKHJ8BFnqc1 0vG0EgdCFlRsG4xg6MhNcxB9HpEsj8ShXyzM7B8FLbOrqCuLkZ5ENsanT+4hkR10jFYV KSk9W+LopQVL7cbXYiDuQdZ8Sb8vu/k5svyvv4+Cba6AzRDvcgXmvwp3ndjXRo34/ee6 5hPQ== 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=LRzrj/9u56txWoaZ8a2r1uVAsthupdSM+Ikd1FrTLgo=; b=VAeaFzt5aYkirEH82SGA9HrLH4FiUmDVBTlyjjEZSepnq2DuOfPOsvspdM7iKie7dN NUcONSmfS1WEyS9SHBYq0bJ425OZZAPxrqU6mqCLzPlyh7XZ4QKcWe5cBwdGqAM5LYtD xD2wpa163TcMruAD4TJXyoApPPaXiNFaP3RIr0ANC/ot2bIilS/VlKx588NgMGITYxz7 8iArfmPHIFdw9Q/6V1oN6X0c5SCmzN6eJxitCWkgEqjQr9eHTrKWob7AKd+HTnVmOvnw 9FQ0M4v5hSD5X7IIxd6/j1PDAvEHbY6FuHdSDF6dwD4fpNOb/x3vXBqZjAq4vPdwTy4L 742A== X-Gm-Message-State: APjAAAUZEg0nDWsO8/FkdkTCnxtVVyO7Ba3gvQAQAnvCqebVxC5QiBmB TZ9EvTpdj4FlFIpb/GfUF1we5m05dh6wdP9Y+ELaK29E X-Google-Smtp-Source: APXvYqwvGFCwG2jG+DSX1/lK9otjLv+uj1KhhEfxshkgl+hXbjQ0Ndt2cLc6bzIAAciOfxrMJM/Pi782SGdHhfXY07o= X-Received: by 2002:a05:600c:290f:: with SMTP id i15mr3225035wmd.115.1577178826718; Tue, 24 Dec 2019 01:13:46 -0800 (PST) MIME-Version: 1.0 Date: Tue, 24 Dec 2019 11:13:35 +0200 Message-ID: To: PHP Internals List Content-Type: multipart/alternative; boundary="000000000000b6c1f7059a6f8f9d" X-Envelope-From: Subject: Add/enforce more strictness with additional declare()s From: kenashkov@gmail.com (Vesselin Kenashkov) --000000000000b6c1f7059a6f8f9d Content-Type: text/plain; charset="UTF-8" Hi internals, Since we have declare(strict_types=1) I was thinking that it makes sense to have declare(strict_comparisons=1) that will enforce: - only strict comparisons with === and !==, == and != should throw a parse error - in_array(), array_search(), array_keys() and similar should by default have their $strict argument set to TRUE and should throw run time error if a FALSE argument is passed. I need to do some more research in regards what else is appropriate to be enforced in such mode but wanted to hear your thoughts first. Additionally as there will be union types coming in PHP 8.0 (and we have property types in 7.4) I think now makes sense also to introduce declare(strict_declarations=1). This will enforce: - all parameters must have type as well the return values - all properties to have types too Also (not so important in my view) we could have declare(strict_classes=1) to prevent the declaration of new class properties during run time. This seems to be a source of mistakes because of mistyped property names. And lastly I would like to suggest to have declare(strict=1); which will be equivalent to the all four: - declare(strict_types=1); - declare(strict_comparisons=1); - declare(strict_declarations=1); - declare(strict_classes=1); This shorthand could include more strict modes in future if such are added - basically puts the engine in the strictest mode possible. And perhaps the following syntax looks better: declare( strict_types=1, strict_comparisons=1, strict_declarations=1, strict_classes=1, //support trailing comma too ); All of that of course for the next major version (PHP 8). Any comments are welcome. Thank you Vesko P.S. Please excuse me if this has been already discussed. In general Im following the internals discussions but may have missed something. --000000000000b6c1f7059a6f8f9d--