@@ -91,9 +91,14 @@ public function testNotice()
91
91
$ this ->fail ('ErrorException expected ' );
92
92
} catch (\ErrorException $ exception ) {
93
93
// if an exception is thrown, the test passed
94
- $ this ->assertEquals (E_NOTICE , $ exception ->getSeverity ());
94
+ if (\PHP_VERSION_ID < 80000 ) {
95
+ $ this ->assertEquals (E_NOTICE , $ exception ->getSeverity ());
96
+ $ this ->assertRegExp ('/^Notice: Undefined variable: (foo|bar)/ ' , $ exception ->getMessage ());
97
+ } else {
98
+ $ this ->assertEquals (E_WARNING , $ exception ->getSeverity ());
99
+ $ this ->assertRegExp ('/^Warning: Undefined variable \$(foo|bar)/ ' , $ exception ->getMessage ());
100
+ }
95
101
$ this ->assertEquals (__FILE__ , $ exception ->getFile ());
96
<
10000
td data-grid-cell-id="diff-258da769eed42a2dbcac11c190514216c438fd9f108c9472f0b7be884cd4936c-96-101-2" data-line-anchor="diff-258da769eed42a2dbcac11c190514216c438fd9f108c9472f0b7be884cd4936cL96" data-selected="false" role="gridcell" style="background-color:var(--diffBlob-deletionLine-bgColor, var(--diffBlob-deletion-bgColor-line));padding-right:24px" tabindex="-1" valign="top" class="focusable-grid-cell diff-text-cell left-side-diff-cell border-right left-side">- $ this ->assertRegExp ('/^Notice: Undefined variable: (foo|bar)/ ' , $ exception ->getMessage ());
97
102
98
103
$ trace = $ exception ->getTrace ();
99
104
@@ -121,7 +126,7 @@ public static function triggerNotice($that)
121
126
public function testFailureCall ()
122
127
{
123
128
$ this ->expectException (\ErrorException::class);
124
- $ this ->expectExceptionMessage ( ' fopen(unknown.txt): failed to open stream: No such file or directory ' );
129
+ $ this ->expectExceptionMessageMatches ( ' /^ fopen\ (unknown\ .txt\ ): [Ff]ailed to open stream: No such file or directory$/ ' );
125
130
126
131
ErrorHandler::call ('fopen ' , 'unknown.txt ' , 'r ' );
127
132
}
@@ -149,9 +154,14 @@ public function testCallErrorExceptionInfo()
149
154
$ this ->fail ('An \ErrorException should have been raised ' );
150
155
} catch (\ErrorException $ e ) {
151
156
$ trace = $ e ->getTrace ();
152
- $ this ->assertSame (E_NOTICE , $ e ->getSeverity ());
157
+ if (\PHP_VERSION_ID < 80000 ) {
158
+ $ this ->assertEquals (E_NOTICE , $ e ->getSeverity ());
159
+ $ this ->assertSame ('Undefined variable: foo ' , $ e ->getMessage ());
160
+ } else {
161
+ $ this ->assertEquals (E_WARNING , $ e ->getSeverity ());
162
+ $ this ->assertSame ('Undefined variable $foo ' , $ e ->getMessage ());
163
+ }
153
164
$ this ->assertSame (__FILE__ , $ e ->getFile ());
154
- $ this ->assertSame ('Undefined variable: foo ' , $ e ->getMessage ());
155
165
$ this ->assertSame (0 , $ e ->getCode ());
156
166
$ this ->assertSame ('Symfony\Component\ErrorHandler\{closure} ' , $ trace [0 ]['function ' ]);
157
167
$ this ->assertSame (ErrorHandler::class, $ trace [0 ]['class ' ]);
@@ -288,11 +298,18 @@ public function testHandleError()
288
298
289
299
$ line = null ;
290
300
$ logArgCheck = function ($ level , $ message , $ context ) use (&$ line ) {
291
- $ this ->assertEquals ('Notice: Undefined variable: undefVar ' , $ message );
292
301
$ this ->assertArrayHasKey ('exception ' , $ context );
293
302
$ exception = $ context ['exception ' ];
303
+
304
+ if (\PHP_VERSION_ID < 80000 ) {
305
+ $ this ->assertEquals ('Notice: Undefined variable: undefVar ' , $ message );
306
+ $ this ->assertSame (E_NOTICE , $ exception ->getSeverity ());
307
+ } else {
308
+ $ this ->assertEquals ('Warning: Undefined variable $undefVar ' , $ message );
309
+ $ this ->assertSame (E_WARNING , $ exception ->getSeverity ());
310
+ }
311
+
294
312
$ this ->assertInstanceOf (SilencedErrorContext::class, $ exception );
295
- $ this ->assertSame (E_NOTICE , $ exception ->getSeverity ());
296
313
$ this ->assertSame (__FILE__ , $ exception ->getFile ());
297
314
$ this ->assertSame ($ line , $ exception ->getLine ());
298
315
$ this ->assertNotEmpty ($ exception ->getTrace ());
@@ -306,8 +323,13 @@ public function testHandleError()
306
323
;
307
324
308
325
$ handler = ErrorHandler::register ();
309
- $ handler ->setDefaultLogger ($ logger , E_NOTICE );
310
- $ handler ->screamAt (E_NOTICE );
326
+ if (\PHP_VERSION_ID < 80000 ) {
327
+ $ handler ->setDefaultLogger ($ logger , E_NOTICE );
328
+ $ handler ->screamAt (E_NOTICE );
329
+ } else {
330
+ $ handler ->setDefaultLogger ($ logger , E_WARNING );
331
+ $ handler ->screamAt (E_WARNING );
332
+ }
311
333
unset($ undefVar );
312
334
$ line = __LINE__ + 1 ;
313
335
@$ undefVar ++;
0 commit comments