@@ -205,7 +205,7 @@ public function __construct(callable $classLoader)
205
205
if (false === $ test || false === $ i ) {
206
206
// filesystem is case sensitive
207
207
self ::$ caseCheck = 0 ;
208
- } elseif (str_ends_with ($ test , $ file )) {
208
+ } elseif (substr ($ test , - \strlen ( $ file )) === $ file ) {
209
209
// filesystem is case insensitive and realpath() normalizes the case of characters
210
210
self ::$ caseCheck = 1 ;
211
211
} elseif ('Darwin ' === \PHP_OS_FAMILY ) {
@@ -396,7 +396,7 @@ private function checkClass(string $class, string $file = null): void
396
396
}
397
397
398
398
if (!$ exists ) {
399
- if (str_contains ($ class , '/ ' )) {
399
+ if (false !== strpos ($ class , '/ ' )) {
400
400
throw new \RuntimeException (sprintf ('Trying to autoload a class with an invalid name "%s". Be careful that the namespace separator is "\" in PHP, not "/". ' , $ class ));
401
401
}
402
402
@@ -418,7 +418,7 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array
418
418
}
419
419
$ deprecations = [];
420
420
421
- $ className = str_contains ($ class , "@anonymous \0" ) ? (get_parent_class ($ class ) ?: key (class_implements ($ class )) ?: 'class ' ).'@anonymous ' : $ class ;
421
+ $ className = false !== strpos ($ class , "@anonymous \0" ) ? (get_parent_class ($ class ) ?: key (class_implements ($ class )) ?: 'class ' ).'@anonymous ' : $ class ;
422
422
423
423
// Don't trigger deprecations for classes in the same vendor
424
424
if ($ class !== $ className ) {
@@ -434,17 +434,17 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array
434
434
// Detect annotations on the class
435
435
if (false !== $ doc = $ refl ->getDocComment ()) {
436
436
foreach (['final ' , 'deprecated ' , 'internal ' ] as $ annotation ) {
437
- if (str_contains ($ doc , $ annotation ) && preg_match ('#\n\s+\* @ ' .$ annotation .'(?:( .+?)\.?)?\r?\n\s+\*(?: @|/$|\r?\n)#s ' , $ doc , $ notice )) {
437
+ if (false !== strpos ($ doc , $ annotation ) && preg_match ('#\n\s+\* @ ' .$ annotation .'(?:( .+?)\.?)?\r?\n\s+\*(?: @|/$|\r?\n)#s ' , $ doc , $ notice )) {
438
438
self ::$ {$ annotation }[$ class ] = isset ($ notice [1 ]) ? preg_replace ('#\.?\r?\n( \*)? *(?= |\r?\n|$)# ' , '' , $ notice [1 ]) : '' ;
439
439
}
440
440
}
441
441
442
- if ($ refl ->isInterface () && str_contains ($ doc , 'method ' ) && preg_match_all ('#\n \* @method\s+(static\s+)?+([\w\|&\[\] \\\]+\s+)?(\w+(?:\s*\([^\)]*\))?)+(.+?([[:punct:]]\s*)?)?(?=\r?\n \*(?: @|/$|\r?\n))# ' , $ doc , $ notice , \PREG_SET_ORDER )) {
442
+ if ($ refl ->isInterface () && false !== strpos ($ doc , 'method ' ) && preg_match_all ('#\n \* @method\s+(static\s+)?+([\w\|&\[\] \\\]+\s+)?(\w+(?:\s*\([^\)]*\))?)+(.+?([[:punct:]]\s*)?)?(?=\r?\n \*(?: @|/$|\r?\n))# ' , $ doc , $ notice , \PREG_SET_ORDER )) {
443
443
foreach ($ notice as $ method ) {
444
444
$ static = '' !== $ method [1 ] && !empty ($ method [2 ]);
445
445
$ name = $ method [3 ];
446
446
$ description = $ method [4 ] ?? null ;
447
- if (! str_contains ($ name , '( ' )) {
447
+ if (false === strpos ($ name , '( ' )) {
448
448
$ name .= '() ' ;
449
449
}
450
450
if (null !== $ description ) {
@@ -495,7 +495,7 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array
495
495
}
496
496
} elseif (!$ refl ->isInterface ()) {
497
497
if (!strncmp ($ vendor , str_replace ('_ ' , '\\' , $ use ), $ vendorLen )
498
- && str_starts_with ($ className , 'Symfony \\' )
498
+ && 0 === strpos ($ className , 'Symfony \\' )
499
499
&& (!class_exists (InstalledVersions::class)
500
500
|| 'symfony/symfony ' !== InstalledVersions::getRootPackage ()['name ' ])
501
501
) {
@@ -596,12 +596,12 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array
596
596
597
597
$ forcePatchTypes = $ this ->patchTypes ['force ' ];
598
598
599
- if ($ canAddReturnType = null !== $ forcePatchTypes && ! str_contains ($ method ->getFileName (), \DIRECTORY_SEPARATOR .'vendor ' .\DIRECTORY_SEPARATOR )) {
599
+ if ($ canAddReturnType = null !== $ forcePatchTypes && false === strpos ($ method ->getFileName (), \DIRECTORY_SEPARATOR .'vendor ' .\DIRECTORY_SEPARATOR )) {
600
600
if ('void ' !== (self ::MAGIC_METHODS [$ method ->name ] ?? 'void ' )) {
601
601
$ this ->patchTypes ['force ' ] = $ forcePatchTypes ?: 'docblock ' ;
602
602
}
603
603
604
- $ canAddReturnType = str_contains ($ refl ->getFileName (), \DIRECTORY_SEPARATOR .'Tests ' .\DIRECTORY_SEPARATOR )
604
+ $ canAddReturnType = false !== strpos ($ refl ->getFileName (), \DIRECTORY_SEPARATOR .'Tests ' .\DIRECTORY_SEPARATOR )
605
605
|| $ refl ->isFinal ()
606
606
|| $ method ->isFinal ()
607
607
|| $ method ->isPrivate ()
@@ -622,8 +622,8 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array
622
622
$ this ->patchMethod ($ method , $ returnType , $ declaringFile , $ normalizedType );
623
623
}
624
624
625
- if (! str_contains ($ doc , '* @deprecated ' ) && strncmp ($ ns , $ declaringClass , $ len )) {
626
- if ($ canAddReturnType && 'docblock ' === $ this ->patchTypes ['force ' ] && ! str_contains ($ method ->getFileName (), \DIRECTORY_SEPARATOR .'vendor ' .\DIRECTORY_SEPARATOR )) {
625
+ if (false === strpos ($ doc , '* @deprecated ' ) && strncmp ($ ns , $ declaringClass , $ len )) {
626
+ if ($ canAddReturnType && 'docblock ' === $ this ->patchTypes ['force ' ] && false === strpos ($ method ->getFileName (), \DIRECTORY_SEPARATOR .'vendor ' .\DIRECTORY_SEPARATOR )) {
627
627
$ this ->patchMethod ($ method , $ returnType , $ declaringFile , $ normalizedType );
628
628
} elseif ('' !== $ declaringClass && $ this ->patchTypes ['deprecations ' ]) {
629
629
$ deprecations [] = sprintf ('Method "%s::%s()" will return "%s" as of its next major version. Doing the same in %s "%s" will be required when upgrading. ' , $ declaringClass , $ method ->name , $ normalizedType , interface_exists ($ declaringClass ) ? 'implementation ' : 'child class ' , $ className );
@@ -639,7 +639,7 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array
639
639
640
640
$ matches = [];
641
641
642
- if (!$ method ->hasReturnType () && ((str_contains ($ doc , '@return ' ) && preg_match ('/\n\s+\* @return +([^\s<(]+)/ ' , $ doc , $ matches )) || 'void ' !== (self ::MAGIC_METHODS [$ method ->name ] ?? 'void ' ))) {
642
+ if (!$ method ->hasReturnType () && ((false !== strpos ($ doc , '@return ' ) && preg_match ('/\n\s+\* @return +([^\s<(]+)/ ' , $ doc , $ matches )) || 'void ' !== (self ::MAGIC_METHODS [$ method ->name ] ?? 'void ' ))) {
643
643
$ matches = $ matches ?: [1 => self ::MAGIC_METHODS [$ method ->name ]];
644
644
$ this ->setReturnType ($ matches [1 ], $ method , $ parent );
645
645
@@ -661,14 +661,14 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array
661
661
$ finalOrInternal = false ;
662
662
663
663
foreach (['final ' , 'internal ' ] as $ annotation ) {
664
- if (str_contains ($ doc , $ annotation ) && preg_match ('#\n\s+\* @ ' .$ annotation .'(?:( .+?)\.?)?\r?\n\s+\*(?: @|/$|\r?\n)#s ' , $ doc , $ notice )) {
664
+ if (false !== strpos ($ doc , $ annotation ) && preg_match ('#\n\s+\* @ ' .$ annotation .'(?:( .+?)\.?)?\r?\n\s+\*(?: @|/$|\r?\n)#s ' , $ doc , $ notice )) {
665
665
$ message = isset ($ notice [1 ]) ? preg_replace ('#\.?\r?\n( \*)? *(?= |\r?\n|$)# ' , '' , $ notice [1 ]) : '' ;
666
666
self ::$ {$ annotation .'Methods ' }[$ class ][$ method ->name ] = [$ class , $ message ];
667
667
$ finalOrInternal = true ;
668
668
}
669
669
}
670
670
671
- if ($ finalOrInternal || $ method ->isConstructor () || ! str_contains ($ doc , '@param ' ) || StatelessInvocation::class === $ class ) {
671
+ if ($ finalOrInternal || $ method ->isConstructor () || false === strpos ($ doc , '@param ' ) || StatelessInvocation::class === $ class ) {
672
672
continue ;
673
673
}
674
674
if (!preg_match_all ('#\n\s+\* @param +((?(?!callable *\().*?|callable *\(.*\).*?))(?<= )\$([a-zA-Z0-9_\x7f-\xff]++)# ' , $ doc , $ matches , \PREG_SET_ORDER )) {
@@ -849,7 +849,7 @@ private function setReturnType(string $types, \ReflectionMethod $method, ?string
849
849
$ iterable = $ object = true ;
850
850
foreach ($ typesMap as $ n => $ t ) {
851
851
if ('null ' !== $ n ) {
852
- $ iterable = $ iterable && (\in_array ($ n , ['array ' , 'iterable ' ]) || str_contains ($ n , 'Iterator ' ));
852
+ $ iterable = $ iterable && (\in_array ($ n , ['array ' , 'iterable ' ]) || false !== strpos ($ n , 'Iterator ' ));
853
853
$ object = $ object && (\in_array ($ n , ['callable ' , 'object ' , '$this ' , 'static ' ]) || !isset (self ::SPECIAL_RETURN_TYPES [$ n ]));
854
854
}
855
855
}
@@ -1033,15 +1033,15 @@ private static function getUseStatements(string $file): array
1033
1033
break ;
1034
1034
}
1035
1035
1036
- if (str_starts_with ($ file [$ i ], 'namespace ' )) {
1036
+ if (0 === strpos ($ file [$ i ], 'namespace ' )) {
1037
1037
$ namespace = substr ($ file [$ i ], \strlen ('namespace ' ), -2 ).'\\' ;
1038
1038
$ useOffset = $ i + 2 ;
1039
1039
}
1040
1040
1041
- if (str_starts_with ($ file [$ i ], 'use ' )) {
1041
+ if (0 === strpos ($ file [$ i ], 'use ' )) {
1042
1042
$ useOffset = $ i ;
1043
1043
1044
- for (; str_starts_with ($ file [$ i ], 'use ' ); ++$ i ) {
1044
+ for (; 0 === strpos ($ file [$ i ], 'use ' ); ++$ i ) {
1045
1045
$ u = explode (' as ' , substr ($ file [$ i ], 4 , -2 ), 2 );
1046
1046
1047
1047
if (1 === \count ($ u )) {
0 commit comments