El lun, 29 ago 2022 a las 11:06, Deleu (<deleu...@gmail.com>) escribió:
>
> Has the option of returning a Result object been discussed/considered? Can it 
> be an option? I imagine that if `json_validate(): JsonValidationResult` 
> always returns a `JsonValidationResult` which contains a `public readonly 
> bool $valid` and a `public readonly ?string $error` it would be better than 
> both options on the table right now. The option of returning CLI-like results 
> means that we will need a `if (! json_validate())` to treat a valid JSON 
> (really awkward) and the option of using `json_last_error()` relies on an 
> internal state instead of an immutable structure. Effectively, what we need 
> is to return a complex structure which can contain a boolean and a string and 
> that is a class/object.
>
Interesting, it was not considered.

I still think BOOLEAN is my preferred choice, but can you provide an
example about how the code would look like with your approach? Imagine
you have the feature like in your suggestion ... how a developer would
write the code?

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to