Skip to content

Instantly share code, notes, and snippets.

@Muqsit
Created June 9, 2018 11:31
Show Gist options
  • Save Muqsit/da2595cc27e011b5ed35fc0e65d5ecb1 to your computer and use it in GitHub Desktop.
Save Muqsit/da2595cc27e011b5ed35fc0e65d5ecb1 to your computer and use it in GitHub Desktop.
<?php
class A {
/** @var \SplFixedArray */
public $array;
public function __construct(){
$this->array = new \SplFixedArray(1);
$b = new B();
$b->value = uniqid();
$this->array[0] = $b;
}
}
class B {
public $value;
}
$a = new A();
$a_clone = clone $a;
$a_clone->array[0]->value = uniqid();
var_dump([$a, $a_clone]);
//RESULT
array(2) {
[0]=>
object(A)#1 (1) {
["array"]=>
object(SplFixedArray)#2 (1) {
[0]=>
object(B)#3 (1) {
["value"]=>
string(13) "5b1bba5940d2f"
}
}
}
[1]=>
object(A)#4 (1) {
["array"]=>
object(SplFixedArray)#2 (1) {
[0]=>
object(B)#3 (1) {
["value"]=>
string(13) "5b1bba5940d2f"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment