1 | <?php |
||
42 | class FileMutex extends Mutex |
||
43 | { |
||
44 | use RetryAcquireTrait; |
||
45 | |||
46 | /** |
||
47 | * @var string the directory to store mutex files. You may use [path alias](guide:concept-aliases) here. |
||
48 | * Defaults to the "mutex" subdirectory under the application runtime path. |
||
49 | */ |
||
50 | public $mutexPath = '@runtime/mutex'; |
||
51 | /** |
||
52 | * @var int the permission to be set for newly created mutex files. |
||
53 | * This value will be used by PHP chmod() function. No umask will be applied. |
||
54 | * If not set, the permission will be determined by the current environment. |
||
55 | */ |
||
56 | public $fileMode; |
||
57 | /** |
||
58 | * @var int the permission to be set for newly created directories. |
||
59 | * This value will be used by PHP chmod() function. No umask will be applied. |
||
60 | * Defaults to 0775, meaning the directory is read-writable by owner and group, |
||
61 | * but read-only for other users. |
||
62 | */ |
||
63 | public $dirMode = 0775; |
||
64 | /** |
||
65 | * @var bool whether file handling should assume a Windows file system. |
||
66 | * This value will determine how [[releaseLock()]] goes about deleting the lock file. |
||
67 | * If not set, it will be determined by checking the DIRECTORY_SEPARATOR constant. |
||
68 | * @since 2.0.16 |
||
69 | */ |
||
70 | public $isWindows; |
||
71 | |||
72 | /** |
||
73 | * @var resource[] stores all opened lock files. Keys are lock names and values are file handles. |
||
74 | */ |
||
75 | private $_files = []; |
||
76 | |||
77 | |||
78 | /** |
||
79 | * Initializes mutex component implementation dedicated for UNIX, GNU/Linux, Mac OS X, and other UNIX-like |
||
80 | * operating systems. |
||
81 | * @throws InvalidConfigException |
||
82 | */ |
||
83 | 13 | public function init() |
|
94 | |||
95 | /** |
||
96 | * Acquires lock by given name. |
||
97 | * @param string $name of the lock to be acquired. |
||
98 | * @param int $timeout time (in seconds) to wait for lock to become released. |
||
99 | * @return bool acquiring result. |
||
100 | */ |
||
101 | 13 | protected function acquireLock($name, $timeout = 0) |
|
140 | |||
141 | /** |
||
142 | * Releases lock by given name. |
||
143 | * @param string $name of the lock to be released. |
||
144 | * @return bool release result. |
||
145 | */ |
||
146 | 13 | protected function releaseLock($name) |
|
169 | |||
170 | /** |
||
171 | * Generate path for lock file. |
||
172 | * @param string $name |
||
173 | * @return string |
||
174 | * @since 2.0.10 |
||
175 | */ |
||
176 | 13 | protected function getLockFilePath($name) |
|
180 | } |
||
181 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.