|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2014-06-10 18:45 UTC] aharvey@php.net
-Status: Open
+Status: Not a bug
[2014-06-10 18:45 UTC] aharvey@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 12:00:01 2025 UTC |
Description: ------------ Basically i get "aaa" and "bbb" automatically updated also in the content object of the first $p If i clone the var on return i can solve this, but i didn't understood why Test script: --------------- abstract class Tag { protected $content = []; private function parse ($var) { return ($var instanceof Tag) ? $var : (string)$var; } public function add_content() { $this->content[] = array_map([$this,'parse'],func_get_args()); } } class p extends Tag { } $p = new p; $p2 = new p; $p->add_content($p2); $p2->add_content("aaa", "bbb"); print_r($p); Expected result: ---------------- p Object ( [content:protected] => Array ( [0] => Array ( [0] => p Object ( [content:protected] => Array ( ) ) ) ) ) Actual result: -------------- p Object ( [content:protected] => Array ( [0] => Array ( [0] => p Object ( [content:protected] => Array ( [0] => Array ( [0] => aaa [1] => bbb ) ) ) ) ) )