@@ -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
@@ -419,7 +419,7 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array
419
419
}
420
420
$ deprecations = [];
421
421
422
- $ className = str_contains ($ class , "@anonymous \0" ) ? (get_parent_class ($ class ) ?: key (class_implements ($ class )) ?: 'class ' ).'@anonymous ' : $ class ;
422
+ $ className = false !== strpos ($ class , "@anonymous \0" ) ? (get_parent_class ($ class ) ?: key (class_implements ($ class )) ?: 'class ' ).'@anonymous ' : $ class ;
423
423
424
424
// Don't trigger deprecations for classes in the same vendor
425
425
if ($ class !== $ className ) {
@@ -435,17 +435,17 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array
435
435
// Detect annotations on the class
436
436
if (false !== $ doc = $ refl ->getDocComment ()) {
437
437
foreach (['final ' , 'deprecated ' , 'internal ' ] as $ annotation ) {
438
- if (str_contains ($ doc , $ annotation ) && preg_match ('#\n\s+\* @ ' .$ annotation .'(?:( .+?)\.?)?\r?\n\s+\*(?: @|/$|\r?\n)#s ' , $ doc , $ notice )) {
438
+ if (false !== strpos ($ doc , $ annotation ) && preg_match ('#\n\s+\* @ ' .$ annotation .'(?:( .+?)\.?)?\r?\n\s+\*(?: @|/$|\r?\n)#s ' , $ doc , $ notice )) {
439
439
self ::$ {$ annotation }[$ class ] = isset ($ notice [1 ]) ? preg_replace ('#\.?\r?\n( \*)? *(?= |\r?\n|$)# ' , '' , $ notice [1 ]) : '' ;
440
440
}
441
441
}
442
442
443
- 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 )) {
443
+ 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 )) {
444
444
foreach ($ notice as $ method ) {
445
445
$ static = '' !== $ method [1 ] && !empty ($ method [2 ]);
446
446
$ name = $ method [3 ];
447
447
$ description = $ method [4 ] ?? null ;
448
- if (! str_contains ($ name , '( ' )) {
448
+ if (false === strpos ($ name , '( ' )) {
449
449
$ name .= '() ' ;
450
450
}
451
451
if (null !== $ description ) {
@@ -496,7 +496,7 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array
496
496
}
497
497
} elseif (!$ refl ->isInterface ()) {
498
498
if (!strncmp ($ vendor , str_replace ('_ ' , '\\' , $ use ), $ vendorLen )
499
- && str_starts_with ($ className , 'Symfony \\' )
499
+ && 0 === strpos ($ className , 'Symfony \\' )
500
500
&& (!class_exists (InstalledVersions::class)
501
501
|| 'symfony/symfony ' !== InstalledVersions::getRootPackage ()['name ' ])
502
502
) {
@@ -597,12 +597,12 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array
597
597
598
598
$ forcePatchTypes = $ this ->patchTypes ['force ' ];
599
599
600
- if ($ canAddReturnType = null !== $ forcePatchTypes && ! str_contains ($ method ->getFileName (), \DIRECTORY_SEPARATOR .'vendor ' .\DIRECTORY_SEPARATOR )) {
600
+ if ($ canAddReturnType = null !== $ forcePatchTypes && false === strpos ($ method ->getFileName (), \DIRECTORY_SEPARATOR .'vendor ' .\DIRECTORY_SEPARATOR )) {
601
601
if ('void ' !== (self ::MAGIC_METHODS [$ method ->name ] ?? 'void ' )) {
602
602
$ this ->patchTypes ['force ' ] = $ forcePatchTypes ?: 'docblock ' ;
603
603
}
604
604
605
- $ canAddReturnType = str_contains ($ refl ->getFileName (), \DIRECTORY_SEPARATOR .'Tests ' .\DIRECTORY_SEPARATOR )
605
+ $ canAddReturnType = false !== strpos ($ refl ->getFileName (), \DIRECTORY_SEPARATOR .'Tests ' .\DIRECTORY_SEPARATOR )
606
606
|| $ refl ->isFinal ()
607
607
|| $ method ->isFinal ()
608
608
|| $ method ->isPrivate ()
@@ -623,8 +623,8 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array
623
623
$ this ->patchMethod ($ method , $ returnType , $ declaringFile , $ normalizedType );
624
624
}
625
625
626
- if (! str_contains ($ doc , '* @deprecated ' ) && strncmp ($ ns , $ declaringClass , $ len )) {
627
- if ($ canAddReturnType && 'docblock ' === $ this ->patchTypes ['force ' ] && ! str_contains ($ method ->getFileName (), \DIRECTORY_SEPARATOR .'vendor ' .\DIRECTORY_SEPARATOR )) {
626
+ if (false === strpos ($ doc , '* @deprecated ' ) && strncmp ($ ns , $ declaringClass , $ len )) {
627
+ if ($ canAddReturnType && 'docblock ' === $ this ->patchTypes ['force ' ] && false === strpos ($ method ->getFileName (), \DIRECTORY_SEPARATOR .'vendor ' .\DIRECTORY_SEPARATOR )) {
628
628
$ this ->patchMethod ($ method , $ returnType , $ declaringFile , $ normalizedType );
629
629
} elseif ('' !== $ declaringClass && $ this ->patchTypes ['deprecations ' ]) {
630
630
$ 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 );
@@ -640,7 +640,7 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array
640
640
641
641
$ matches = [];
642
642
643
- if (!$ method ->hasReturnType () && ((str_contains ($ doc , '@return ' ) && preg_match ('/\n\s+\* @return +([^\s<(]+)/ ' , $ doc , $ matches )) || 'void ' !== (self ::MAGIC_METHODS [$ method ->name ] ?? 'void ' ))) {
643
+ if (!$ method ->hasReturnType () && ((false !== strpos ($ doc , '@return ' ) && preg_match ('/\n\s+\* @return +([^\s<(]+)/ ' , $ doc , $ matches )) || 'void ' !== (self ::MAGIC_METHODS [$ method ->name ] ?? 'void ' ))) {
644
644
$ matches = $ matches ?: [1 => self ::MAGIC_METHODS [$ method ->name ]];
645
645
$ this ->setReturnType ($ matches [1 ], $ method , $ parent );
646
646
@@ -662,14 +662,14 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array
662
662
$ finalOrInternal = false ;
663
663
664
664
foreach (['final ' , 'internal ' ] as $ annotation ) {
665
- if (str_contains ($ doc , $ annotation ) && preg_match ('#\n\s+\* @ ' .$ annotation .'(?:( .+?)\.?)?\r?\n\s+\*(?: @|/$|\r?\n)#s ' , $ doc , $ notice )) {
665
+ if (false !== strpos ($ doc , $ annotation ) && preg_match ('#\n\s+\* @ ' .$ annotation .'(?:( .+?)\.?)?\r?\n\s+\*(?: @|/$|\r?\n)#s ' , $ doc , $ notice )) {
666
666
$ message = isset ($ notice [1 ]) ? preg_replace ('#\.?\r?\n( \*)? *(?= |\r?\n|$)# ' , '' , $ notice [1 ]) : '' ;
667
667
self ::$ {$ annotation .'Methods ' }[$ class ][$ method ->name ] = [$ class , $ message ];
668
668
$ finalOrInternal = true ;
669
669
}
670
670
}
671
671
672
- if ($ finalOrInternal || $ method ->isConstructor () || ! str_contains ($ doc , '@param ' ) || StatelessInvocation::class === $ class ) {
672
+ if ($ finalOrInternal || $ method ->isConstructor () || false === strpos ($ doc , '@param ' ) || StatelessInvocation::class === $ class ) {
673
673
continue ;
674
674
}
675
675
if (!preg_match_all ('#\n\s+\* @param +((?(?!callable *\().*?|callable *\(.*\).*?))(?<= )\$([a-zA-Z0-9_\x7f-\xff]++)# ' , $ doc , $ matches , \PREG_SET_ORDER )) {
@@ -850,7 +850,7 @@ private function setReturnType(string $types, \ReflectionMethod $method, ?string
850
850
$ iterable = $ object = true ;
851
851
foreach ($ typesMap as $ n => $ t ) {
852
852
if ('null ' !== $ n ) {
853
- $ iterable = $ iterable && (\in_array ($ n , ['array ' , 'iterable ' ]) || str_contains ($ n , 'Iterator ' ));
853
+ $ iterable = $ iterable && (\in_array ($ n , ['array ' , 'iterable ' ]) || false !== strpos ($ n , 'Iterator ' ));
854
854
$ object = $ object && (\in_array ($ n , ['callable ' , 'object ' , '$this ' , 'static ' ]) || !isset (self ::SPECIAL_RETURN_TYPES [$ n ]));
855
855
}
856
856
}
@@ -1034,15 +1034,15 @@ private static function getUseStatements(string $file): array
1034
1034
break ;
1035
1035
}
1036
1036
1037
- if (str_starts_with ($ file [$ i ], 'namespace ' )) {
1037
+ if (0 === strpos ($ file [$ i ], 'namespace ' )) {
1038
1038
$ namespace = substr ($ file [$ i ], \strlen ('namespace ' ), -2 ).'\\' ;
1039
1039
$ useOffset = $ i + 2 ;
1040
1040
}
1041
1041
1042
- if (str_starts_with ($ file [$ i ], 'use ' )) {
1042
+ if (0 === strpos ($ file [$ i ], 'use ' )) {
1043
1043
$ useOffset = $ i ;
1044
1044
1045
- for (; str_starts_with ($ file [$ i ], 'use ' ); ++$ i ) {
1045
+ for (; 0 === strpos ($ file [$ i ], 'use ' ); ++$ i ) {
1046
1046
$ u = explode (' as ' , substr ($ file [$ i ], 4 , -2 ), 2 );
1047
1047
1048
1048
if (1 === \count ($ u )) {
0 commit comments