Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
27c6110
chore: fix ci deprecations
Chris8934 Feb 7, 2024
2f52946
Merge pull request #193 from Chris53897/feature/improve-ci
mnapoli Feb 10, 2024
57f2365
Ignore `readonly` properties
llupa Jun 3, 2024
4e89dc3
Ignore `readonly` properties
llupa Jun 3, 2024
156b10c
Update DeepCopyTest.php
llupa Jun 3, 2024
3306d5f
Add test fixtures
llupa Jun 12, 2024
3a6b9a4
Merge pull request #195 from llupa/readonly-properties
mnapoli Jun 12, 2024
47aebd6
bug: #196 Introduce a custom DatePeriodFilter that safely copies Date…
michalananapps Nov 6, 2024
bed190b
bug: #196 support php7.1
michalananapps Nov 7, 2024
123267b
Merge pull request #197 from michalananapps/copy-DatePeriod
mnapoli Nov 8, 2024
67ebab1
Run tests on PHP 8.4
alamirault Nov 25, 2024
4764e04
Merge pull request #198 from alamirault/feature/add-tests-php-84
mnapoli Nov 26, 2024
2356a16
Add PrependTypeFilter method
alexz707 Feb 11, 2025
024473a
Merge pull request #202 from alexz707/add-prepend-type-filter
mnapoli Feb 12, 2025
3424b4d
Fix return types for Doctrine\Persistence\Proxy implementations
SpazzMarticus Apr 29, 2025
1720ddd
Merge pull request #203 from SpazzMarticus/fix-return-types-for-doctr…
mnapoli Apr 29, 2025
f13e8ee
Add generic to DeepCopy::copy method
ruudk Jul 3, 2025
d25e62e
Merge pull request #205 from ruudk/patch-1
mnapoli Jul 4, 2025
4f05aba
Change TObject to mixed
ruudk Jul 5, 2025
faed855
Merge pull request #206 from ruudk/patch-2
mnapoli Jul 5, 2025
8c42cfd
setAccessible() has no effect as of PHP 8.1
W0rma Aug 1, 2025
07d290f
Merge pull request #207 from W0rma/reflection-set-accessible
mnapoli Aug 1, 2025
8f6a6df
Merge tag '1.13.4' into feature/bum-1.13.1
CharloMez Mar 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions fixtures/f013/A.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace DeepCopy\f013;

use BadMethodCallException;
use Doctrine\Persistence\Proxy;

class A implements Proxy
Expand All @@ -11,14 +12,15 @@ class A implements Proxy
/**
* @inheritdoc
*/
public function __load()
public function __load(): void
{
}

/**
* @inheritdoc
*/
public function __isInitialized()
public function __isInitialized(): bool
{
throw new BadMethodCallException();
}
}
6 changes: 4 additions & 2 deletions fixtures/f013/B.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace DeepCopy\f013;

use BadMethodCallException;
use Doctrine\Persistence\Proxy;

class B implements Proxy
Expand All @@ -11,15 +12,16 @@ class B implements Proxy
/**
* @inheritdoc
*/
public function __load()
public function __load(): void
{
}

/**
* @inheritdoc
*/
public function __isInitialized()
public function __isInitialized(): bool
{
throw new BadMethodCallException();
}

public function getFoo()
Expand Down
10 changes: 7 additions & 3 deletions src/DeepCopy/DeepCopy.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,11 @@ public function skipUncloneable($skipUncloneable = true)
/**
* Deep copies the given object.
*
* @param mixed $object
* @template TObject
*
* @return mixed
* @param TObject $object
*
* @return TObject
*/
public function copy($object)
{
Expand Down Expand Up @@ -270,7 +272,9 @@ function ($object) {
}
}

$property->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$property->setAccessible(true);
}

// Ignore uninitialized properties (for PHP >7.4)
if (method_exists($property, 'isInitialized') && !$property->isInitialized($object)) {
Expand Down
4 changes: 3 additions & 1 deletion src/DeepCopy/Filter/Doctrine/DoctrineCollectionFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ public function apply($object, $property, $objectCopier)
{
$reflectionProperty = ReflectionHelper::getProperty($object, $property);

$reflectionProperty->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$reflectionProperty->setAccessible(true);
}
$oldCollection = $reflectionProperty->getValue($object);

$newCollection = $oldCollection->map(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ class DoctrineEmptyCollectionFilter implements Filter
public function apply($object, $property, $objectCopier)
{
$reflectionProperty = ReflectionHelper::getProperty($object, $property);
$reflectionProperty->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$reflectionProperty->setAccessible(true);
}

$reflectionProperty->setValue($object, new ArrayCollection());
}
Expand Down
4 changes: 3 additions & 1 deletion src/DeepCopy/Filter/ReplaceFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ public function __construct(callable $callable)
public function apply($object, $property, $objectCopier)
{
$reflectionProperty = ReflectionHelper::getProperty($object, $property);
$reflectionProperty->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$reflectionProperty->setAccessible(true);
}

$value = call_user_func($this->callback, $reflectionProperty->getValue($object));

Expand Down
4 changes: 3 additions & 1 deletion src/DeepCopy/Filter/SetNullFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ public function apply($object, $property, $objectCopier)
{
$reflectionProperty = ReflectionHelper::getProperty($object, $property);

$reflectionProperty->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$reflectionProperty->setAccessible(true);
}
$reflectionProperty->setValue($object, null);
}
}
4 changes: 3 additions & 1 deletion src/DeepCopy/Matcher/PropertyTypeMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ public function matches($object, $property)
return false;
}

$reflectionProperty->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$reflectionProperty->setAccessible(true);
}

// Uninitialized properties (for PHP >7.4)
if (method_exists($reflectionProperty, 'isInitialized') && !$reflectionProperty->isInitialized($object)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ class FooProxy implements Proxy
/**
* @inheritdoc
*/
public function __load()
public function __load(): void
{
throw new BadMethodCallException();
}

/**
* @inheritdoc
*/
public function __isInitialized()
public function __isInitialized(): bool
{
throw new BadMethodCallException();
}
Expand Down