@@ -58,7 +58,7 @@ class FlockMutex extends LockMutex
5858 * @param resource $fileHandle The file handle.
5959 * @param int $timeout
6060 */
61- public function __construct ($ fileHandle , $ timeout = self ::INFINITE_TIMEOUT )
61+ public function __construct ($ fileHandle , int $ timeout = self ::INFINITE_TIMEOUT )
6262 {
6363 if (!is_resource ($ fileHandle )) {
6464 throw new \InvalidArgumentException ("The file handle is not a valid resource. " );
@@ -85,7 +85,7 @@ private function determineLockingStrategy()
8585 /**
8686 * @throws LockAcquireException
8787 */
88- private function lockBlocking ()
88+ private function lockBlocking (): void
8989 {
9090 if (!flock ($ this ->fileHandle , LOCK_EX )) {
9191 throw new LockAcquireException ("Failed to lock the file. " );
@@ -96,13 +96,13 @@ private function lockBlocking()
9696 * @throws LockAcquireException
9797 * @throws TimeoutException
9898 */
99- private function lockPcntl ()
99+ private function lockPcntl (): void
100100 {
101101 $ timebox = new PcntlTimeout ($ this ->timeout );
102102
103103 try {
104104 $ timebox ->timeBoxed (
105- function () {
105+ function (): void {
106106 $ this ->lockBlocking ();
107107 }
108108 );
@@ -118,7 +118,7 @@ function () {
118118 private function lockBusy ()
119119 {
120120 $ loop = new Loop ($ this ->timeout );
121- $ loop ->execute (function () use ($ loop ) {
121+ $ loop ->execute (function () use ($ loop ): void {
122122 if ($ this ->acquireNonBlockingLock ()) {
123123 $ loop ->end ();
124124 }
@@ -129,7 +129,7 @@ private function lockBusy()
129129 * @return bool
130130 * @throws LockAcquireException
131131 */
132- private function acquireNonBlockingLock ()
132+ private function acquireNonBlockingLock (): bool
133133 {
134134 if (!flock ($ this ->fileHandle , LOCK_EX | LOCK_NB , $ wouldBlock )) {
135135 if ($ wouldBlock ) {
@@ -147,7 +147,7 @@ private function acquireNonBlockingLock()
147147 * @throws LockAcquireException
148148 * @throws TimeoutException
149149 */
150- protected function lock ()
150+ protected function lock (): void
151151 {
152152 switch ($ this ->strategy ) {
153153 case self ::STRATEGY_BLOCK :
@@ -167,7 +167,7 @@ protected function lock()
167167 /**
168168 * @throws LockReleaseException
169169 */
170- protected function unlock ()
170+ protected function unlock (): void
171171 {
172172 if (!flock ($ this ->fileHandle , LOCK_UN )) {
173173 throw new LockReleaseException ("Failed to unlock the file. " );
0 commit comments