Skip to content

Commit 4a241eb

Browse files
derrabusnicolas-grekas
authored andcommitted
Leverage str_contains/str_starts_with
Signed-off-by: Alexander M. Turek <[email protected]>
1 parent 4fd31dd commit 4a241eb

File tree

10 files changed

+13
-13
lines changed

10 files changed

+13
-13
lines changed

Command/DebugCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ private function findAlternatives(string $name, array $collection): array
230230
$alternatives = [];
231231
foreach ($collection as $item) {
232232
$lev = levenshtein($name, $item);
233-
if ($lev <= \strlen($name) / 3 || false !== strpos($item, $name)) {
233+
if ($lev <= \strlen($name) / 3 || str_contains($item, $name)) {
234234
$alternatives[$item] = isset($alternatives[$item]) ? $alternatives[$item] - $lev : $lev;
235235
}
236236
}

Extension/Core/DataMapper/PropertyPathMapper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ private function getPropertyValue($data, $propertyPath)
9898
} catch (AccessException $e) {
9999
if (!$e instanceof UninitializedPropertyException
100100
// For versions without UninitializedPropertyException check the exception message
101-
&& (class_exists(UninitializedPropertyException::class) || false === strpos($e->getMessage(), 'You should initialize it'))
101+
&& (class_exists(UninitializedPropertyException::class) || !str_contains($e->getMessage(), 'You should initialize it'))
102102
) {
103103
throw $e;
104104
}

Extension/Core/DataTransformer/DateTimeToStringTransformer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function __construct(string $inputTimezone = null, string $outputTimezone
6262
// where the time corresponds to the current server time.
6363
// With "|" and "Y-m-d", "2010-02-03" becomes "2010-02-03 00:00:00",
6464
// which is at least deterministic and thus used here.
65-
if (false === strpos($this->parseFormat, '|')) {
65+
if (!str_contains($this->parseFormat, '|')) {
6666
$this->parseFormat .= '|';
6767
}
6868
}

Extension/Core/DataTransformer/IntegerToLocalizedStringTransformer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function reverseTransform($value)
4848
{
4949
$decimalSeparator = $this->getNumberFormatter()->getSymbol(\NumberFormatter::DECIMAL_SEPARATOR_SYMBOL);
5050

51-
if (\is_string($value) && false !== strpos($value, $decimalSeparator)) {
51+
if (\is_string($value) && str_contains($value, $decimalSeparator)) {
5252
throw new TransformationFailedException(sprintf('The value "%s" is not a valid integer.', $value));
5353
}
5454

Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public function reverseTransform($value)
157157
$value = str_replace(',', $decSep, $value);
158158
}
159159

160-
if (false !== strpos($value, $decSep)) {
160+
if (str_contains($value, $decSep)) {
161161
$type = \NumberFormatter::TYPE_DOUBLE;
162162
} else {
163163
$type = \PHP_INT_SIZE === 8

Extension/Core/DataTransformer/PercentToLocalizedStringTransformer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public function reverseTransform($value)
122122
$value = str_replace(',', $decSep, $value);
123123
}
124124

125-
if (false !== strpos($value, $decSep)) {
125+
if (str_contains($value, $decSep)) {
126126
$type = \NumberFormatter::TYPE_DOUBLE;
127127
} else {
128128
$type = \PHP_INT_SIZE === 8 ? \NumberFormatter::TYPE_INT64 : \NumberFormatter::TYPE_INT32;

Extension/Core/Type/DateType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
5858
}
5959

6060
if ('single_text' === $options['widget']) {
61-
if ('' !== $pattern && false === strpos($pattern, 'y') && false === strpos($pattern, 'M') && false === strpos($pattern, 'd')) {
61+
if ('' !== $pattern && !str_contains($pattern, 'y') && !str_contains($pattern, 'M') && !str_contains($pattern, 'd')) {
6262
throw new InvalidOptionsException(sprintf('The "format" option should contain the letters "y", "M" or "d". Its current value is "%s".', $pattern));
6363
}
6464

@@ -71,7 +71,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
7171
$pattern
7272
));
7373
} else {
74-
if ('' !== $pattern && (false === strpos($pattern, 'y') || false === strpos($pattern, 'M') || false === strpos($pattern, 'd'))) {
74+
if ('' !== $pattern && (!str_contains($pattern, 'y') || !str_contains($pattern, 'M') || !str_contains($pattern, 'd'))) {
7575
throw new InvalidOptionsException(sprintf('The "format" option should contain the letters "y", "M" and "d". Its current value is "%s".', $pattern));
7676
}
7777

Extension/Core/Type/FileType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,9 @@ private static function getMaxFilesize()
190190
}
191191

192192
$max = ltrim($iniMax, '+');
193-
if (0 === strpos($max, '0x')) {
193+
if (str_starts_with($max, '0x')) {
194194
$max = \intval($max, 16);
195-
} elseif (0 === strpos($max, '0')) {
195+
} elseif (str_starts_with($max, '0')) {
196196
$max = \intval($max, 8);
197197
} else {
198198
$max = (int) $max;

Extension/Validator/ViolationMapper/ViolationMapper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ private function matchChild(FormInterface $form, PropertyPathIteratorInterface $
206206
if ($childPath === $chunk) {
207207
$target = $child;
208208
$foundAtIndex = $it->key();
209-
} elseif (0 === strpos($childPath, $chunk)) {
209+
} elseif (str_starts_with($childPath, $chunk)) {
210210
continue;
211211
}
212212

Util/ServerParams.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ public function getPostMaxSize()
5252
}
5353

5454
$max = ltrim($iniMax, '+');
55-
if (0 === strpos($max, '0x')) {
55+
if (str_starts_with($max, '0x')) {
5656
$max = \intval($max, 16);
57-
} elseif (0 === strpos($max, '0')) {
57+
} elseif (str_starts_with($max, '0')) {
5858
$max = \intval($max, 8);
5959
} else {
6060
$max = (int) $max;

0 commit comments

Comments
 (0)