From 523e13c122e4321d8e06636f28d42cbf56a3f268 Mon Sep 17 00:00:00 2001 From: Sven Rautenberg Date: Tue, 14 Jan 2025 15:31:07 +0000 Subject: [PATCH] Add a closure to the TestObjectCache The closure prevents the object from getting serialized, which should not happen during tests, as the ObjectCache code path must not serialize the object. Signed-off-by: Sven Rautenberg --- test/Pattern/TestAsset/TestObjectCache.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/Pattern/TestAsset/TestObjectCache.php b/test/Pattern/TestAsset/TestObjectCache.php index bc83a92e..ec4e0bda 100644 --- a/test/Pattern/TestAsset/TestObjectCache.php +++ b/test/Pattern/TestAsset/TestObjectCache.php @@ -22,6 +22,13 @@ final class TestObjectCache /** @var string */ public $property = 'testProperty'; + private \Closure $closure; + + public function __construct() + { + // Closures prevent serialization - this acts as a detector to verify this object is not serialized during test. + $this->closure = function () {}; + } public function bar(): string { ++static::$fooCounter;