Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113075 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 43037 invoked from network); 4 Feb 2021 14:52:25 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 4 Feb 2021 14:52:25 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D41B61804E1 for ; Thu, 4 Feb 2021 06:36:07 -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.8 required=5.0 tests=BAYES_50,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-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10olkn2034.outbound.protection.outlook.com [40.92.40.34]) (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, 4 Feb 2021 06:36:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c4XZdwuobCVHq8lKowaPVOw3ZZTsFOPLNq9Nju6E+h/8mv2aOUVARBPnFPIZCG3+QNmG3I1246ynm6r9XoNsxgEa3WhszK24tT0Qqv0S/KxzR7iV5cpXTqHctWoqTXdjymrPxYXzPv07p86gAx12+eT/ZlFbul+0SkeT/02JBFKNJwDDlOVIUSGGNA2pG5Ou3cPfij/lYiInpQ21C3G8SNFXdwpyG3ln9pE9MyMNjbdRLhq+ryPg9gx6ANfKMkSt7yLRpepPwGxgslamdCdM05juMpzpCYsVtDdk7vCWcKG34D72pwn5mcUnb3vE7WU9kl0ZPXDt0i15Fk614boi/w== 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=fsSnpjkI6kqKx6T6diVQy21YADra5BwGnxzRIrYXVgQ=; b=frJTHsqX03HWwM4GphDFbCeX8Wr99nNkKxvMS0a14jpzrzRJubhAQrsNDwGkIj5RRw1Pm4jxpqkFzLtJ2sTm4B0h+j9awbOWmL+zSTdPwjYBwyzEBkZBXjrKvOh+b9Qhu3JqxexjPvzbzPNvClIRTIugwDglR5QqHiuDAWllTo6OpS1EyQA9HbBYNQGiCi/oYN/HAJ5xl2BDz24pqUhHXECEoACNbyNTViBPI7vYCGSqdPBi10KalDB2L2yA43VPaOxkgjxg/3SmFJr9vQTfFWojZqQF0NGZhq1GLK/6CmRAs6UhjXmDL+bHunBWwOCIJMRjx4WC0RqPaJBgK9eoww== 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=fsSnpjkI6kqKx6T6diVQy21YADra5BwGnxzRIrYXVgQ=; b=WhyD9KxEKziYRym1INXO8ZbbfF/orPTj/Qr0n4QQCA77tT+6wTPs38SfBVDrGHWketsReiCNJaAKUQSpsLahmMxIc8hilFT+KrpGfqR0CnPfPb8wYUwpOUS1cDydm+DxmsBUfaPl0pcmP8oxHVwjIwFLwIykGWJb+ELO32H9wE7FJ6f9A1QaFt6uPGO2lW4IqBwMofPaTEcApxsD13sx7beQZcOAImtYLaxb2kvDyytW8xWgIl+DFdjPDEMZzjg0HLzj/xnHQZ84w2iNaUZwv4+l9dyXb6dpWRT9TdeA0BtKYKCR6XizrF+DgV6y4zBZkob66e7N7Dd/aMKWK0J78w== Received: from BN7NAM10FT047.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e8f::4a) by BN7NAM10HT181.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e8f::213) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.11; Thu, 4 Feb 2021 14:36:05 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com (2a01:111:e400:7e8f::44) by BN7NAM10FT047.mail.protection.outlook.com (2a01:111:e400:7e8f::126) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.11 via Frontend Transport; Thu, 4 Feb 2021 14:36:05 +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.3805.028; Thu, 4 Feb 2021 14:36:05 +0000 To: "internals@lists.php.net" Thread-Topic: [RFC] var_representation() : readable alternative to var_export() Thread-Index: AQHW8R1wWWGP+37l0kiexDpDbUAmVKpIIyDY Date: Thu, 4 Feb 2021 14:36:05 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-CA, en-US Content-Language: en-CA X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:7D41811B805D5D3EF12FA4C447E5462E2EDDCAF6AADE09B0F5614CDDB86583A5;UpperCasedChecksum:B458CB498FAD699ED5169064142A86EEEB3B809A1B79E01F87660734CB2957D5;SizeAsReceived:7092;Count:44 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [+sKbFNKdF3SPQJ052WOrpNBx0l4dtb0ooIAq66CxLOOcThd2kXEEDM++BblGarGP] x-ms-publictraffictype: Email x-incomingheadercount: 44 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: 5999d41d-8560-4d73-08bc-08d8c91a3437 x-ms-traffictypediagnostic: BN7NAM10HT181: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 8dGgOD56APMeQT029e5gcjw//S6kpas/K4x2ZZEWdKrNrIGZ2lLXIp4rfX9XueTxGeiRagilzxhiVLSGFyzz5tLto9pRdC0eNQIxATYHgglex/mIr6WSj/ANYPKjuUCjMw7LotMXplUTGm60NdB5hX56/mwSbmFl6WVQrjLIztE+wVXZ0/hOWy86kBY11m9VfSq+N1V0GxrWxLaZqZg6qbOVLuCurBmKlwB4nRXHsY/98F3mNWZBLm6iWXFJNcgLralJQpvaizOxZbKwAjl1aidUDrGcNUZAshO+5RV82v4ESqxjlPya7iVV43zQhxYFUVI5Dcg9UFpTBDVNr1MEt19m2KtPeo51HYOfH3WJJUZysREJwMt98YAaznrHS59VErjLyWVUgcY2u6liMN1L5CYk+cO8X4bL4HLLnu+o/OU= x-ms-exchange-antispam-messagedata: hHLAvtj7ZaOqVYMdtLoFUG+JVsIRKCSdplPKpgN2cLv0r42n20vmK37fYID5OHp8YLhymSka9/9mWvnuI1TEsuTgTACCbNuKiAFMcWxnX6zZIRSgpEnaeGWouquJwbe1BbGCSfzoEeAqUJ0zWnFL4aF9vauvNisscGL45Ay5+4TQMvJXzYpwpyiIW9I+FUnAJJ+cOnp190VxSvqnkIn5eQ== 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: BN7NAM10FT047.eop-nam10.prod.protection.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 5999d41d-8560-4d73-08bc-08d8c91a3437 X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Feb 2021 14:36:05.4460 (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: BN7NAM10HT181 Subject: Re: [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=A0bas= ed on=0A= > my original proposal in https://externals.io/message/112924=0A= > =0A= > This RFC proposes adding a new function `var_representation(mixed $value,= int $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= > =A0=A0 guidelines (https://www.php-fig.org/psr/psr-2/).=0A= > 3. Change the way indentation is done for arrays/objects.=0A= > =A0=A0 See ext/standard/tests/general_functions/short_var_export1.phpt=0A= > =A0=A0 (e.g. always add 2 spaces, never 3 in objects, and put the array s= tart on the=0A= > =A0=A0 same line as the key)=0A= > 4. Render lists as `"['item1']"` rather than `"array(\n=A0 0 =3D> 'item1'= ,\n)"`=0A= > =0A= > =A0=A0 Always render empty lists on a single line, render multiline by de= fault when there are 1 or more elements=0A= > 5. Prepend `\` to class names so that generated code snippets can be used= in=0A= > =A0=A0 namespaces without any issues.=0A= > 6. Support `VAR_REPRESENTATION_SINGLE_LINE` in `$flags`.=0A= > =A0=A0 This will use a single-line representation for arrays/objects, tho= ugh=0A= > =A0=A0 strings with embedded newlines will still cause newlines in the ou= tput.=0A= > 7. If a string contains control characters("\x00"-"\x1f" and "\x7f"(backs= pace)),=0A= > =A0=A0 then represent the entire string as a double quoted string=0A= > =A0=A0 escaping `\r`, `\n`, `\t`, `\$`, `\\`, and `\"`, in addition to es= caping remaining control characters=0A= > =A0=A0 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= > =A0=A0=A0 It now always returns a string.=0A= > 2. Backspace control characters (\x7f) are now also escaped.=0A= =0A= A reminder that voting on the var_representation RFC starts in a day.=0A= This RFC proposes adding a new function `var_representation(mixed $value, i= nt $flags=3D0): string` with multiple improvements on `var_export()`.=0A= =0A= Any other feedback?=0A= =0A= Thanks,=0A= - Tyson=