Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111568 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 5872 invoked from network); 17 Aug 2020 05:18:24 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 17 Aug 2020 05:18:24 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 993491804AA for ; Sun, 16 Aug 2020 21:19:11 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,HTML_MESSAGE, SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-mahalux.mvorisek.com (mail-mahalux.mvorisek.com [77.93.195.127]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 16 Aug 2020 21:19:09 -0700 (PDT) Received: from a0bffc822dee (10.228.0.186) by mail-mahalux.mvorisek.com (10.228.0.4) with Microsoft SMTP Server (TLS); Mon, 17 Aug 2020 06:19:00 +0200 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="=_0b0ad5949608c68e1b755af850de49b7" Date: Mon, 17 Aug 2020 06:18:59 +0200 To: Josh Bruce Cc: Internals In-Reply-To: References: Message-ID: <747c6d622bbadebf32a8b7dec541c333eeb8776a6ab7ff0784a0b75c8895a646@mahalux.com> X-Mailer: SAP NetWeaver 7.03 Subject: Re: [PHP-DEV] [Concept] Don't cast keys in array to int From: vorismi3@fel.cvut.cz (=?UTF-8?Q?Michael_Vo=C5=99=C3=AD=C5=A1ek_-_=C4=8CVUT_FEL?=) --=_0b0ad5949608c68e1b755af850de49b7 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8; format=flowed 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 --=_0b0ad5949608c68e1b755af850de49b7--