Bug #63217 [Ana->Csd]: Constant numeric strings become integers when used as ArrayAccess offset

From: Date: Mon, 02 Jul 2018 14:43:42 +0000
Subject: Bug #63217 [Ana->Csd]: Constant numeric strings become integers when used as ArrayAccess offset
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-216071@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=63217&edit=1

 ID:                 63217
 Updated by:         nikic@php.net
 Reported by:        kmsheng at pixnet dot tw
 Summary:            Constant numeric strings become integers when used
                     as ArrayAccess offset
-Status:             Analyzed
+Status:             Closed
 Type:               Bug
 Package:            Arrays related
 Operating System:   freebsd
 PHP Version:        5.4Git-2012-10-04 (Git)
 Block user comment: N
 Private report:     N

 New Comment:

Automatic comment on behalf of rudolf.theunissen@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=30156d588c07e26d4e752ddb62344e96854d4773
Log: Fixed bug #63217


Previous Comments:
------------------------------------------------------------------------
[2018-02-23 00:11:08] requinix@php.net

Related To: Bug #75998

------------------------------------------------------------------------
[2017-06-18 05:46:01] a dot schilder at gmx dot de

I also ran into this problem and found another strange behavior within it (PHP 7.1.x):

When I use $object["0"], the offset is int(0).

When I use $object[(string)"0"], offset is sometimes string(1) "0", sometimes
int(0), without a recognizable pattern.

------------------------------------------------------------------------
[2017-05-26 15:31:10] ajf@php.net

Removing myself from being assigned to this. I could fix it, but I lost interest in doing so for the
most part.

------------------------------------------------------------------------
[2016-04-04 04:20:48] whatchildisthis at gmail dot com

Examples using expressions:

<?php
$test["1" . "0"]; // int(10) expect string(2) "10"
$test[1 + 0 . "0"]; // int(10) expect string(2) "10"
$test[<<<_
10
_
]; // int(10) expect string (2) "10"
$test[(string) "10"]; // only one that worked, string(2) "10"
?>

------------------------------------------------------------------------
[2015-11-24 17:23:15] ajf@php.net

I updated the title to better describe the bug.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=63217


--
Edit this bug report at https://bugs.php.net/bug.php?id=63217&edit=1


Thread (7 messages)

« previous php.bugs (#216071) next »