@@ -2321,64 +2321,81 @@ private function startErrorLogCapture(): void
23212321
23222322 $ errorLogCapture = tmpfile ();
23232323
2324- if ($ errorLogCapture !== false ) {
2325- $ capturePath = stream_get_meta_data ($ errorLogCapture )['uri ' ];
2324+ if ($ errorLogCapture === false ) {
2325+ return ;
2326+ }
23262327
2327- if (@is_writable ($ capturePath )) {
2328- $ this ->previousErrorLogTarget = ini_set ('error_log ' , $ capturePath );
2329- } else {
2330- $ errorLogCapture = false ;
2331- }
2328+ $ capturePath = stream_get_meta_data ($ errorLogCapture )['uri ' ];
2329+
2330+ if (!@is_writable ($ capturePath )) {
2331+ return ;
23322332 }
23332333
2334- $ this ->errorLogCapture = $ errorLogCapture ;
2334+ $ this ->errorLogCapture = $ errorLogCapture ;
2335+ $ this ->previousErrorLogTarget = ini_set ('error_log ' , $ capturePath );
23352336 }
23362337
23372338 private function verifyErrorLogExpectation (): void
23382339 {
2339- if ($ this ->errorLogCapture !== false ) {
2340- $ errorLogOutput = stream_get_contents ($ this ->errorLogCapture );
2341-
2340+ if ($ this ->errorLogCapture === false ) {
23422341 if ($ this ->expectErrorLog ) {
2343- $ this ->assertNotEmpty ($ errorLogOutput , 'Test did not call error_log(). ' );
2344- } else {
2345- if ($ errorLogOutput !== false ) {
2346- print $ this ->stripDateFromErrorLog ($ errorLogOutput );
2347- }
2342+ $ this ->markTestIncomplete ('Could not create writable error_log file. ' );
23482343 }
2349- } elseif ($ this ->expectErrorLog ) {
2350- $ this ->markTestIncomplete ('Could not create writable error_log file. ' );
2344+
2345+ return ;
2346+ }
2347+
2348+ $ errorLogOutput = stream_get_contents ($ this ->errorLogCapture );
2349+
2350+ if ($ this ->expectErrorLog ) {
2351+ $ this ->assertNotEmpty ($ errorLogOutput , 'Test did not call error_log(). ' );
2352+
2353+ return ;
2354+ }
2355+
2356+ if ($ errorLogOutput === false ) {
2357+ return ;
23512358 }
2359+
2360+ print $ this ->stripDateFromErrorLog ($ errorLogOutput );
23522361 }
23532362
23542363 private function handleErrorLogError (): void
23552364 {
2356- if ($ this ->errorLogCapture ! == false ) {
2357- if (! $ this -> expectErrorLog ) {
2358- $ errorLogOutput = stream_get_contents ( $ this -> errorLogCapture );
2365+ if ($ this ->errorLogCapture = == false ) {
2366+ return ;
2367+ }
23592368
2360- if ($ errorLogOutput !== false ) {
2361- print $ this ->stripDateFromErrorLog ($ errorLogOutput );
2362- }
2363- }
2369+ if ($ this ->expectErrorLog ) {
2370+ return ;
2371+ }
2372+
2373+ $ errorLogOutput = stream_get_contents ($ this ->errorLogCapture );
2374+
2375+ if ($ errorLogOutput !== false ) {
2376+ print $ this ->stripDateFromErrorLog ($ errorLogOutput );
23642377 }
23652378 }
23662379
23672380 private function stopErrorLogCapture (): void
23682381 {
2369- if ($ this ->errorLogCapture !== false ) {
2370- ShutdownHandler::resetMessage ();
2382+ if ($ this ->errorLogCapture === false ) {
2383+ return ;
2384+ }
23712385
2372- fclose ( $ this -> errorLogCapture );
2386+ ShutdownHandler:: resetMessage ( );
23732387
2374- $ this ->errorLogCapture = false ;
2388+ fclose ( $ this ->errorLogCapture ) ;
23752389
2376- if ($ this ->previousErrorLogTarget !== false ) {
2377- ini_set ('error_log ' , $ this ->previousErrorLogTarget );
2390+ $ this ->errorLogCapture = false ;
23782391
2379- $ this ->previousErrorLogTarget = false ;
2380- }
2392+ if ( $ this ->previousErrorLogTarget === false ) {
2393+ return ;
23812394 }
2395+
2396+ ini_set ('error_log ' , $ this ->previousErrorLogTarget );
2397+
2398+ $ this ->previousErrorLogTarget = false ;
23822399 }
23832400
23842401 /**
0 commit comments