LL: add class InvalidEncodingException and flag VALIDATE_UTF8_ENCODING#91
Conversation
…G to call validateUTF8Encoding() function.
|
See #52 |
|
This is a first draft. |
|
I think it looks ok (the exception message). Having some unit tests definitely would help tho. |
…ng for the class InvalidEncodingException.
c359e25 to
a9c2a52
Compare
b66acf9 to
82ca084
Compare
… repository, and re?correct bug when some continuation octet is still needed at end of string as suggested by Jordi Boggiano.
82ca084 to
4f3f03b
Compare
…ues for UTF-8 first octet of sequences of 4 octets.
4f3f03b to
04efacd
Compare
…629 : The definition of UTF-8 prohibits encoding character numbers between U+D800 and U+DFFF, which are reserved for use with the UTF-16 encoding form (as surrogate pairs) and do not directly represent characters.
9ade89f to
202ff29
Compare
| /** | ||
| * @var array{key: string, line: int} | ||
| */ | ||
| protected $details; |
There was a problem hiding this comment.
Yep, probably no further specialization of this exception will be done in the code.
Since the PR is already merged, I will prepare another PR to address your remarks that are not already dealed with.
There was a problem hiding this comment.
even if specialization is done, the child class can use the getter if it needs to read it.
Btw, I'm not even sure whether those details are useful. I fail to see what they bring compared to the message.
There was a problem hiding this comment.
even if specialization is done, the child class can use the getter if it needs to read it.
Ok, but you can't overwrite the PHPDoc in that case, if you want distinct keys in the details array after specialization.
Btw, I'm not even sure whether those details are useful. I fail to see what they bring compared to the message.
Noob ;). You always need the strongly typed data instead of a hotchpotch string if you want to do further error handling of the exception and some automatized recovery after failure instead of just printing the message of the exception :).
There was a problem hiding this comment.
Ok, but you can't overwrite the PHPDoc in that case, if you want distinct keys in the details array after specialization.
Changing the type of a property in a child class does not respect variance rules anyway.
And I don't see the use case anyway for specializing the class: the library will not use your special child class as it won't know about it.
There was a problem hiding this comment.
Then you need to talk with @Seldaek about variance rules, because currently it already overrides ParsingException:
class ParsingException extends \Exception
{
/**
* @var array{text?: string, token?: string|int, line?: int, loc?: array{first_line: int, first_column: int, last_line: int, last_column: int}, expected?: string[]}
*/
protected $details;
I assumed array type hint was enough.
Feel free to propose a PR for "the details" ;).
I will mess up with the tests in the meantime :).
to call validateUTF8Encoding() function.