Am 19.02.2021 um 16:21 schrieb Sara Golemon <poll...@php.net>: > On Fri, Feb 19, 2021 at 8:04 AM Christian Schneider <cschn...@cschneid.com > <mailto:cschn...@cschneid.com>> wrote: > Stack traces: > ========== > > 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 <https://3v4l.org/0Pgfo> where the first line try { $a[(object)null] = 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: > ==================== > 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. An example script is at https://3v4l.org/V8r5k <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