Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:104527 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 84792 invoked from network); 27 Feb 2019 11:06:52 -0000 Received: from unknown (HELO NAM02-SN1-obe.outbound.protection.outlook.com) (40.107.77.139) by pb1.pair.com with SMTP; 27 Feb 2019 11:06:52 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=RWSoftware.onmicrosoft.com; s=selector1-zend-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+uQXv6LPK2VSKJYLBAPRRiq8aogsk3XHiGiN0+9oVPA=; b=whJxiHohaakZbjpsPs9cyMXhHSMpxo0al/d7AnXDJsz7HC7xpaa8VRaTzyvpFvVLl3duWtdMv+jrcJDcIFfAF2cM/5hp1qO/7qweVn4wZTxvwj77XBzfb6C90ggbtOTtRbTkkmiVIeog67H5EikoX9WK14LFPQO7/me3upPRvZ8= Received: from MN2PR02MB5775.namprd02.prod.outlook.com (20.179.98.90) by MN2PR02MB5856.namprd02.prod.outlook.com (20.179.87.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1643.20; Wed, 27 Feb 2019 07:53:25 +0000 Received: from MN2PR02MB5775.namprd02.prod.outlook.com ([fe80::918b:ceb4:662b:f4b3]) by MN2PR02MB5775.namprd02.prod.outlook.com ([fe80::918b:ceb4:662b:f4b3%2]) with mapi id 15.20.1643.019; Wed, 27 Feb 2019 07:53:25 +0000 To: Nikita Popov , PHP internals Thread-Topic: [PHP-DEV] [RFC] Saner string to number comparisons Thread-Index: AQHUzc6wG2Qe9FJuvku5V6pZbs9F4aXzRmiE Date: Wed, 27 Feb 2019 07:53:25 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=dmitry@zend.com; x-originating-ip: [194.106.107.132] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 4677102d-5f7f-4f6b-eb70-08d69c88a783 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(2017052603328)(7153060)(7193020);SRVR:MN2PR02MB5856; x-ms-traffictypediagnostic: MN2PR02MB5856: x-ms-exchange-purlcount: 1 x-microsoft-exchange-diagnostics: =?us-ascii?Q?1;MN2PR02MB5856;23:/MPkT5ajGyNHawyUWyls8U+5GvqYv9Kf8re/aOZei?= =?us-ascii?Q?cv3OtLafae8qXjEyYIi5scvDIVVWL4AswlR6tgXk6r3rB2Utwg8XCDAP22lu?= =?us-ascii?Q?HAFnqmrFoSjVhQCF7eoiP3GanO69HcVQ6EJzv3wShDJ1pWEwLwNZhHu7EudQ?= =?us-ascii?Q?Gl4P/WyanL9IDfaQKnNQuRVWOJS16ZNsh6D9QYDD3x8uQZscM9dXgIRUQEyU?= =?us-ascii?Q?iFqAjDJHNE4jjcaDBbShaaB8enScdZRt6Ge/Hxob0qqZadrVIXaDrLSX+Sls?= =?us-ascii?Q?zAXl/LUeN6uLj27ogirFo9I0b2UHp/y36OArEoXefxomv29iOwZP3SNiV1kD?= =?us-ascii?Q?CIeioR1akxL8IXN8KN5lgP5QxUgn7AaosotSZlLEDJ+1asIEa8Dfn4PD7lqp?= =?us-ascii?Q?A9ZFwEJ8/4047G66he3ExE3sdBG8oxeRpKKcSvqS3Q0TtlPVJnkwOKFNDbpT?= =?us-ascii?Q?CDgcRROxw8X5f4c4/tvtAzHVsn+c+Q09VN+pI4dUv6yvMHpfaMY1+jR4PpLr?= =?us-ascii?Q?TG83dP+vbxOTzYlTux+gjHM9/eqUX7Brx5PapwJLL2kuNm4iJjbyMLIS2clk?= =?us-ascii?Q?63its8hDEsRGF4UEXfpGuMdHH1pO2ClTwmfxe1ZOpGvVfIL6CmrrXbVgLg3X?= =?us-ascii?Q?elMOLpIoRoO9vw/RdLyPdLgwGzOwNmLnhuNVkuPBaLwLU2iMqyBevCr5DuiG?= =?us-ascii?Q?eAul+zeT2FUs5e9v7TN7cRA2VmJH9lbYn/0ul61CQFa4myHBARWPUmdD7YOr?= =?us-ascii?Q?ysEikM0g0owOYUCkKuI4DrCGQLnqpIV0m9n6gwtcOkGEJaD1eTN2iYxuRU2N?= =?us-ascii?Q?PFhZGZTSx8YFlq0SjZD+7Tn3Qox4UIIWwmEygkTKbCGT900MSWYVH2EKXU1F?= =?us-ascii?Q?g2Bhy7qbV1gKNTkwxFs0Gj9XKFTkhuVNumucqhigstnrnlZ0MtLB8NV2njh6?= =?us-ascii?Q?UbXYxgWLcFYokEZe+VQRemGr1hZJVb21xdCNtCiPFYu/YzNL7HL4E6cxFdT1?= =?us-ascii?Q?Mz5f57QcPTlo2OGtyWddmV8UHeOwsc41wyLDtmtHbpDIsMDRGhzdtHG6aBP7?= =?us-ascii?Q?1SWm/Mt1OS+90rJf/zZ2U6li9YRX8WuiR+kcH7KklQGmeJT54hISPlkQ6yCU?= =?us-ascii?Q?piW41tRnFHNZ5tXtlc6mllBIKZCP+GjuslApF8ORvSJam/6dklSYNS64FoMq?= =?us-ascii?Q?Mn0eShZauY6Q8T2d0vbbgAacxhOGhggoLEoaH3mFjgqShIboCGHkLFUSxKcL?= =?us-ascii?Q?eKpqjWwPdFdMHJjKThEsZKya2ErFx8yCsi2CBPGqNzgNYE6DAcK5SM/AzosL?= =?us-ascii?Q?FJK/OX855ocHxLihmeGGRKaB+GgBaQDAWLCE7Gi3ezwgfP86wqXeESrNBgL6?= =?us-ascii?Q?XXTIw=3D=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 0961DF5286 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(376002)(39850400004)(136003)(396003)(366004)(51444003)(199004)(189003)(53936002)(486006)(476003)(606006)(6606003)(11346002)(229853002)(71200400001)(71190400001)(86362001)(68736007)(446003)(478600001)(7736002)(14454004)(966005)(53546011)(102836004)(6506007)(256004)(55236004)(76176011)(106356001)(66066001)(7696005)(74316002)(99286004)(25786009)(6436002)(97736004)(3846002)(6116002)(81166006)(8676002)(9686003)(55016002)(8936002)(33656002)(81156014)(6306002)(316002)(26005)(236005)(19627405001)(52536013)(54896002)(5660300002)(186003)(6246003)(105586002)(2906002)(110136005);DIR:OUT;SFP:1102;SCL:1;SRVR:MN2PR02MB5856;H:MN2PR02MB5775.namprd02.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: zend.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: p0odAUEv+c7SgFM0Wtbdvl4e/cS7yd0z7v1ZC7oBcDyJqwgZhrO/n7WUXijBXk3XK2JlKHuCsdRHgdDYaIi6sWubxxn5GqyaF91fzPy92G9HtSfFHxp+t3SoRMr19skllqPfwT26eTzM9y3F62fDRlURKkfvcaUNauRx2icYUVLgQQ2+mbinnsvCZjbmz7s7337LGMKJWiNorWeWJkFzSoV3S6GaVY7ckeW+QfBHdy20oz1lK7z4IWrNQP3AM7/Ui8/lD5skHmlsQFAAcKvPAxrXDKQOWzqCDuSIpIUQngPPszRwYJXNaFuT3fUtELZkatBK430VwM+cYhQpgKDpgsnh3rRP2kGcpiiad4/7eMfjGcW6cNHgz4jX++8/b9dKET74bVaI2vgYY+sgF6y82y8hVgx0C7obOUWMvlaYVeU= Content-Type: multipart/alternative; boundary="_000_MN2PR02MB57755C29630116FE3981C277BF740MN2PR02MB5775namp_" MIME-Version: 1.0 X-OriginatorOrg: zend.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4677102d-5f7f-4f6b-eb70-08d69c88a783 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Feb 2019 07:53:25.7648 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 32210298-c08b-4829-8097-6b12c025a892 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR02MB5856 Subject: Re: [PHP-DEV] [RFC] Saner string to number comparisons From: dmitry@zend.com (Dmitry Stogov) --_000_MN2PR02MB57755C29630116FE3981C277BF740MN2PR02MB5775namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Nikita, Yeah, this is a big BC break, but I think, it's a good time to make some "c= leanup" in PHP-8. The only thing, I don't like is a difference between leading and trailing s= paces. They should behave in the same way. Thanks. Dmitry. ________________________________ From: Nikita Popov Sent: Tuesday, February 26, 2019 3:27:23 PM To: PHP internals Subject: [PHP-DEV] [RFC] Saner string to number comparisons Hi internals, I think it is well known that =3D=3D in PHP is a pretty big footgun. It doe= sn't have to be. I think that type juggling comparisons in a language like PHP have some merit, it's just that the particular semantics of =3D=3D in PHP m= ake it so dangerous. The biggest WTF factor is probably that 0 =3D=3D "foobar" returns true. I'd like to bring forward an RFC for PHP 8 to change the semantics of =3D= =3D and other non-strict comparisons, when used between a number and a string: https://wiki.php.net/rfc/string_to_number_comparison The tl;dr is that if you compare a number and a numeric string, they'll be compared as numbers. Otherwise, the number is converted into a string and they'll be compared as strings. This is a very significant change -- not so much because the actual BC breakage is expected to be particularly large, but because it is a silent change in core language semantics, which makes it hard to determine whether or not code is affected by the change. There are things we can do about this, for example the RFC suggests that we might want to have a transition mode where we perform the comparison using both the old and the new semantics and warn if the result differs. I think we should give serious consideration to making such a change. I'd be interested to hear whether other people think this is worthwhile, and how we could go about doing it, while minimizing breakage. Regards, Nikita --_000_MN2PR02MB57755C29630116FE3981C277BF740MN2PR02MB5775namp_--