Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109502 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 18224 invoked from network); 2 Apr 2020 09:48:12 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 2 Apr 2020 09:48:12 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A6B591804E2 for ; Thu, 2 Apr 2020 01:14:47 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,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-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (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, 2 Apr 2020 01:14:46 -0700 (PDT) Received: by mail-lf1-f51.google.com with SMTP id t11so1958552lfe.4 for ; Thu, 02 Apr 2020 01:14:46 -0700 (PDT) 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=3WbNqVi3rJ/D+lF9AGEkG7gus0L3xaxfQyy+1jvrb5U=; b=r1pksLhwnIv/q4uDGpcdcAgwc1+iseXSfZRrXei1vYiX0UDCJNx3G7CUwRQkCymXFu N4Q3i6AWbLSeYQvKKrKimIMcgd2GSgq1Aeof0mX4HJgZjDQn+M25Yc9Vpn/CiSV3w8gP eUFuqJX0OxBoBQL/QR/i6xcSEzX/rmU/RS6SHb1576564uPwRJ2vF5SZiqr1h7z025ST nCGi151vqwNKNyVYFbPsgd9PLrED9PD4mAJ8iBbSFlR0m3et1zoYJ+evbmbffcmY/uD2 OOPAifGv54hoTaQNX/RjILtT2GpsqOKbANrgKS1yysVJ6N1Pc79TfYCLmZkaai3dRn5x pl6g== 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=3WbNqVi3rJ/D+lF9AGEkG7gus0L3xaxfQyy+1jvrb5U=; b=lXeZ19OVZm2Q35NNGeGsp/zBcBIX0ESbg4oMvoeDagn673CxtgLx2fm8lXIvV+psWU xMfhXJHlaHlPC3ieK1J+dHIA6FvMYlZYEoHSgpZoFi18QUjgTGO/sKSVMC2xiKkDLiGR ks2+hxjpm3faid9QliLzVYeVmXpcqzD0Acytqd3mAMrgJk8jGSkKGANcIGIY91Sk688/ fLHfule6QOjMztLIDc9iCl2ggTUmMT5G8RgLQNPZGxOeYi6TfxVZXWg7y/Kn+l5TW+Z5 mRpqOunBGmlR/lKJacPneSnVGI70Fgde3tBGeAdR6HqTTkpOtvO96UK3YCAl0j5uUOpX PodQ== X-Gm-Message-State: AGi0PuYxGkDfkpEladP1KLrZ3wJVIz5J2ejsZo67bfKys48kuQN01p1J idm7GEwgYvRLON4iY72SOR/6JabnkyzsgA8trnqEOIUFnkXNUQ== X-Google-Smtp-Source: APiQypIuuFugfv8E/9d7UnEnvgywPjgj2FELJQz7wLaB6BQWQfNbhcojI/MnUPcjAR6RQ+mA4VmZjRYgfo7NvNYy1TE= X-Received: by 2002:a05:6512:200a:: with SMTP id a10mr1405056lfb.154.1585815281837; Thu, 02 Apr 2020 01:14:41 -0700 (PDT) MIME-Version: 1.0 Date: Thu, 2 Apr 2020 10:14:26 +0200 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="0000000000008da91305a24a641d" Subject: [RFC] Stricter type-checks for arithmetic/bitwise operators From: nikita.ppv@gmail.com (Nikita Popov) --0000000000008da91305a24a641d Content-Type: text/plain; charset="UTF-8" Hi internals, I would like to propose making the use of arithmetic/bitwise operators on arrays, resources and (non-overloaded) objects a TypeError exception: https://wiki.php.net/rfc/arithmetic_operator_type_checks This is inspired by some of the recent discussions, in particular the operator overloading RFC (where the fact that operations on non-overloaded objects still succeed with just a notice was criticized) and the increment/decrement RFC, which handles the array case of this proposal for inc/dec only. I think as-is, this RFC should be completely uncontroversial. However, there is an open question on whether we want to make this slightly more strict, in order to align the semantics with the rules for weak parameter type checks for ints/floats. If we do that, then this RFC could be a stepping stone towards making "implicit" internal casts use the (weak) parameter type checking semantics more generally, which I think would be a good idea. The current explicit cast semantics we use everywhere are too forgiving for most circumstances (e.g. an array is almost always not a reasonable input where an integer is expected). Regards, Nikita --0000000000008da91305a24a641d--