Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109503 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 21888 invoked from network); 2 Apr 2020 10:08:58 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 2 Apr 2020 10:08:58 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4C4C91804C7 for ; Thu, 2 Apr 2020 01:35:33 -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.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS8560 212.227.0.0/16 X-Spam-Virus: No X-Envelope-From: Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) (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 ; Thu, 2 Apr 2020 01:35:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1585816530; bh=PHx65yEHdizHxEn5elT4YIiPQs0opy1TMBxNBbZVw+w=; h=X-UI-Sender-Class:Subject:To:References:From:Date:In-Reply-To; b=ADIp4sp1Xk/o8CTe6Xi8jC69ZneeC+BiRCW9blsUVGW2cVP2Yhw6BPGzWlBTniVMS t8bNzCuXXsnen+iOc+TkSULdKBvPq59wOLZmb4mkFelUGWYtsNh6JBVlDJEl19Z/5q WtXo9Ubryt6aCLNehq41TX01VhST5ieik+UkpaMU= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.2.130] ([91.8.171.81]) by mail.gmx.com (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1M6ll8-1jQ07w1qko-008HHS; Thu, 02 Apr 2020 10:35:30 +0200 To: Nikita Popov , PHP internals References: Message-ID: Date: Thu, 2 Apr 2020 10:35:28 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: de-DE Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:2S5Qe6j03Rfgv3hqrUBQPNMiiL9sQjGvGFTwRdBnn93BV7p5FXY 0T5odEtaUwP+0WZlue3PX8JCYnOzE2JQS9dnVMjwLD6xqW7D0/eylnizpJBNJ3vjRUn+mr1 LE3KKKqdMDz4EdZYAM9TFCqLdRaBvkmaWistGs6RIjDlHgUw1gBf7FFbgkbXdCPZq3NvCsB C26p3zMZEEpm1DVcgLtyg== X-UI-Out-Filterresults: notjunk:1;V03:K0:MOWlVuKXrxA=:G931W9RKieaEDlmavmOozW OrY652xhwtfHCv+ZusWANd7W+skWf7sIEFLRcm1cKHJHCoFoW0RJ839VVBRwtdaxQEX84GjKl QHZf67DjFlOmvygw/7JAtJ3CqIp3Uqo49thjb6dkBgyuRaQ3E6Fyh/Xfek8JwicE5jN/8+VMG 7oGN85TSdqRfiDL5cDvLY0J3fipXQV22BKUC3ah9HuUnL0KVzMpV1RtJWHd99ZY+wGiTv7Bq1 kdzWwApuLjlap2Q+kdtNn9vSeTkAQg/60/s5e9Ij3gm+OKDio2f6bQkNrtBAXLihRYVNyViD6 kP1TH15Mnff68As+R+3BB1NLdrvkHNfLXXfF7P6h+AchioNYslQn8sDtxR4HEl90dbzh0BF7o 0JslDk6tBl6CYFmfCHFGyOZXw06O7abrR8mEgomDBQqNbIJmM+FryRcDMbaA9vJsDoEV0nm/z gbvkrVTbkTse6GsblRlLV7X1bBc+XPAlkEAZvHZ0Jk89ErF7o8mzqGB/SJgIfuM1pu3vISyFl 4mI/nkQNpJHotSm9JqZKfB2M/8ku8AJMaXCHr0vujGcnJPuFGIXb1k14H/m4dV3LJmApjxiSb sL/bCyIvIpHzGHsSi6HRUJ8wtI/PR/TYZFhKl3SvlTM9dgB+qJr1xj+rnYBf8FRsXVhcJ5AXK GzBFFdrsr/3qtGYGL4sG+OEQknnurtLJ5DQiiqaHMWzi3KGqg/I/7QjbwhL4qHOwfNDyJAG3+ 5ua2Ui6XWRQd9GzAdeR8uQWdN0zyDWNkCVqkfQnph7K7XKuf6BM5moK0wv7aGJk5+HxO1jqSn nq8T3+FHfBQmhg/uO9VyZyDy2r04MAPJ4q/q9jjuDw6NBCmtNYyxEsmzLj91jJZ9SSHNFVhHB dORg4KidTKePCYgyqztndh+USKhqcMUdC7ij8bMAZMHlxWEPquDwSWeMXwPQR86JGqFk9DXw/ D22pnARFyoFRHOh9T03WMixfbbw2vUyJm3lxvTz4shDPFjJdHjRdzXWViR6rJCx+viEyooh3z lF5LilTG39EObOeqSU2RshqNXiBZKd9P0xNIBeIDEyIQNXGDGhA2swDpA+eR+xHNrbuPoVtVS 588w1bs86ah91yl46oEdwkte4DK41erIPSwGYT/mPhwzW/II8Gj+bj9rfWq68sIcUpqEgZP4n VOVjRSZklrL5c5m7FtSCpge7vF5IvUs1//phfXaSZgS5gOjdj0+mgvgSgdNza9VeUIgeJlhUK ZytovuqLE1pCndd7o Subject: Re: [RFC] Stricter type-checks for arithmetic/bitwise operators From: cmbecker69@gmx.de ("Christoph M. Becker") On 02.04.2020 at 10:14, Nikita Popov wrote: > I would like to propose making the use of arithmetic/bitwise operators o= n > 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-overload= ed > objects still succeed with just a notice was criticized) and the > increment/decrement RFC, which handles the array case of this proposal f= or > 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 paramete= r > 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 semanti= cs > more generally, which I think would be a good idea. The current explicit > cast semantics we use everywhere are too forgiving for most circumstance= s > (e.g. an array is almost always not a reasonable input where an integer = is > expected). Thanks! Generally I like that very much. I'm not quite sure, though, what to do with resource to int conversions. These are documented to be valid[1], and are sometimes deliberately used[2], and as such it might be reasonable not to throw on these conversions (maybe even change the current behavior of the ~ operator). After all, I hope we will be able to port all resources to objects sometime, and till then we could stick with more lax semantics. [1] [2] =2D- Christoph M. Becker