Skip to content

Commit 392cf85

Browse files
Add validation of the returned locks
1 parent 870a973 commit 392cf85

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/Symfony/Component/Semaphore/Store/LockStore.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ public function putOffExpiration(Key $key, float $ttlInSecond): void
8181
}
8282

8383
/**
84-
* @return iterable<LockInterface>
84+
* @return array<LockInterface>
8585
*/
86-
private function getLocks(Key $key, float $ttlInSecond, bool $create): iterable
86+
private function getLocks(Key $key, float $ttlInSecond, bool $create): array
8787
{
8888
$lockName = base64_encode($key->__toString());
8989

@@ -118,6 +118,15 @@ private function getLocks(Key $key, float $ttlInSecond, bool $create): iterable
118118
$key->setState(__CLASS__, $locks);
119119
} elseif ($key->hasState(__CLASS__)) {
120120
$locks = $key->getState(__CLASS__);
121+
\assert((function () use ($locks) {
122+
foreach ($locks as $lock) {
123+
if (!$lock instanceof LockInterface) {
124+
return false;
125+
}
126+
}
127+
128+
return true;
129+
})() === true, 'Locks must be an array of LockInterface');
121130
}
122131

123132
return $locks;

0 commit comments

Comments
 (0)