Skip to content

Commit f6f4d86

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

File tree

4 files changed

+11
-12
lines changed

4 files changed

+11
-12
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: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ public function __construct(string|\SimpleXMLElement $data, bool $writeOnly = fa
7373
$returnType = '';
7474
}
7575
foreach ($returnTypes as &$returnType) {
76-
$pos = \strpos($returnType, '?');
77-
if ($pos !== false) {
76+
if (str_contains($returnType, '?')) {
7877
$nullable = true;
7978
$returnType = \str_replace('?', '', $returnType);
8079
}
@@ -178,17 +177,17 @@ public function getSignatureType(?int $errorType = null): string
178177
}
179178

180179
foreach ($types as &$type) {
181-
if (\strpos($type, 'callable(') > -1) {
180+
if (str_contains($type, 'callable(')) {
182181
$type = 'callable'; //strip callable type of its possible parenthesis and return (ex: callable(): void)
183-
} elseif (\strpos($type, 'array<') !== false || \strpos($type, 'array{') !== false) {
182+
} elseif (str_contains($type, 'array<') || str_contains($type, 'array{')) {
184183
$type = 'array'; //typed array has to be untyped
185-
} elseif (\strpos($type, '[]') !== false) {
184+
} elseif (str_contains($type, '[]')) {
186185
$type = 'iterable'; //generics cannot be typehinted and have to be turned into iterable
187-
} elseif (\strpos($type, 'resource') !== false) {
186+
} elseif (str_contains($type, 'resource')) {
188187
$type = ''; // resource cant be typehinted
189-
} elseif (\strpos($type, 'null') !== false) {
188+
} elseif (str_contains($type, 'null')) {
190189
$type = ''; // null is a real typehint
191-
} elseif (\strpos($type, 'true') !== false) {
190+
} elseif (str_contains($type, 'true')) {
192191
$type = 'bool'; // php8.1 doesn't support "true" as a typehint
193192
}
194193
}

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)