Skip to content

Commit 70c5483

Browse files
Merge branch '5.2' into 5.3
* 5.2: Leverage str_contains/str_starts_with Leverage str_ends_with
2 parents 34b7c04 + 3cc1e94 commit 70c5483

11 files changed

+15
-15
lines changed

Command/DebugCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ private function getFqcnTypeClass(InputInterface $input, SymfonyStyle $io, strin
168168
$classes[] = $fqcn;
169169
} elseif (class_exists($fqcn = $namespace.'\\'.ucfirst($shortClassName).'Type')) {
170170
$classes[] = $fqcn;
171-
} elseif ('type' === substr($shortClassName, -4) && class_exists($fqcn = $namespace.'\\'.ucfirst(substr($shortClassName, 0, -4).'Type'))) {
171+
} elseif (str_ends_with($shortClassName, 'type') && class_exists($fqcn = $namespace.'\\'.ucfirst(substr($shortClassName, 0, -4).'Type'))) {
172172
$classes[] = $fqcn;
173173
}
174174
}
@@ -231,7 +231,7 @@ private function findAlternatives(string $name, array $collection): array
231231
$alternatives = [];
232232
foreach ($collection as $item) {
233233
$lev = levenshtein($name, $item);
234-
if ($lev <= \strlen($name) / 3 || false !== strpos($item, $name)) {
234+
if ($lev <= \strlen($name) / 3 || str_contains($item, $name)) {
235235
$alternatives[$item] = isset($alternatives[$item]) ? $alternatives[$item] - $lev : $lev;
236236
}
237237
}

Extension/Core/DataMapper/PropertyPathMapper.php

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

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
@@ -40,7 +40,7 @@ public function reverseTransform($value)
4040
{
4141
$decimalSeparator = $this->getNumberFormatter()->getSymbol(\NumberFormatter::DECIMAL_SEPARATOR_SYMBOL);
4242

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

Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public function reverseTransform($value)
143143
$value = str_replace(',', $decSep, $value);
144144
}
145145

146-
if (false !== strpos($value, $decSep)) {
146+
if (str_contains($value, $decSep)) {
147147
$type = \NumberFormatter::TYPE_DOUBLE;
148148
} else {
149149
$type = \PHP_INT_SIZE === 8

Extension/Core/DataTransformer/PercentToLocalizedStringTransformer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public function reverseTransform($value)
133133
$value = str_replace(',', $decSep, $value);
134134
}
135135

136-
if (false !== strpos($value, $decSep)) {
136+
if (str_contains($value, $decSep)) {
137137
$type = \NumberFormatter::TYPE_DOUBLE;
138138
} else {
139139
$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
@@ -188,9 +188,9 @@ private static function getMaxFilesize()
188188
}
189189

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

Extension/Validator/ViolationMapper/ViolationMapper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ private function matchChild(FormInterface $form, PropertyPathIteratorInterface $
267267
if ($childPath === $chunk) {
268268
$target = $child;
269269
$foundAtIndex = $it->key();
270-
} elseif (0 === strpos($childPath, $chunk)) {
270+
} elseif (str_starts_with($childPath, $chunk)) {
271271
continue;
272272
}
273273

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)