Re: Proposal: AS assertions
| From: | Marco Pivetta | Date: | Tue, 19 Mar 2024 16:52:41 +0000 |
| Subject: | Re: Proposal: AS assertions | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-122691@lists.php.net to get a copy of this message | ||
On Tue, 19 Mar 2024 at 17:46, Deleu <deleugyn@gmail.com> wrote:
> On Tue, Mar 19, 2024 at 1:42 PM Marco Pivetta <ocramius@gmail.com> wrote:
>
>> One note: if what you are going for is what
azjezz/psl, be
>> aware that
>> exception / error tracing design needs special attention here: it's not as
>> simple as it looks!
>>
>
> I believe you answered your own question here. The proposal seems far
> simpler and reaches 100% of PHP projects as opposed to the ones that either
> opt to use psalm or opt to use azjezz/psl.
>
Eh, kinda: you'd need to check how Psl\Type\TypeInterface recursively
validates types and throws meaningful errors.
Having that in the engine, given its structure, is a massive BC surface
that is best kept as a composer dependency that can move separately.
I hardly see that working in a language-level RFC, with the speed at which
the language can do BC incompatible changes.
See
https://github.com/azjezz/psl/blob/5f0aeacb708a33d5b2d53a832736c7767a99b215/src/Psl/Type/TypeInterface.php#L21-L35
See
https://github.com/azjezz/psl/blob/5f0aeacb708a33d5b2d53a832736c7767a99b215/src/Psl/Type/Exception/CoercionException.php#L49
See
https://github.com/azjezz/psl/blob/5f0aeacb708a33d5b2d53a832736c7767a99b215/src/Psl/Type/Exception/Exception.php#L22
See
https://github.com/azjezz/psl/blob/5f0aeacb708a33d5b2d53a832736c7767a99b215/src/Psl/Type/Exception/TypeTrace.php
That stuff is all but figured out, even in userland :-)
Also worth mentioning:
https://github.com/CuyZ/Valinor/blob/37993b64a6eb04dc0aee79e03f2ddb4f86ff9c3a/src/Mapper/TreeMapper.php#L23-L25
https://github.com/CuyZ/Valinor/blob/37993b64a6eb04dc0aee79e03f2ddb4f86ff9c3a/src/Mapper/MappingError.php#L13
and the whole rabbit hole behind that
Marco Pivetta
https://mastodon.social/@ocramius
https://ocramius.github.io/