@@ -99,7 +99,7 @@ public function __construct(string $message, array $trace, string $file, bool $l
99
99
$ this ->getOriginalFilesStack ();
100
100
array_splice ($ this ->originalFilesStack , 0 , $ j , [$ this ->triggeringFile ]);
101
101
102
- if (preg_match ('/(?|"([^"]++)" that is deprecated|should implement method "(?:static )?([^:]++))/ ' , $ message , $ m ) || (false === strpos ($ message , '()" will return ' ) && false === strpos ($ message , 'native return type declaration ' ) && preg_match ('/^(?:The|Method) "([^":]++)/ ' , $ message , $ m ))) {
102
+ if (preg_match ('/(?|"([^"]++)" that is deprecated|should implement method "(?:static )?([^:]++))/ ' , $ message , $ m ) || (! str_contains ($ message , '()" will return ' ) && ! str_contains ($ message , 'native return type declaration ' ) && preg_match ('/^(?:The|Method) "([^":]++)/ ' , $ message , $ m ))) {
103
103
$ this ->triggeringFile = (new \ReflectionClass ($ m [1 ]))->getFileName ();
104
104
array_unshift ($ this ->originalFilesStack , $ this ->triggeringFile );
105
105
}
@@ -137,7 +137,7 @@ public function __construct(string $message, array $trace, string $file, bool $l
137
137
return ;
138
138
}
139
139
140
- if (!isset ($ line ['class ' ], $ trace [$ i - 2 ]['function ' ]) || 0 !== strpos ($ line ['class ' ], SymfonyTestsListenerFor::class)) {
140
+ if (!isset ($ line ['class ' ], $ trace [$ i - 2 ]['function ' ]) || ! str_starts_with ($ line ['class ' ], SymfonyTestsListenerFor::class)) {
141
141
$ this ->originClass = isset ($ line ['object ' ]) ? \get_class ($ line ['object ' ]) : $ line ['class ' ];
142
142
$ this ->originMethod = $ line ['function ' ];
143
143
@@ -147,7 +147,7 @@ public function __construct(string $message, array $trace, string $file, bool $l
147
147
$ test = $ line ['args ' ][0 ] ?? null ;
148
148
149
149
if (($ test instanceof TestCase || $ test instanceof TestSuite) && ('trigger_error ' !== $ trace [$ i - 2 ]['function ' ] || isset ($ trace [$ i - 2 ]['class ' ]))) {
150
- $ this ->originClass = \get_class ( $ test) ;
150
+ $ this ->originClass = $ test::class ;
151
151
$ this ->originMethod = $ test ->getName ();
152
152
}
153
153
}
@@ -159,7 +159,7 @@ private function lineShouldBeSkipped(array $line): bool
159
159
}
160
160
$ class = $ line ['class ' ];
161
161
162
- return 'ReflectionMethod ' === $ class || 0 === strpos ($ class , 'PHPUnit \\' );
162
+ return 'ReflectionMethod ' === $ class || str_starts_with ($ class , 'PHPUnit \\' );
163
163
}
164
164
165
165
public function originatesFromDebugClassLoader (): bool
@@ -189,7 +189,7 @@ public function originatingClass(): string
189
189
190
190
$ class = $ this ->originClass ;
191
191
192
- return false !== strpos ($ class , "@anonymous \0" ) ? (get_parent_class ($ class ) ?: key (class_implements ($ class )) ?: 'class ' ).'@anonymous ' : $ class ;
192
+ return str_contains ($ class , "@anonymous \0" ) ? (get_parent_class ($ class ) ?: key (class_implements ($ class )) ?: 'class ' ).'@anonymous ' : $ class ;
193
193
}
194
194
195
195
public function originatingMethod (): string
@@ -215,9 +215,9 @@ public function isLegacy(): bool
215
215
$ method = $ this ->originatingMethod ();
216
216
$ groups = class_exists (Groups::class, false ) ? [new Groups (), 'groups ' ] : [Test::class, 'getGroups ' ];
217
217
218
- return 0 === strpos ($ method , 'testLegacy ' )
219
- || 0 === strpos ($ method , 'provideLegacy ' )
220
- || 0 === strpos ($ method , 'getLegacy ' )
218
+ return str_starts_with ($ method , 'testLegacy ' )
219
+ || str_starts_with ($ method , 'provideLegacy ' )
220
+ || str_starts_with ($ method , 'getLegacy ' )
221
221
|| strpos ($ this ->originClass , '\Legacy ' )
222
222
|| \in_array ('legacy ' , $ groups ($ this ->originClass , $ method ), true );
223
223
}
@@ -228,10 +228,10 @@ public function isMuted(): bool
228
228
return false ;
229
229
}
230
230
if (isset ($ this ->trace [1 ]['class ' ])) {
231
- return 0 === strpos ($ this ->trace [1 ]['class ' ], 'PHPUnit \\' );
231
+ return str_starts_with ($ this ->trace [1 ]['class ' ], 'PHPUnit \\' );
232
232
}
233
233
234
- return false !== strpos ($ this ->triggeringFile , \DIRECTORY_SEPARATOR .'vendor ' .\DIRECTORY_SEPARATOR .'phpunit ' .\DIRECTORY_SEPARATOR );
234
+ return str_contains ($ this ->triggeringFile , \DIRECTORY_SEPARATOR .'vendor ' .\DIRECTORY_SEPARATOR .'phpunit ' .\DIRECTORY_SEPARATOR );
235
235
}
236
236
237
237
/**
@@ -300,7 +300,7 @@ private function getPackage(string $path): string
300
300
{
301
301
$ path = realpath ($ path ) ?: $ path ;
302
302
foreach (self ::getVendors () as $ vendorRoot ) {
303
- if (0 === strpos ($ path , $ vendorRoot )) {
303
+ if (str_starts_with ($ path , $ vendorRoot )) {
304
304
$ relativePath = substr ($ path , \strlen ($ vendorRoot ) + 1 );
305
305
$ vendor = strstr ($ relativePath , \DIRECTORY_SEPARATOR , true );
306
306
if (false === $ vendor ) {
@@ -326,7 +326,7 @@ private static function getVendors(): array
326
326
self ::$ vendors [] = \dirname ((new \ReflectionClass (DebugClassLoader::class))->getFileName ());
327
327
}
328
328
foreach (get_declared_classes () as $ class ) {
329
- if ('C ' === $ class [0 ] && 0 === strpos ($ class , 'ComposerAutoloaderInit ' )) {
329
+ if ('C ' === $ class [0 ] && str_starts_with ($ class , 'ComposerAutoloaderInit ' )) {
330
330
$ r = new \ReflectionClass ($ class );
331
331
$ v = \dirname ($ r ->getFileName (), 2 );
332
332
if (file_exists ($ v .'/composer/installed.json ' )) {
@@ -341,7 +341,7 @@ private static function getVendors(): array
341
341
}
342
342
foreach ($ paths as $ path ) {
343
343
foreach (self ::$ vendors as $ vendor ) {
344
- if (0 !== strpos ($ path , $ vendor )) {
344
+ if (! str_starts_with ($ path , $ vendor )) {
345
345
self ::$ internalPaths [] = $ path ;
346
346
}
347
347
}
@@ -371,13 +371,13 @@ private function getPathType(string $path): string
371
371
return self ::PATH_TYPE_UNDETERMINED ;
372
372
}
373
373
foreach (self ::getVendors () as $ vendor ) {
374
- if (0 === strpos ($ realPath , $ vendor ) && false !== strpbrk (substr ($ realPath , \strlen ($ vendor ), 1 ), '/ ' .\DIRECTORY_SEPARATOR )) {
374
+ if (str_starts_with ($ realPath , $ vendor ) && false !== strpbrk (substr ($ realPath , \strlen ($ vendor ), 1 ), '/ ' .\DIRECTORY_SEPARATOR )) {
375
375
return self ::PATH_TYPE_VENDOR ;
376
376
}
377
377
}
378
378
379
379
foreach (self ::$ internalPaths as $ internalPath ) {
380
- if (0 === strpos ($ realPath , $ internalPath )) {
380
+ if (str_starts_with ($ realPath , $ internalPath )) {
381
381
return self ::PATH_TYPE_SELF ;
382
382
}
383
383
}
0 commit comments