Get changes from a Doctrine entity

Code
<?php

use PHPSnippets\Db\Entity\Test;

/* @var $em Doctrine\ORM\EntityManager */
$uow $em->getUnitOfWork();

$entityChanges = function ($entity) use ($em$uow) {
    
// compute changes into changeset
    
$uow->computeChangeSet(
        
$em->getClassMetadata(Test::CLASS),
        
$entity
    
);

    echo 
'Is entity scheduled for update, delete, etc.?';
    
dump($uow->isEntityScheduled($entity));
    echo 
'What changed in entity (value before/after)?';
    
dump($uow->getEntityChangeSet($entity));
};

// get Test entity with id 1
$entity $em->find(Test::CLASS, 1);
dump($entity);

echo 
'<b>Set same value for entity name</b>' PHP_EOL;
$entity->name 'foo';
$entityChanges($entity);

echo 
'<b>Change value of name</b>' PHP_EOL;
$entity->name 'foobar';
$entityChanges($entity);

echo 
'<b>Change name again and date value</b>' PHP_EOL;
$entity->name 'foobar2';
$entity->creationDate = new DateTime();
$entityChanges($entity);
Result
Test {#399
+id: 1
+name: "foo"
+creationDate: DateTime @1405849049 {#388
date: 2014-07-20 11:37:29.0 Europe/Berlin (+02:00)
}
+subTests: PersistentCollection {#403
-snapshot: []
-owner: Test {#399}
-association: array:15 [ …15]
-em: EntityManager {#342 …11}
-backRefFieldName: "test"
-typeClass: ClassMetadata {#401 …}
-isDirty: false
#collection: ArrayCollection {#406
-elements: []
}
#initialized: false
}
}

Set same value for entity name
Is entity scheduled for update, delete, etc.?
false

What changed in entity (value before/after)?
[]

Change value of name
Is entity scheduled for update, delete, etc.?
true

What changed in entity (value before/after)?
array:1 [
"name" => array:2 [
0 => "foo"
1 => "foobar"
]
]

Change name again and date value
Is entity scheduled for update, delete, etc.?
true

What changed in entity (value before/after)?
array:2 [
"name" => array:2 [
0 => "foobar"
1 => "foobar2"
]
"creationDate" => array:2 [
0 => DateTime @1405849049 {#388
date: 2014-07-20 11:37:29.0 Europe/Berlin (+02:00)
}
1 => DateTime @1544635717 {#413
date: 2018-12-12 18:28:37.121971 Europe/Berlin (+01:00)
}
]
]
Used Versions
PHP 7.2, Zend 3.0, Symfony 4.0, Laravel 5.6, PHPUnit 6.5, Doctrine 2.8