On 03/06/2021 18:03, Timon de Groot wrote:
On 3-6-2021 17:53, Ayesh Karunaratne wrote:
Hi Timon,
Thank you for this RFC. I think the `string|int $indent` approach is
great 🚀!
Reading the PR, it looks like `$indent=0` is essentially turning off
pretty-print, which I think is intuitive.
Basically, yes. With `$indent=0`, no indentation will take place but
new lines will still be added.
Do you plan to add any sort of validation on negative integers?
Perhaps throw a `\ValueError` exception on $indent < 0?
Good question. Personally I'd prefer clamping $indent to 0 when it
reaches below 0. But I'd like
to hear about what other particpants think about such behavior.
IMO the JS spec is quite reasonable there, and I would say copying it
1:1 would be fine:
   If this is a Number, it indicates the number of space characters to
use as white space; this number is capped at 10 (if it is greater, the
value is just 10). Values less than 1 indicate that no space should be used.
  If this is a String, the string (or the first 10 characters of the
string, if it's longer than that) is used as white space. If this
parameter is not provided (or is null), no white space is used.
Best,
Jordi
--
Jordi Boggiano
@seldaek - https://seld.be
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php