Bug #73686 [Opn->Ver]: Adding settype()ed values to ArrayObject results in references.

From: Date: Thu, 08 Dec 2016 19:24:20 +0000
Subject: Bug #73686 [Opn->Ver]: Adding settype()ed values to ArrayObject results in references.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-205859@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=73686&edit=1

 ID:                 73686
 Updated by:         cmb@php.net
 Reported by:        arjen at parse dot nl
 Summary:            Adding settype()ed values to ArrayObject results in
                     references.
-Status:             Open
+Status:             Verified
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   All
 PHP Version:        7.1.0
-Assigned To:        
+Assigned To:        dmitry
 Block user comment: N
 Private report:     N

 New Comment:

Thanks for properly reporting this issue here, Arjen!

Apparently, this bug has been introduced with commit eaf489ac[1]. Dmitry, could you please have a
look at this issue?

[1] <http://git.php.net/?p=php-src.git;a=commit;h=eaf489ac>


Previous Comments:
------------------------------------------------------------------------
[2016-12-08 13:37:25] arjen at parse dot nl

Description:
------------
Found at https://twitter.com/kozzi11/status/806828728890380288

https://3v4l.org/suHQh

Removing the settype() call produces the expected output.

Test script:
---------------
<?php

$ao = new ArrayObject;

foreach ([1, 2, 3] as $i => $var)
{
    settype($var, 'string');
    $ao[$i] = $var;
}

var_dump($ao);

Expected result:
----------------
Output for 5.6.0 - 5.6.28, hhvm-3.12.0 - 3.13.2, 7.0.0 - 7.0.14

object(ArrayObject)#1 (1) {
  ["storage":"ArrayObject":private]=>
  array(3) {
    [0]=>
    string(1) "1"
    [1]=>
    string(1) "2"
    [2]=>
    string(1) "3"
  }
}

Actual result:
--------------
Output for 7.1.0

object(ArrayObject)#1 (1) {
  ["storage":"ArrayObject":private]=>
  array(3) {
    [0]=>
    &string(1) "3"
    [1]=>
    &string(1) "3"
    [2]=>
    &string(1) "3"
  }
}


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



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


Thread (3 messages)

« previous php.bugs (#205859) next »