Hello!
I have following example:
$value1 = [
'name' => 'Name',
'value' => 30000,
'clients' => [
[
'name' => 'Client name 1',
'documents' => [
[
'name' => 'Document name 1',
'attributes' => [
[
'name' => 'Attribute 1',
],
],
],
],
],
],
];
$value2 = $value1;
$value2['name'] = 'New name';
$value2['clients'][0]['name'] = 'Client name 1!';
$value2['clients'][0]['documents'][0]['name'] = 'Document name 1!';
$value2['clients'][0]['documents'][0]['attributes'][0]['name'] = 'Attribute 1!';
To make it work I either should know depth
$differ = new \Diff\Differ\MapDiffer(
true,
new \Diff\Differ\MapDiffer(
true,
new \Diff\Differ\MapDiffer(/** ... */)
)
);
or use reflection to instantiate $differ
$differ = new \Diff\Differ\MapDiffer(true);
$reflectionClass = new ReflectionClass(\Diff\Differ\MapDiffer::class);
$reflectionProperty = $reflectionClass->getProperty('listDiffer');
$reflectionProperty->setAccessible(true);
$reflectionProperty->setValue($differ, $differ);
Looks like we need to add a setter for $listDiffer or change constructor to
public function __construct( bool $recursively = false, Differ $listDiffer = null, ValueComparer $comparer = null ) {
$this->recursively = $recursively;
$this->listDiffer = $listDiffer ?? $this;
$this->valueComparer = $comparer ?? new StrictComparer();
}
Hello!
I have following example:
To make it work I either should know depth
or use reflection to instantiate
$differLooks like we need to add a setter for
$listDifferor change constructor to