Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112967 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 25917 invoked from network); 23 Jan 2021 01:09:35 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 23 Jan 2021 01:09:35 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2EE301804C6 for ; Fri, 22 Jan 2021 16:50:10 -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-mw2nam10olkn2098.outbound.protection.outlook.com [40.92.42.98]) (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 ; Fri, 22 Jan 2021 16:50:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VycWD/qDnpaEG7IkHCO5q1cCQWbos4eY0Rr8EvLgGmzeWk5kpBaK1qr6aBm0eLG9lwDxIpnq7d8nVYcoQKezMUWGvoMbn9b96qmqK1eRqUnqaOpDKEBydJ5CJzT0dsX3owgnMm1yE+J5JrNwL1+pzwff/bbXdpcc73wgv1Kwg1043eWgOnVrBz6PhUKm0zZ28TkkRbAabn/Jl1Qr44BRj4DsndL9KkxKIiyuRUS2QSPNgvaWQIJ78nqGtvNjeX5y5x438P1zC4oTBzbFL12d9nuVToSipBoPcOwa+AFUYaKLQPHJ6tMbx4KsG6JMi3g//6bwb6jb0HELYhQp0z+oBw== 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=S/zM7oUSr8Upc4clvIC9PUQBdF6zSN38UUKd/MkX6Iw=; b=g25ZXk59Y5e2TRaVWIz2nh5PfRkykkCUqg/OjkxMAexgbreoYw+AdIYzcpC8TxpmEydjM6e88p3Kpy4kX2nw62cL5CI29OkANzZFOWHzLntJEPUlfRMsdVvScmYb8iWHW48zDti/qB9xQATo4Ik8YK4F6ZeBvTzgk3xLexcrPS6jMqvPB21CYTYnOfkQfRSAWPPpOBo/Z1MSWcJSV6tXr1OCuCiXrJZUxB1HdABPusDQH3TUx+xxdjLlgvf51quO6LnfOBIgtVqwz8X0nPbcl+HRLsRSQJ6vuuDOQKQ7r0GmxW26ve7CQ2Kayjn33pGgA9+GGcKB77HwMGodXk+JKA== 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=S/zM7oUSr8Upc4clvIC9PUQBdF6zSN38UUKd/MkX6Iw=; b=Oc8RfcmxrPDwknZ27BnUAQdjgNSKMs0bmtPqSGJMiJebUvhpYwlofWOGyyBEGyn8wtrX7y7+0hlLdokrMFl6+zCBvwR7pEcBid9KGQaah2A2OGIrWelGY/lpn/59Exyt/pXGNYu62ori01Dts6nKBS6Zf2E5Yra00wi6/kZvPiOuxayxuDtCTPJYbw5vLa5OQz8biwJdFLpk1sjaATrHFIwAS4ws8DbotWl/sH3tPjfav7pCR5cjzLuJAq6eSB1XKBJM6KRqzNa/tFx3lkjM1hhGrkowON5OWUESwi207SXn1xliudnnxvJwPOxTDzT3zwWv59JsTApjGXcUmuO7eA== Received: from MW2NAM10FT013.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e87::4c) by MW2NAM10HT243.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e87::73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.11; Sat, 23 Jan 2021 00:50:07 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com (2a01:111:e400:7e87::51) by MW2NAM10FT013.mail.protection.outlook.com (2a01:111:e400:7e87::279) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.11 via Frontend Transport; Sat, 23 Jan 2021 00:50:07 +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.3784.013; Sat, 23 Jan 2021 00:50:07 +0000 To: "internals@lists.php.net" Thread-Topic: [RFC] var_representation() : readable alternative to var_export() Thread-Index: AQHW8R1wWWGP+37l0kiexDpDbUAmVA== Date: Sat, 23 Jan 2021 00:50:07 +0000 Message-ID: Accept-Language: en-CA, en-US Content-Language: en-CA X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:0F0B637FA93014E52896D34811C753AE4FB2A4580A0BA4AFEE844464217D00B0;UpperCasedChecksum:2B770BF17FD63413363DB04B5642365D855B244A6F260A122C0BD20B20ACF553;SizeAsReceived:6852;Count:41 x-tmn: [Nr0i4fPNJLDXrLdtmK0+iDhZ9oldYYvHcYq+aidZTRrAXF0lM0RIEwVyVqzwhHaA] x-ms-publictraffictype: Email x-incomingheadercount: 41 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: 8abcb967-5bc9-4745-6676-08d8bf38d48e x-ms-traffictypediagnostic: MW2NAM10HT243: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: pWnCSYqCB4t+zGMeWkxS4id7xC79476zBaVRu/udjBKJxd0of9bR2A3roW2DpqF9E0u8vd5YQi0LeljYU6MHBRERzxthTqa6ZVOgtNaewsBrkvGrmX5WiJ3RoyHwYrasSb9WJcXJ+Ha603RvvthswDZOgOzJOHhs2G+g/WQ2OZxSqXDJerkMPePZnA6+ToTOAEoDd2cSfIpd39W4JwHrfhGuvSfMCdeflyzmtZfH5eSodoYdmiNPjqLGwHCYBNcJdSHWkjIQX1JIIhJQKU/zgZjdChVTsAz+Rw8wC6M4coc= x-ms-exchange-antispam-messagedata: 8oinXoroJ8DCbTP96Cpw9lzwM3mO08WcxhR/ADQyLtT42inFf00/SEktw5bFbVK+ZX9c7Wo3wQ85NWWm8Fw0bCQ9GGLnfyC9e4LP/KkQ4esbmMuQ9IBnReNjnv4x0Nw0VCgnD8BzZEhatCYHLcg7wySgmi6nQNdYUfYTK48YVBggIpDkbvj1e4Fed9dWnvFDelUMZIxJ/dZgpdgzESDcBQ== 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: MW2NAM10FT013.eop-nam10.prod.protection.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 8abcb967-5bc9-4745-6676-08d8bf38d48e X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Jan 2021 00:50:07.7571 (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: MW2NAM10HT243 Subject: [RFC] var_representation() : readable alternative to var_export() From: tysonandre775@hotmail.com (tyson andre) Hi internals,=0A= =0A= I've created=A0https://wiki.php.net/rfc/readable_var_representation=A0based= on=0A= my original proposal in https://externals.io/message/112924=0A= =0A= This RFC proposes adding a new function `var_representation(mixed $value, i= nt $flags=3D0): string`=0A= with the following differences from var_export:=0A= =0A= 1. var_representation() unconditionally returns a string=0A= 2. Use `null` instead of `NULL` - lowercase is recommended by more coding= =0A= guidelines (https://www.php-fig.org/psr/psr-2/).=0A= 3. Change the way indentation is done for arrays/objects.=0A= See ext/standard/tests/general_functions/short_var_export1.phpt=0A= (e.g. always add 2 spaces, never 3 in objects, and put the array start o= n the=0A= same line as the key)=0A= 4. Render lists as `"['item1']"` rather than `"array(\n 0 =3D> 'item1',\n)= "`=0A= =0A= Always render empty lists on a single line, render multiline by default = when there are 1 or more elements=0A= 5. Prepend `\` to class names so that generated code snippets can be used i= n=0A= namespaces without any issues.=0A= 6. Support `VAR_REPRESENTATION_SINGLE_LINE` in `$flags`.=0A= This will use a single-line representation for arrays/objects, though=0A= strings with embedded newlines will still cause newlines in the output.= =0A= 7. If a string contains control characters("\x00"-"\x1f" and "\x7f"(backspa= ce)),=0A= then represent the entire string as a double quoted string=0A= escaping `\r`, `\n`, `\t`, `\$`, `\\`, and `\"`, in addition to escaping= remaining control characters=0A= with hexadecimal encoding (\x00, \x7f, etc)=0A= =0A= This is different from my original proposal in two ways:=0A= 1. The function signature and name changed from my previous proposal.=0A= It now always returns a string.=0A= 2. Backspace control characters (\x7f) are now also escaped.=0A= =0A= Thanks,=0A= - Tyson=