There is such a code:
<?php // копирование свойств с одинаковыми именами class one { public $a; public $b; } class two { public $a; public $b; } $o = new one; $t = new two; $o->a = 1; $o->b = 2; $t->a = $o->a; $t->b = $o->b; // нужно заменить на одну операцию var_dump($o, $t); ?> As we see in the end, we have two different objects but with the same property names and their values. I would like to do the same, but without tediously copying the values of one property into a property of another object, provided that the objects have the same properties.