@@ -240,7 +240,7 @@ private function initialize(): void
240240 $ domserver_languages = dj_json_decode ($ this ->request ('languages ' , 'GET ' ));
241241 foreach ($ domserver_languages as $ language ) {
242242 $ id = $ language ['id ' ];
243- if (key_exists ($ id , $ this ->langexts )) {
243+ if (array_key_exists ($ id , $ this ->langexts )) {
244244 $ this ->langexts [$ id ] = $ language ['extensions ' ];
245245 }
246246 }
@@ -551,7 +551,7 @@ private function handleTask(string $type, array $row, ?string &$lastWorkdir, str
551551 $ this ->endpoints [$ this ->endpointID ]['retrying ' ] = false ;
552552
553553 logmsg (LOG_INFO ,
554- "⇝ Received " . sizeof ($ row ) . " ' " . $ type . "' judge tasks (endpoint $ this ->endpointID ) " );
554+ "⇝ Received " . count ($ row ) . " ' " . $ type . "' judge tasks (endpoint $ this ->endpointID ) " );
555555
556556 if ($ type == 'prefetch ' ) {
557557 $ this ->handlePrefetchTask ($ row , $ lastWorkdir , $ workdirpath );
@@ -763,14 +763,14 @@ private function request(string $url, string $verb = 'GET', $data = '', bool $fa
763763 }
764764 }
765765 if ($ trial == BACKOFF_STEPS ) {
766- $ errstr = $ errstr . " Retry limit reached. " ;
766+ $ errstr .= " Retry limit reached. " ;
767767 } else {
768768 $ retry_in_sec = $ delay_in_sec + BACKOFF_JITTER_SEC * random_int (0 , mt_getrandmax ()) / mt_getrandmax ();
769769 $ warnstr = $ errstr . " This request will be retried after about " .
770770 round ($ retry_in_sec , 2 ) . "sec... ( " . $ trial . "/ " . BACKOFF_STEPS . ") " ;
771771 warning ($ warnstr );
772772 dj_sleep ($ retry_in_sec );
773- $ delay_in_sec = $ delay_in_sec * BACKOFF_FACTOR ;
773+ $ delay_in_sec *= BACKOFF_FACTOR ;
774774 }
775775 }
776776 if (!$ succeeded ) {
@@ -865,7 +865,7 @@ private function runCommandSafe(array $command_parts, &$retval = DONT_CARE, $log
865865 return false ;
866866 }
867867
868- $ command = implode (' ' , array_map (' dj_escapeshellarg ' , $ command_parts ));
868+ $ command = implode (' ' , array_map (dj_escapeshellarg (...) , $ command_parts ));
869869
870870 logmsg (LOG_DEBUG , "Executing command: $ command " );
871871 system ($ command , $ retval_local );
@@ -917,7 +917,7 @@ private function fetchExecutableInternal(
917917 string $ hash ,
918918 bool $ combined_run_compare = false
919919 ): array {
920- $ execdir = join ('/ ' , [
920+ $ execdir = implode ('/ ' , [
921921 $ workdirpath ,
922922 'executable ' ,
923923 $ type ,
@@ -945,7 +945,7 @@ private function fetchExecutableInternal(
945945 $ filesArray = [];
946946 foreach ($ files as $ file ) {
947947 $ filename = $ execbuilddir . '/ ' . $ file ['filename ' ];
948- $ content = base64_decode ($ file ['content ' ]);
948+ $ content = base64_decode (( string ) $ file ['content ' ]);
949949 file_put_contents ($ filename , $ content );
950950 if ($ file ['is_executable ' ]) {
951951 chmod ($ filename , 0755 );
@@ -957,10 +957,10 @@ private function fetchExecutableInternal(
957957 ];
958958 }
959959 unset($ files );
960- uasort ($ filesArray , fn (array $ a , array $ b ) => strcmp ($ a ['filename ' ], $ b ['filename ' ]));
960+ uasort ($ filesArray , fn (array $ a , array $ b ) => strcmp (( string ) $ a ['filename ' ], ( string ) $ b ['filename ' ]));
961961 $ computedHash = md5 (
962- join (
963- array_map (
962+ implode (
963+ '' , array_map (
964964 fn ($ file ) => $ file ['hash ' ] . $ file ['filename ' ] . $ file ['is_executable ' ],
965965 $ filesArray
966966 )
@@ -1251,8 +1251,8 @@ private function compile(
12511251 if ($ compile_config ['filter_compiler_files ' ]) {
12521252 $ picked = false ;
12531253 foreach ($ compile_config ['language_extensions ' ] as $ extension ) {
1254- $ extensionLength = strlen ($ extension );
1255- if (substr ($ file , -$ extensionLength ) === $ extension ) {
1254+ $ extensionLength = strlen (( string ) $ extension );
1255+ if (substr (( string ) $ file , -$ extensionLength ) === $ extension ) {
12561256 $ files [] = $ file ;
12571257 $ picked = true ;
12581258 break ;
@@ -1264,7 +1264,7 @@ private function compile(
12641264 } else {
12651265 $ files [] = $ file ;
12661266 }
1267- if (file_put_contents ($ srcfile , base64_decode ($ source ['content ' ])) === false ) {
1267+ if (file_put_contents ($ srcfile , base64_decode (( string ) $ source ['content ' ])) === false ) {
12681268 error ("Could not create $ srcfile " );
12691269 }
12701270 }
@@ -1596,7 +1596,7 @@ private function runTestcase(
15961596 }
15971597
15981598 $ new_judging_run = [
1599- 'runresult ' => urlencode ($ result ),
1599+ 'runresult ' => urlencode (( string ) $ result ),
16001600 'start_time ' => urlencode ((string )$ startTime ),
16011601 'end_time ' => urlencode ((string )microtime (true )),
16021602 'runtime ' => urlencode ((string )$ runtime ),
@@ -1757,7 +1757,7 @@ private function fetchTestcase(string $workdirpath, string $testcase_id, int $ju
17571757 unset($ content );
17581758 foreach ($ files as $ file ) {
17591759 $ filename = $ tcfile [$ file ['filename ' ]];
1760- file_put_contents ($ filename , base64_decode ($ file ['content ' ]));
1760+ file_put_contents ($ filename , base64_decode (( string ) $ file ['content ' ]));
17611761 }
17621762 unset($ files );
17631763
@@ -1767,10 +1767,10 @@ private function fetchTestcase(string $workdirpath, string $testcase_id, int $ju
17671767
17681768 private function initsignals (): void
17691769 {
1770- pcntl_signal (SIGTERM , [ self ::class, ' signalHandler ' ] );
1771- pcntl_signal (SIGINT , [ self ::class, ' signalHandler ' ] );
1772- pcntl_signal (SIGHUP , [ self ::class, ' signalHandler ' ] );
1773- pcntl_signal (SIGUSR1 , [ self ::class, ' signalHandler ' ] );
1770+ pcntl_signal (SIGTERM , self ::signalHandler (...) );
1771+ pcntl_signal (SIGINT , self ::signalHandler (...) );
1772+ pcntl_signal (SIGHUP , self ::signalHandler (...) );
1773+ pcntl_signal (SIGUSR1 , self ::signalHandler (...) );
17741774 }
17751775}
17761776
0 commit comments