On Wed, Aug 30, 2023 at 7:14 AM Saki Takamachi <s...@sakiot.com> wrote:

> I accidentally wrote the name in Japanese and it looks weird, so I'll
> resend it, sorry.
>
> I also skimmed over past discussions.
>
> I've found that having full control over `strict_types` globally is not a
> good idea. This is because it can break the behavior of many libraries, and
> developers don't always respond appropriately to this fix.
>
> So I came up with the following idea.
> Allows a new value of 2 for strict_types.
>
> However, since magic numbers make the code difficult to read, I thought it
> would be a good idea to also provide strings that can serve as constants
> and aliases.
>
> This could provide new options to users while safely maintaining backwards
> compatibility.
>
> example:
> ```
> // weak
> declare(strict_types=0);
> declare(strict_types='weak');
> declare(strict_types=STRICT_TYPE_MODE_WEAK);
>
> // strict
> declare(strict_types=1);
> declare(strict_types='strict');
> declare(strict_types=STRICT_TYPE_MODE_STRICT);
>
> // strict with internal func
> declare(strict_types=2);
> declare(strict_types='strict_with_internal_func');
> declare(strict_types=STRICT_TYPE_MODE_WITH_INTERNAL_FUNC);
> ```
>
> I need more time to come up with a better name.
>
> Saki
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: https://www.php.net/unsub.php
>
>
I'm not entirely sure if this is 100% related, but it seems to be.

If you don't declare "strict_types" and pass a Stringable instance as the
first argument to json_decode, it works as expected [1].

On the other hand, when you declare "strict_types" and pass a Stringable
instance as the first argument to json_decode, it fails [2].

Fatal error: Uncaught TypeError: json_decode(): Argument #1 ($json) must be
> of type string, strcls given
>

[1] https://3v4l.org/TXAUi
[2] https://3v4l.org/uEhbM

-- 
Atenciosamente,

    Flávio Heleno

Reply via email to