nikic/scalar_objects

Can't mutate pseudo-object array

puppe0 opened this issue · 1 comments

Hi,

I'm prototyping an array pseudo-object and ran into a problem with mutating the array. It seems the current implementation doesn't allow mutation of the autoboxed value.

For example this code:

<?php

class ArrayHandler {
    public function pop() {
        return array_pop($this);
    }
}

register_primitive_type_handler('array', 'ArrayHandler');

$array = ['foo'];
$array->pop(); // Array should be empty now

var_dump($array);

Returns:

array(1) {
  [0]=>
  string(3) "foo"
}

Thanks for the report! This is now fixed (see a39f156).