@@ -128,7 +128,7 @@ public function __destruct()
128128 *
129129 * @return void
130130 */
131- public function destroyWorkerPools ()
131+ public function destroyWorkerPools (): void
132132 {
133133 // Destroy any worker pools
134134 if (!empty ($ this ->workerPools )) {
@@ -157,12 +157,12 @@ public function destroyWorkerPools()
157157 * @return void
158158 */
159159 public function createWorkerPool (
160- $ poolId ,
161- $ processes ,
162- $ maxQueue ,
160+ string $ poolId ,
161+ int $ processes ,
162+ int $ maxQueue ,
163163 callable $ runMethod ,
164164 ?callable $ initMethod = null
165- ) {
165+ ): void {
166166 if (isset ($ this ->workerPoolRunMethods [$ poolId ])) {
167167 // Already initialized
168168 return ;
@@ -257,7 +257,7 @@ public function createWorkerPool(
257257 *
258258 * @return bool
259259 */
260- public function hasWorkerPool ($ poolId )
260+ public function hasWorkerPool (string $ poolId ): bool
261261 {
262262 return !empty ($ this ->workerPools [$ poolId ]);
263263 }
@@ -269,7 +269,7 @@ public function hasWorkerPool($poolId)
269269 *
270270 * @return void
271271 */
272- public function addRequest ($ poolId/*, ... */ )
272+ public function addRequest (string $ poolId/*, ... */ ): void
273273 {
274274 $ args = func_get_args ();
275275 array_shift ($ args );
@@ -302,7 +302,7 @@ public function addRequest($poolId/*, ... */)
302302 *
303303 * @return void
304304 */
305- public function handleRequests ($ poolId )
305+ public function handleRequests (string $ poolId ): void
306306 {
307307 if (empty ($ this ->workerPools [$ poolId ])) {
308308 return ;
@@ -334,7 +334,7 @@ public function handleRequests($poolId)
334334 *
335335 * @return bool
336336 */
337- public function requestsPending ($ poolId )
337+ public function requestsPending (string $ poolId ): bool
338338 {
339339 $ this ->handleRequests ($ poolId );
340340 $ this ->checkForStoppedWorkers ();
@@ -349,7 +349,7 @@ public function requestsPending($poolId)
349349 *
350350 * @return bool
351351 */
352- public function requestsActive ($ poolId )
352+ public function requestsActive (string $ poolId ): bool
353353 {
354354 $ this ->handleRequests ($ poolId );
355355 if (empty ($ this ->workerPools [$ poolId ])) {
@@ -370,7 +370,7 @@ public function requestsActive($poolId)
370370 *
371371 * @return void
372372 */
373- public function waitUntilDone ($ poolId )
373+ public function waitUntilDone (string $ poolId ): void
374374 {
375375 while ($ this ->requestsPending ($ poolId )) {
376376 usleep (1000 );
@@ -384,7 +384,7 @@ public function waitUntilDone($poolId)
384384 *
385385 * @return bool
386386 */
387- public function checkForResults ($ poolId )
387+ public function checkForResults (string $ poolId ): bool
388388 {
389389 if (!empty ($ this ->workerPools [$ poolId ])) {
390390 foreach ($ this ->workerPools [$ poolId ] as &$ worker ) {
@@ -411,7 +411,7 @@ public function checkForResults($poolId)
411411 *
412412 * @return mixed
413413 */
414- public function getResult ($ poolId )
414+ public function getResult (string $ poolId ): mixed
415415 {
416416 if (empty ($ this ->results [$ poolId ])) {
417417 return null ;
@@ -424,11 +424,11 @@ public function getResult($poolId)
424424 *
425425 * @param mixed $socket Socket
426426 * @param bool $block Whether to block waiting for data
427- * @param bool $checkParent Whether to chek that the parent process is alive
427+ * @param bool $checkParent Whether to check that the parent process is alive
428428 *
429429 * @return mixed
430430 */
431- public function readSocket ($ socket , $ block = false , $ checkParent = false )
431+ public function readSocket (mixed $ socket , bool $ block = false , bool $ checkParent = false ): mixed
432432 {
433433 $ msgLen = '' ;
434434 $ received = 0 ;
@@ -521,7 +521,7 @@ public function readSocket($socket, $block = false, $checkParent = false)
521521 *
522522 * @return bool
523523 */
524- public function writeSocket ($ socket , $ data , $ checkParent = false )
524+ public function writeSocket (mixed $ socket , mixed $ data , bool $ checkParent = false ): bool
525525 {
526526 $ message = serialize ($ data );
527527 $ length = strlen ($ message );
@@ -578,7 +578,7 @@ public function writeSocket($socket, $data, $checkParent = false)
578578 *
579579 * @return void
580580 */
581- public function signalHandler ($ signo )
581+ public function signalHandler ($ signo ): void
582582 {
583583 if (SIGCHLD == $ signo ) {
584584 $ this ->reapChildren ();
@@ -590,7 +590,7 @@ public function signalHandler($signo)
590590 *
591591 * @return void
592592 */
593- protected function reapChildren ()
593+ protected function reapChildren (): void
594594 {
595595 do {
596596 $ found = false ;
@@ -616,7 +616,7 @@ protected function reapChildren()
616616 * @return void
617617 * @throws \Exception
618618 */
619- protected function checkForStoppedWorkers ()
619+ protected function checkForStoppedWorkers (): void
620620 {
621621 if (empty ($ this ->workerPools )) {
622622 return ;
@@ -640,7 +640,7 @@ protected function checkForStoppedWorkers()
640640 * @return void
641641 * @throws \Exception
642642 */
643- protected function checkParentIsAlive ()
643+ protected function checkParentIsAlive (): void
644644 {
645645 $ time = microtime (true );
646646 if (
0 commit comments