Re: Small annoyances of PHP: Simple fixes would make tests fail
| From: | Sara Golemon | Date: | Fri, 19 Feb 2021 15:21:44 +0000 |
| Subject: | Re: Small annoyances of PHP: Simple fixes would make tests fail | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-113213@lists.php.net to get a copy of this message | ||
On Fri, Feb 19, 2021 at 8:04 AM Christian Schneider <cschneid@cschneid.com>
wrote:
> Hi there,
> we encountered small annoyances over time which could be easy to fix but
> would break tests.
> Why does this matter? While it is easy to fix the PHP test suite they
> could potentially affect other projects' code, most probably tests.
>
> Here are the two things on our current list:
>
> Stack traces:
> ==========
> Stack traces for certain constructs do not include the exact location in
> the stack frame:
> $a[(object)null] = 1;
> $e->getTrace() => [] # <-- no stack trace
> while for
> file(); / file(null);
> $e->getTrace() => [ ["file"]=> .. ].
>
>
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).
> Indentation in var_export:
> ====================
> The indentation for
> var_export((object)[(object)[]]);
> is off by one for nested structures:
> (object) array(
> '0' => # <-- 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
>
> This breaks about 60 PHP tests relying on the var_export format.
>
>
I think shifting the indentation in var_export() could probably be done
without a major BC break. 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.
-Sara