Skip to content

Commit

Permalink
Add a closure to the TestObjectCache
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
SvenRtbg committed Jan 14, 2025
1 parent d776470 commit 523e13c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/Pattern/TestAsset/TestObjectCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ final class TestObjectCache
/** @var string */
public $property = 'testProperty';

private \Closure $closure;

Check failure on line 25 in test/Pattern/TestAsset/TestObjectCache.php

View workflow job for this annotation

GitHub Actions / ci / QA Checks (PHPCodeSniffer [8.1, locked], ubuntu-latest, laminas/laminas-continuous-integration-ac...

Class \Closure should not be referenced via a fully qualified name, but via a use statement.

Check failure on line 25 in test/Pattern/TestAsset/TestObjectCache.php

View workflow job for this annotation

GitHub Actions / ci / QA Checks (Psalm [8.1, locked], ubuntu-latest, laminas/laminas-continuous-integration-action@v1, ...

UnusedProperty

test/Pattern/TestAsset/TestObjectCache.php:25:22: UnusedProperty: Cannot find any references to private property LaminasTest\Cache\Pattern\TestAsset\TestObjectCache::$closure (see https://psalm.dev/150)

public function __construct()
{
// Closures prevent serialization - this acts as a detector to verify this object is not serialized during test.
$this->closure = function () {};

Check failure on line 30 in test/Pattern/TestAsset/TestObjectCache.php

View workflow job for this annotation

GitHub Actions / ci / QA Checks (PHPCodeSniffer [8.1, locked], ubuntu-latest, laminas/laminas-continuous-integration-ac...

Closing brace must be on a line by itself

Check failure on line 30 in test/Pattern/TestAsset/TestObjectCache.php

View workflow job for this annotation

GitHub Actions / ci / QA Checks (Psalm [8.1, locked], ubuntu-latest, laminas/laminas-continuous-integration-action@v1, ...

MissingClosureReturnType

test/Pattern/TestAsset/TestObjectCache.php:30:26: MissingClosureReturnType: Closure does not have a return type, expecting void (see https://psalm.dev/068)
}

Check failure on line 31 in test/Pattern/TestAsset/TestObjectCache.php

View workflow job for this annotation

GitHub Actions / ci / QA Checks (PHPCodeSniffer [8.1, locked], ubuntu-latest, laminas/laminas-continuous-integration-ac...

Expected 1 blank line after method; 0 found
public function bar(): string
{
++static::$fooCounter;
Expand Down

0 comments on commit 523e13c

Please sign in to comment.