Skip to content

Commit 016387c

Browse files
committed
Add scalar type hints, slight change of wording
1 parent fcda71d commit 016387c

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

lib/internal/Magento/Framework/Lock/Backend/Database.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@
44
* See COPYING.txt for license details.
55
*/
66

7+
declare(strict_types=1);
78
namespace Magento\Framework\lock\Backend;
89

10+
use Magento\Framework\App\ResourceConnection;
11+
912
class Database implements \Magento\Framework\Lock\LockManagerInterface
1013
{
11-
/** @var \Magento\Framework\App\ResourceConnection */
14+
/** @var ResourceConnection */
1215
private $resource;
1316

1417
public function __construct(
15-
\Magento\Framework\App\ResourceConnection $resource
18+
ResourceConnection $resource
1619
)
1720
{
1821
$this->resource = $resource;
@@ -22,9 +25,10 @@ public function __construct(
2225
* Sets a lock for name
2326
*
2427
* @param string $name lock name
28+
* @param int $timeout How long to wait lock acquisition in seconds, negative value means infinite timeout
2529
* @return bool
2630
*/
27-
public function setLock($name, $timeout = -1)
31+
public function setLock(string $name, int $timeout = -1): bool
2832
{
2933
return (bool)$this->resource->getConnection()->query("SELECT GET_LOCK(?, ?);", array((string)$name, (int)$timeout))
3034
->fetchColumn();
@@ -36,7 +40,7 @@ public function setLock($name, $timeout = -1)
3640
* @param string $name lock name
3741
* @return bool
3842
*/
39-
public function releaseLock($name)
43+
public function releaseLock(string $name): bool
4044
{
4145
return (bool)$this->resource->getConnection()->query("SELECT RELEASE_LOCK(?);", array((string)$name))->fetchColumn();
4246
}
@@ -47,7 +51,7 @@ public function releaseLock($name)
4751
* @param string $name lock name
4852
* @return bool
4953
*/
50-
public function isLocked($name)
54+
public function isLocked(string $name): bool
5155
{
5256
return (bool)$this->resource->getConnection()->query("SELECT IS_USED_LOCK(?);", array((string)$name))->fetchColumn();
5357
}

lib/internal/Magento/Framework/Lock/LockManagerInterface.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
7+
declare(strict_types=1);
68
namespace Magento\Framework\Lock;
79

810
/**
@@ -13,29 +15,30 @@
1315
interface LockManagerInterface
1416
{
1517
/**
16-
* Sets a lock for name
18+
* Sets a lock
1719
*
1820
* @param string $name lock name
19-
* @param int $timeout Timeout in seconds, negative value means infinite timeout
21+
* @param int $timeout How long to wait lock acquisition in seconds, negative value means infinite timeout
2022
* @return bool
23+
* @api
2124
*/
22-
public function setLock($name, $timeout = -1);
25+
public function setLock(string $name, int $timeout = -1): bool;
2326

2427
/**
25-
* Releases a lock for name
28+
* Releases a lock
2629
*
2730
* @param string $name lock name
2831
* @return bool
2932
* @api
3033
*/
31-
public function releaseLock($name);
34+
public function releaseLock(string $name): bool;
3235

3336
/**
34-
* Tests of lock is set for name
37+
* Tests if lock is set
3538
*
3639
* @param string $name lock name
3740
* @return bool
3841
* @api
3942
*/
40-
public function isLocked($name);
43+
public function isLocked(string $name): bool;
4144
}

0 commit comments

Comments
 (0)