@@ -21,16 +21,16 @@ protected function setUp()
2121 {
2222 \ini_set ('display_errors ' , (string ) false );
2323 $ this ->backupErrorLog = \ini_get ('error_log ' );
24- $ this ->errorLog = __DIR__ . \DIRECTORY_SEPARATOR . 'error_log_test ' ;
24+ $ this ->errorLog = __DIR__ . \DIRECTORY_SEPARATOR . 'error_log_test ' ;
2525 \touch ($ this ->errorLog );
2626 \ini_set ('error_log ' , $ this ->errorLog );
2727
28- $ this ->exception = new ErrorException (\uniqid ('normal_ ' ), \E_USER_NOTICE );
29- $ this ->emailsSent = [];
30- $ this ->errorHandler = new ErrorHandler (function ($ subject , $ body ) {
28+ $ this ->exception = new ErrorException (\uniqid ('normal_ ' ), \E_USER_NOTICE );
29+ $ this ->emailsSent = [];
30+ $ this ->errorHandler = new ErrorHandler (function (string $ subject , string $ body ) {
3131 $ this ->emailsSent [] = [
3232 'subject ' => $ subject ,
33- 'body ' => $ body ,
33+ 'body ' => $ body ,
3434 ];
3535 });
3636
@@ -50,26 +50,26 @@ public function testDefaultConfiguration()
5050 $ errorHandler = new ErrorHandler (function () {
5151 });
5252
53- $ this -> assertTrue ($ errorHandler ->isCli ());
54- $ this -> assertTrue ($ errorHandler ->autoExit ());
55- $ this -> assertNotNull ($ errorHandler ->getTerminalWidth ());
56- $ this -> assertSame (\STDERR , $ errorHandler ->getErrorOutputStream ());
57- $ this -> assertFalse ($ errorHandler ->logErrors ());
53+ static :: assertTrue ($ errorHandler ->isCli ());
54+ static :: assertTrue ($ errorHandler ->autoExit ());
55+ static :: assertNotNull ($ errorHandler ->getTerminalWidth ());
56+ static :: assertSame (\STDERR , $ errorHandler ->getErrorOutputStream ());
57+ static :: assertFalse ($ errorHandler ->logErrors ());
5858
5959 $ errorHandler ->setCli (false );
6060 $ errorHandler ->setAutoExit (false );
6161 $ errorHandler ->setTerminalWidth ($ width = \mt_rand (1 , 999 ));
6262 $ errorHandler ->setErrorOutputStream ($ memoryStream = \fopen ('php://memory ' , 'r+ ' ));
6363 $ errorHandler ->setLogErrors (true );
6464
65- $ this -> assertFalse ($ errorHandler ->isCli ());
66- $ this -> assertFalse ($ errorHandler ->autoExit ());
67- $ this -> assertSame ($ width , $ errorHandler ->getTerminalWidth ());
68- $ this -> assertSame ($ memoryStream , $ errorHandler ->getErrorOutputStream ());
69- $ this -> assertTrue ($ errorHandler ->logErrors ());
65+ static :: assertFalse ($ errorHandler ->isCli ());
66+ static :: assertFalse ($ errorHandler ->autoExit ());
67+ static :: assertSame ($ width , $ errorHandler ->getTerminalWidth ());
68+ static :: assertSame ($ memoryStream , $ errorHandler ->getErrorOutputStream ());
69+ static :: assertTrue ($ errorHandler ->logErrors ());
7070
7171 $ errorHandler ->setErrorOutputStream (\uniqid ('not_a_stream_ ' ));
72- $ this -> assertSame ($ memoryStream , $ errorHandler ->getErrorOutputStream ());
72+ static :: assertSame ($ memoryStream , $ errorHandler ->getErrorOutputStream ());
7373 }
7474
7575 /**
@@ -97,9 +97,9 @@ public function testScream()
9797 \E_USER_WARNING => true ,
9898 ];
9999
100- $ this -> assertEmpty ($ this ->errorHandler ->getScreamSilencedErrors ());
100+ static :: assertEmpty ($ this ->errorHandler ->getScreamSilencedErrors ());
101101 $ this ->errorHandler ->setScreamSilencedErrors ($ scream );
102- $ this -> assertSame ($ scream , $ this ->errorHandler ->getScreamSilencedErrors ());
102+ static :: assertSame ($ scream , $ this ->errorHandler ->getScreamSilencedErrors ());
103103
104104 $ this ->errorHandler ->register ();
105105
@@ -115,13 +115,14 @@ public function testScream()
115115 public function testHandleCliException ()
116116 {
117117 $ memoryStream = \fopen ('php://memory ' , 'r+ ' );
118+ static ::assertIsResource ($ memoryStream );
118119 $ this ->errorHandler ->setErrorOutputStream ($ memoryStream );
119120
120121 $ this ->errorHandler ->exceptionHandler ($ this ->exception );
121122
122123 \fseek ($ memoryStream , 0 );
123124 $ output = \stream_get_contents ($ memoryStream );
124- $ this -> assertContains ($ this ->exception ->getMessage (), $ output );
125+ static :: assertContains ($ this ->exception ->getMessage (), $ output );
125126 }
126127
127128 public function testHandleWebExceptionWithDisplay ()
@@ -134,10 +135,10 @@ public function testHandleWebExceptionWithDisplay()
134135 $ this ->errorHandler ->exceptionHandler ($ this ->exception );
135136 $ output = \ob_get_clean ();
136137
137- $ this -> assertContains ($ this ->exception ->getMessage (), $ output );
138+ static :: assertContains ($ this ->exception ->getMessage (), $ output );
138139
139140 $ errorLogContent = \file_get_contents ($ this ->errorLog );
140- $ this -> assertContains ($ this ->exception ->getMessage (), $ errorLogContent );
141+ static :: assertContains ($ this ->exception ->getMessage (), $ errorLogContent );
141142 }
142143
143144 public function testHandleWebExceptionWithoutDisplay ()
@@ -150,10 +151,10 @@ public function testHandleWebExceptionWithoutDisplay()
150151 $ this ->errorHandler ->exceptionHandler ($ this ->exception );
151152 $ output = \ob_get_clean ();
152153
153- $ this -> assertNotContains ($ this ->exception ->getMessage (), $ output );
154+ static :: assertNotContains ($ this ->exception ->getMessage (), $ output );
154155
155156 $ errorLogContent = \file_get_contents ($ this ->errorLog );
156- $ this -> assertContains ($ this ->exception ->getMessage (), $ errorLogContent );
157+ static :: assertContains ($ this ->exception ->getMessage (), $ errorLogContent );
157158 }
158159
159160 public function testLogErrorAndException ()
@@ -162,7 +163,7 @@ public function testLogErrorAndException()
162163
163164 $ this ->errorHandler ->logException ($ this ->exception );
164165
165- $ this -> assertSame (0 , \filesize ($ this ->errorLog ));
166+ static :: assertSame (0 , \filesize ($ this ->errorLog ));
166167
167168 $ this ->errorHandler ->setLogErrors (true );
168169
@@ -172,8 +173,8 @@ public function testLogErrorAndException()
172173
173174 $ errorLogContent = \file_get_contents ($ this ->errorLog );
174175
175- $ this -> assertContains ($ exception ->getMessage (), $ errorLogContent );
176- $ this -> assertContains ($ this ->exception ->getMessage (), $ errorLogContent );
176+ static :: assertContains ($ exception ->getMessage (), $ errorLogContent );
177+ static :: assertContains ($ this ->exception ->getMessage (), $ errorLogContent );
177178 }
178179
179180 public function testEmailException ()
@@ -182,54 +183,54 @@ public function testEmailException()
182183
183184 $ this ->errorHandler ->emailException ($ this ->exception );
184185
185- $ this -> assertEmpty ($ this ->emailsSent );
186+ static :: assertEmpty ($ this ->emailsSent );
186187
187188 $ this ->errorHandler ->setLogErrors (true );
188189
189- $ key = \uniqid (__FUNCTION__ );
190+ $ key = \uniqid (__FUNCTION__ );
190191 $ _SESSION = [$ key => \uniqid ()];
191- $ _POST = [$ key => \uniqid ()];
192+ $ _POST = [$ key => \uniqid ()];
192193
193194 $ this ->errorHandler ->emailException ($ this ->exception );
194195
195- $ this -> assertNotEmpty ($ this ->emailsSent );
196+ static :: assertNotEmpty ($ this ->emailsSent );
196197 $ message = \current ($ this ->emailsSent );
197- $ this -> assertNotEmpty ($ message );
198+ static :: assertNotEmpty ($ message );
198199
199200 $ messageText = $ message ['body ' ];
200- $ this -> assertContains ($ this ->exception ->getMessage (), $ messageText );
201- $ this -> assertContains ($ _SESSION [$ key ], $ messageText );
202- $ this -> assertContains ($ _POST [$ key ], $ messageText );
201+ static :: assertContains ($ this ->exception ->getMessage (), $ messageText );
202+ static :: assertContains ($ _SESSION [$ key ], $ messageText );
203+ static :: assertContains ($ _POST [$ key ], $ messageText );
203204 }
204205
205206 public function testCanHideVariablesFromEmail ()
206207 {
207- $ this -> assertTrue ($ this ->errorHandler ->logVariables ());
208+ static :: assertTrue ($ this ->errorHandler ->logVariables ());
208209 $ this ->errorHandler ->setLogVariables (false );
209- $ this -> assertFalse ($ this ->errorHandler ->logVariables ());
210+ static :: assertFalse ($ this ->errorHandler ->logVariables ());
210211
211212 $ this ->errorHandler ->setLogErrors (true );
212213
213- $ key = \uniqid (__FUNCTION__ );
214+ $ key = \uniqid (__FUNCTION__ );
214215 $ _SESSION = [$ key => \uniqid ()];
215- $ _POST = [$ key => \uniqid ()];
216+ $ _POST = [$ key => \uniqid ()];
216217
217218 $ this ->errorHandler ->emailException ($ this ->exception );
218219
219- $ this -> assertNotEmpty ($ this ->emailsSent );
220+ static :: assertNotEmpty ($ this ->emailsSent );
220221 $ message = \current ($ this ->emailsSent );
221- $ this -> assertNotEmpty ($ message );
222+ static :: assertNotEmpty ($ message );
222223
223224 $ messageText = $ message ['body ' ];
224- $ this -> assertContains ($ this ->exception ->getMessage (), $ messageText );
225- $ this -> assertNotContains ($ _SESSION [$ key ], $ messageText );
226- $ this -> assertNotContains ($ _POST [$ key ], $ messageText );
225+ static :: assertContains ($ this ->exception ->getMessage (), $ messageText );
226+ static :: assertNotContains ($ _SESSION [$ key ], $ messageText );
227+ static :: assertNotContains ($ _POST [$ key ], $ messageText );
227228 }
228229
229230 public function testErroriNellInvioDellaMailVengonoComunqueLoggati ()
230231 {
231- $ mailError = \uniqid ('mail_not_sent_ ' );
232- $ mailCallback = function ($ body , $ text ) use ($ mailError ) {
232+ $ mailError = \uniqid ('mail_not_sent_ ' );
233+ $ mailCallback = static function () use ($ mailError ) {
233234 throw new ErrorException ($ mailError , \E_USER_ERROR );
234235 };
235236 $ errorHandler = new ErrorHandler ($ mailCallback );
@@ -238,8 +239,8 @@ public function testErroriNellInvioDellaMailVengonoComunqueLoggati()
238239 $ errorHandler ->emailException ($ this ->exception );
239240
240241 $ errorLogContent = \file_get_contents ($ this ->errorLog );
241- $ this -> assertNotContains ($ this ->exception ->getMessage (), $ errorLogContent );
242- $ this -> assertContains ($ mailError , $ errorLogContent );
242+ static :: assertNotContains ($ this ->exception ->getMessage (), $ errorLogContent );
243+ static :: assertContains ($ mailError , $ errorLogContent );
243244 }
244245
245246 public function testUsernameInEmailSubject ()
@@ -252,7 +253,7 @@ public function testUsernameInEmailSubject()
252253
253254 $ message = \current ($ this ->emailsSent );
254255
255- $ this -> assertContains ($ username , $ message ['subject ' ]);
256+ static :: assertContains ($ username , $ message ['subject ' ]);
256257 }
257258
258259 public function testTerminalWidthByEnv ()
@@ -263,14 +264,14 @@ public function testTerminalWidthByEnv()
263264 $ errorHandler = new ErrorHandler (function () {
264265 });
265266
266- $ this -> assertSame ($ width , $ errorHandler ->getTerminalWidth ());
267+ static :: assertSame ($ width , $ errorHandler ->getTerminalWidth ());
267268
268269 \putenv ('COLUMNS ' );
269270
270271 $ errorHandler = new ErrorHandler (function () {
271272 });
272273
273274 $ terminal = new Terminal ();
274- $ this -> assertSame ($ terminal ->getWidth (), $ errorHandler ->getTerminalWidth ());
275+ static :: assertSame ($ terminal ->getWidth (), $ errorHandler ->getTerminalWidth ());
275276 }
276277}
0 commit comments