This seems almost as a bug, strict types should apply also for array key
which is currently not the case.
https://3v4l.org/epv5s
With kind regards / Mit freundlichen Grüßen / S přátelským pozdravem,
Michael Voříšek
On 17 Aug 2020 02:56, Josh Bruce wrote:
I'm sure this conversation has happened before. But it's on my mind as I work
on some things on wanted to ask internals real quick before getting back to it.
["2" => "hello", "4" => "internals"] -> [2 => "hello", 4 => "internals"]
Meanwhile:
["hello", "internals"] -> cast to object -> ("0" => "hello", "2" => "internals")
Curious why this it's the case that specifically requesting a string be a key
that happens to be an integer, becomes an int type.
I kind of understand why in the case of object the implicit (PHP-established)
integers become strings.
And, of course, casting back puts us back to an indexed array. I've picked up
that type juggling might be a touchy point - but the focus is on why the key
gets cast at all when it's an array type.
Is it to facilitate the type juggle from an object to an array??
Cheers,
Josh
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php