Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113214 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 65756 invoked from network); 22 Feb 2021 10:26:07 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 22 Feb 2021 10:26:07 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9EF451804B3 for ; Mon, 22 Feb 2021 02:14:19 -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=-1.9 required=5.0 tests=BAYES_00,HTML_MESSAGE, SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from darkcity.gna.ch (darkcity.gna.ch [195.49.47.11]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 22 Feb 2021 02:14:18 -0800 (PST) Received: from wafer-1.home (unknown [IPv6:2a02:1205:5053:a220:68df:e3a2:f435:5704]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by darkcity.gna.ch (Postfix) with ESMTPSA id 853E4150ED0C for ; Mon, 22 Feb 2021 11:14:16 +0100 (CET) Content-Type: multipart/alternative; boundary="Apple-Mail=_05820433-D6B3-499A-A8B4-4D8D09D4DD04" Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.60.0.2.21\)) Date: Mon, 22 Feb 2021 11:14:15 +0100 References: <52E47CD0-11F0-45DF-9387-DFB5DFDC481A@cschneid.com> To: PHP internals In-Reply-To: Message-ID: X-Mailer: Apple Mail (2.3654.60.0.2.21) Subject: Re: [PHP-DEV] Small annoyances of PHP: Simple fixes would make tests fail From: cschneid@cschneid.com (Christian Schneider) --Apple-Mail=_05820433-D6B3-499A-A8B4-4D8D09D4DD04 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Am 19.02.2021 um 16:21 schrieb Sara Golemon : > On Fri, Feb 19, 2021 at 8:04 AM Christian Schneider = > wrote: > Stack traces: > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >=20 > What version are you testing with. I know Niki killed some unnecessary = frames in 8.0's stacktrace output. (A whole repro script is more useful = than a snippet wherein $e comes into being seemingly from nowhere). I was testing with PHP 8.0.3 but it is the same with master. You can see the difference at https://3v4l.org/0Pgfo = where the first line try { $a[(object)null] =3D 1; } catch (Throwable $e) { = print_r($e->getTrace()); } does not create a stack trace. That's what I'd like to change. What do you think? Should I create a PR for this? It does break a lot of tests in PHP. Probably less so for other projects = but still... > Indentation in var_export: > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > The indentation for > var_export((object)[(object)[]]); > is off by one for nested structures: > (object) array( > '0' =3D> # <-- extra space before = index > (object) array( > and the fix would be to change > buffer_append_spaces(buf, level + 2) > to > buffer_append_spaces(buf, level + 1) > in ext/standard/var.c >=20 > This breaks about 60 PHP tests relying on the var_export format. >=20 >=20 > I think shifting the indentation in var_export() could probably be = done without a major BC break. An example script is at https://3v4l.org/V8r5k It does break tests though. And my guess it that is would also break = tests in quite some projects. What version would you aim this for? 8.1? 9.0? > Trimming trailing whitespace would also resolve one of my long-time = annoyances with the function. > Feel free to propose that as a PR and/or an RFC. I see your point as it means there have to be trailing white-spaces in = tests which can be confusing when editing/creating tests. I can have a look at how hard this would be to fix... Side-note: Maybe we should recommend a function to be used for tests. At = my work we used to use var_export(), some of our newer tests are using = json_encode() but neither is really guaranteed to be stable, right? - Chris --Apple-Mail=_05820433-D6B3-499A-A8B4-4D8D09D4DD04--