Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112914 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 9486 invoked from network); 17 Jan 2021 16:18:33 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 17 Jan 2021 16:18:33 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id F18FF1804E4 for ; Sun, 17 Jan 2021 07:57:46 -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=0.0 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10olkn2055.outbound.protection.outlook.com [40.92.42.55]) (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 ; Sun, 17 Jan 2021 07:57:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KBr20mCdF6jMehkotoG9dE9m80ojepebqJExzS4UK9SGv19ttjO43gYaGnIXlQgUwbtvwIpuxatSsHNzT3/ZQWRxdCtIGQgvxkGFNjMDZyRp33vi+1cNY+hAiV453oHTTKYuFaPE17LeNZIPsHCcqeTL1WpC7ZfWtx6f5L59oklGUxlhnkdCPXV4DgE3jb933hSzu+17r4O3pIYobU4RKT4/tPFgSNJxDCmrwWjSqmkNNkPIF9MhiZAk24ZuFPhqlHaGxTa2/ROp8V0VK5bKQMuNiju8o4efat0Oyrrz3ZOMTCcguYdkp5I0Nb21lPwg1YGwZRo29NQd6bPOQNqfiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=17HG5bOI+fihl9Z8yXLteu+TJJ1iAOBO6EzqQro6yyA=; b=FiDC4Z4aJmqqc3hh5pYGHDJiT5DabQTH4/4SF45F5+aqLdfrV98Ww0zoGC08ejpQQMGd1Bd/GLIsJ0MGEJKFBlIBiYSyGJwOpesUlH313A5BbaPIeyPjq/8t66WrmAFJzaJybPZ7hD9XpoRw/UYOP3taE3NYkjY+fbi4/4+PNlzfBCvhZ5KMz7SerXiA/reTc2QVdxfJneIEBRqRPgdcuZTQd+fKlfDsx0KzMlpYClE+xvPzK14FQOnoeol9eXXzvugZO+PbTZCHG9UxAYR+N6RG8uQxs0HtNtUu16Ejx9IVtfUTpXrJANjVkLrcBUhB19xoc3vEroeZbq5yUeDkKQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=17HG5bOI+fihl9Z8yXLteu+TJJ1iAOBO6EzqQro6yyA=; b=o3sCJev8+nL7PVYiqxz+9ykFWmwkI2jSMmdlbJvvf1adAvr+q/NVfAuX+GkoyZjPZAddABbYuvSgc4ws4ka7jakgf1EF+/VtgEI7lvnxMN7d/8MYkhL4tjghyjzgPeVqn4jqYMiOd2Y3bQrJj7nTyAUd3f+uKppY8GXxwQQSYxLNYZzJCvlyRMCYfOp+pm2rPHXy+RzoF5Q3kfbwtBp+SbNO2rP5C9H+Am83VRP5pgxVxsokpPieYCryq8rxnHHqhDgySzFrb4vmiAuyqO4moJ4MTmgzgM1tGMDFeJH8NFZQE7Cm60KgRus4l38fl0nXcdJ9ju+6U/xpGkQRZrBYhw== Received: from MW2NAM10FT007.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e87::41) by MW2NAM10HT132.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e87::162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.12; Sun, 17 Jan 2021 15:57:44 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com (2a01:111:e400:7e87::43) by MW2NAM10FT007.mail.protection.outlook.com (2a01:111:e400:7e87::62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.12 via Frontend Transport; Sun, 17 Jan 2021 15:57:44 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::b4c4:dc11:5337:821d]) by DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::b4c4:dc11:5337:821d%4]) with mapi id 15.20.3763.012; Sun, 17 Jan 2021 15:57:44 +0000 To: "internals@lists.php.net" Thread-Topic: Proposal: Render floats differently from integers in print_r() Thread-Index: AQHW7Og8HulFfPKKykG6tdud5188Iw== Date: Sun, 17 Jan 2021 15:57:44 +0000 Message-ID: Accept-Language: en-CA, en-US Content-Language: en-CA X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:1527AE745C08340725BDB48969520399549A9BA3A9C65D2939A679191D9947E1;UpperCasedChecksum:E1680FA2D737AC4B8750F14788AEDEA10E41713CD6564BB774E4E68B97CA8834;SizeAsReceived:6840;Count:41 x-tmn: [YrN9/wlNBGBKpzVXl3nsmcEACeXFlv1KVU2BifdEcPWF6tMXIR4z1B+v05tFKT7o] x-ms-publictraffictype: Email x-incomingheadercount: 41 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: e119db58-4717-4ce1-e282-08d8bb00a0fa x-ms-traffictypediagnostic: MW2NAM10HT132: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: tPw6QYze3iCI+QhPmSdRcVr7o0clHGF7IA4vRgKPZyh5RROb9czIAh0VokX6shKzVRY8njHClEPhof0Qj+HHW3tY7ZJi62/IwbIp7Dfy4jzGbkBMnS57pI+haqCAoPPD8R/qVY2ybLRnj4Bul524PmQ1USaVwf0MsxudFsmcPgyJmiwiF04WW7hWMjcuIs8z7xEOvH8tOvUXpdjlZKHvjPSE5PtNGzgdSSAJDVGIhiNV/imRncmrddyz11JgsfbIZhiB/zbo+imLS0cHeIl4z+ZzgUmrJy8glB9tmu+rD3I= x-ms-exchange-antispam-messagedata: QEPhwKm7/eBBZzugPwNrwGCRcfTtb6yCS0A6/ruMNXYjAHRF6cSBzLotWfL0Etyq+2nTP6vWV8UtqZ/tMaiaVBXlC67W7YCQwJRdVfVFQjJSDfHXem5XCW2UWZzedsJOCxwEly7Zt11disib+OcjJrJT9WCFCg8eZHSkKQWHPhppbyHckXHiwej4MMpz1gJKtdKRwLwPJSHciU/OPy+zow== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-AuthSource: MW2NAM10FT007.eop-nam10.prod.protection.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: e119db58-4717-4ce1-e282-08d8bb00a0fa X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Jan 2021 15:57:44.7326 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2NAM10HT132 Subject: Proposal: Render floats differently from integers in print_r() From: tysonandre775@hotmail.com (tyson andre) Hi internals,=0A= =0A= Currently, print_r() will print ints and floats in exactly the same way, de= spite the fact that they are different types=0A= and floats may cause a TypeError (or be treated differently from integers, = e.g. avro encoding) when used where an integer is expected.=0A= This is not documented in https://www.php.net/print_r=0A= =0A= I've created https://github.com/php/php-src/pull/6611 , which proposes to h= ave print_r() dump floats such as 1.0 as 1.0, like var_export currently doe= s.=0A= =0A= ```=0A= php > print_r(1.0); // old behavior, proposed behavior is 1.0=0A= 1=0A= php > print_r(1);=0A= 1=0A= php > var_export(1.0);=0A= 1.0=0A= php > var_export(1);=0A= 1=0A= ```=0A= =0A= Benefits:=0A= - print_r() previously make it look as if a value was an int when it really= was a=0A= float. When using print_r() to inspect the value of an array, TypeErrors = or differences in behavior can be unintuitive=0A= if you think the value is really an integer when it's actually a float.= =0A= =0A= This change should save time debugging in the long run for users unfamili= ar with this behavior.=0A= (https://www.php.net/print_r has no mention of the behavior seen for floa= ts in the summary or user-submitted comments)=0A= - print_r() output now shows a difference between 0.0 and 0,=0A= which is useful for generating diffs between expected and actual values i= n test failures, etc.=0A= =0A= Cons:=0A= - Existing tests of php, pecl extensions, and composer libraries need to be= changed if they involve the raw output of=0A= print_r and dumping float values.=0A= If this is merged, tests would need to normalize print_r output or use fo= rmat string expectations=0A= to pass in both 8.0 and 8.1 (or switch to var_dump(), var_export(), etc.)= =0A= =0A= Thanks,=0A= - Tyson=0A=