Skip to content

Commit e2a0ca0

Browse files
committed
strpos -> str_contains
a simple commit to make this consistent before I do some more serious work
1 parent e7a2faf commit e2a0ca0

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

generator/src/Generator/ComposerJsonEditor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public static function editComposerFileForGeneration(array $modules): void
3838
public static function editFilesListForGeneration(array $oldFiles, array $modules): array
3939
{
4040
$files = array_values(array_filter($oldFiles, function ($file) {
41-
return strpos($file, 'generated/') === false;
41+
return !str_contains($file, 'generated/');
4242
}));
4343
foreach ($modules as $module) {
4444
$files[] = 'generated/'.lcfirst($module).'.php';

generator/src/PhpStanFunctions/PhpStanParameter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class PhpStanParameter
1212
public function __construct(string $name, string $type)
1313
{
1414
$writeOnly = false;
15-
if (\strpos($name, '&w_') !== false) {
15+
if (str_contains($name, '&w_')) {
1616
$writeOnly = true;
1717
}
1818
$name = \str_replace(['&rw_', '&w_'], '', $name);

generator/src/PhpStanFunctions/PhpStanType.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,17 @@ public function getSignatureType(?int $errorType = null): string
178178
}
179179

180180
foreach ($types as &$type) {
181-
if (\strpos($type, 'callable(') > -1) {
181+
if (str_contains($type, 'callable(')) {
182182
$type = 'callable'; //strip callable type of its possible parenthesis and return (ex: callable(): void)
183-
} elseif (\strpos($type, 'array<') !== false || \strpos($type, 'array{') !== false) {
183+
} elseif (str_contains($type, 'array<') || str_contains($type, 'array{')) {
184184
$type = 'array'; //typed array has to be untyped
185-
} elseif (\strpos($type, '[]') !== false) {
185+
} elseif (str_contains($type, '[]')) {
186186
$type = 'iterable'; //generics cannot be typehinted and have to be turned into iterable
187-
} elseif (\strpos($type, 'resource') !== false) {
187+
} elseif (str_contains($type, 'resource')) {
188188
$type = ''; // resource cant be typehinted
189-
} elseif (\strpos($type, 'null') !== false) {
189+
} elseif (str_contains($type, 'null')) {
190190
$type = ''; // null is a real typehint
191-
} elseif (\strpos($type, 'true') !== false) {
191+
} elseif (str_contains($type, 'true')) {
192192
$type = 'bool'; // php8.1 doesn't support "true" as a typehint
193193
}
194194
}

generator/src/XmlDocParser/Parameter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function isOptionalWithNoDefault(): bool
6868

6969
$initializer = $this->getInitializer();
7070
// Some default value have weird values. For instance, first parameter of "mb_internal_encoding" has default value "mb_internal_encoding()"
71-
if ($initializer === 'null' || ($initializer !== 'array()' && strpos($initializer, '(') !== false)) {
71+
if ($initializer === 'null' || ($initializer !== 'array()' && str_contains($initializer, '('))) {
7272
return true;
7373
}
7474
return false;
@@ -110,7 +110,7 @@ public function getDefaultValue(): ?string
110110
$initializer = $this->getInitializer();
111111

112112
// Some default value have weird values. For instance, first parameter of "mb_internal_encoding" has default value "mb_internal_encoding()"
113-
if (strpos($initializer, '(') !== false) {
113+
if (str_contains($initializer, '(')) {
114114
return null;
115115
}
116116

0 commit comments

Comments
 (0)