Skip to content

Commit 4500fe6

Browse files
committed
Merge branch '4.4' into 5.3
* 4.4: Remove polyfills from Yaml and Dotenv
2 parents 90909bd + 3abcc4d commit 4500fe6

File tree

6 files changed

+24
-25
lines changed

6 files changed

+24
-25
lines changed

Command/LintCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ private function displayTxt(SymfonyStyle $io, array $filesInfo, bool $errorAsGit
174174
$io->text('<error> ERROR </error>'.($info['file'] ? sprintf(' in %s', $info['file']) : ''));
175175
$io->text(sprintf('<error> >> %s</error>', $info['message']));
176176

177-
if (str_contains($info['message'], 'PARSE_CUSTOM_TAGS')) {
177+
if (false !== strpos($info['message'], 'PARSE_CUSTOM_TAGS')) {
178178
$suggestTagOption = true;
179179
}
180180

@@ -203,7 +203,7 @@ private function displayJson(SymfonyStyle $io, array $filesInfo): int
203203
++$errors;
204204
}
205205

206-
if (isset($v['message']) && str_contains($v['message'], 'PARSE_CUSTOM_TAGS')) {
206+
if (isset($v['message']) && false !== strpos($v['message'], 'PARSE_CUSTOM_TAGS')) {
207207
$v['message'] .= ' Use the --parse-tags option if you want parse custom tags.';
208208
}
209209
});

Dumper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function dump($input, int $inline = 0, int $indent = 0, int $flags = 0):
6868
$output .= "\n";
6969
}
7070

71-
if (Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value) && str_contains($value, "\n") && !str_contains($value, "\r")) {
71+
if (Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value) && false !== strpos($value, "\n") && false === strpos($value, "\r")) {
7272
// If the first line starts with a space character, the spec requires a blockIndicationIndicator
7373
// http://www.yaml.org/spec/1.2/spec.html#id2793979
7474
$blockIndentationIndicator = (' ' === substr($value, 0, 1)) ? (string) $this->indentation : '';
@@ -97,7 +97,7 @@ public function dump($input, int $inline = 0, int $indent = 0, int $flags = 0):
9797
if ($value instanceof TaggedValue) {
9898
$output .= sprintf('%s%s !%s', $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', $value->getTag());
9999

100-
if (Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value->getValue()) && str_contains($value->getValue(), "\n") && !str_contains($value->getValue(), "\r\n")) {
100+
if (Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value->getValue()) && false !== strpos($value->getValue(), "\n") && false === strpos($value->getValue(), "\r\n")) {
101101
// If the first line starts with a space character, the spec requires a blockIndicationIndicator
102102
// http://www.yaml.org/spec/1.2/spec.html#id2793979
103103
$blockIndentationIndicator = (' ' === substr($value->getValue(), 0, 1)) ? (string) $this->indentation : '';

Exception/ParseException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ private function updateRepr()
108108
$this->message = $this->rawMessage;
109109

110110
$dot = false;
111-
if (str_ends_with($this->message, '.')) {
111+
if ('.' === substr($this->message, -1)) {
112112
$this->message = substr($this->message, 0, -1);
113113
$dot = true;
114114
}

Inline.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ private static function parseSequence(string $sequence, int $flags, int &$i = 0,
377377
$value = self::parseScalar($sequence, $flags, [',', ']'], $i, null === $tag, $references);
378378

379379
// the value can be an array if a reference has been resolved to an array var
380-
if (\is_string($value) && !$isQuoted && str_contains($value, ': ')) {
380+
if (\is_string($value) && !$isQuoted && false !== strpos($value, ': ')) {
381381
// embedded mapping?
382382
try {
383383
$pos = 0;
@@ -564,7 +564,7 @@ private static function evaluateScalar(string $scalar, int $flags, array &$refer
564564
{
565565
$scalar = trim($scalar);
566566

567-
if (str_starts_with($scalar, '*')) {
567+
if (0 === strpos($scalar, '*')) {
568568
if (false !== $pos = strpos($scalar, '#')) {
569569
$value = substr($scalar, 1, $pos - 2);
570570
} else {
@@ -596,11 +596,11 @@ private static function evaluateScalar(string $scalar, int $flags, array &$refer
596596
return false;
597597
case '!' === $scalar[0]:
598598
switch (true) {
599-
case str_starts_with($scalar, '!!str '):
599+
case 0 === strpos($scalar, '!!str '):
600600
return (string) substr($scalar, 6);
601-
case str_starts_with($scalar, '! '):
601+
case 0 === strpos($scalar, '! '):
602602
return substr($scalar, 2);
603-
case str_starts_with($scalar, '!php/object'):
603+
case 0 === strpos($scalar, '!php/object'):
604604
if (self::$objectSupport) {
605605
if (!isset($scalar[12])) {
606606
trigger_deprecation('symfony/yaml', '5.1', 'Using the !php/object tag without a value is deprecated.');
@@ -616,7 +616,7 @@ private static function evaluateScalar(string $scalar, int $flags, array &$refer
616616
}
617617

618618
return null;
619-
case str_starts_with($scalar, '!php/const'):
619+
case 0 === strpos($scalar, '!php/const'):
620620
if (self::$constantSupport) {
621621
if (!isset($scalar[11])) {
622622
trigger_deprecation('symfony/yaml', '5.1', 'Using the !php/const tag without a value is deprecated.');
@@ -636,9 +636,9 @@ private static function evaluateScalar(string $scalar, int $flags, array &$refer
636636
}
637637

638638
return null;
639-
case str_starts_with($scalar, '!!float '):
639+
case 0 === strpos($scalar, '!!float '):
640640
return (float) substr($scalar, 8);
641-
case str_starts_with($scalar, '!!binary '):
641+
case 0 === strpos($scalar, '!!binary '):
642642
return self::evaluateBinaryScalar(substr($scalar, 9));
643643
default:
644644
throw new ParseException(sprintf('The string "%s" could not be parsed as it uses an unsupported built-in tag.', $scalar), self::$parsedLineNumber, $scalar, self::$parsedFilename);

Parser.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ private function doParse(string $value, int $flags)
173173
}
174174

175175
// array
176-
if (isset($values['value']) && str_starts_with(ltrim($values['value'], ' '), '-')) {
176+
if (isset($values['value']) && 0 === strpos(ltrim($values['value'], ' '), '-')) {
177177
// Inline first child
178178
$currentLineNumber = $this->getRealCurrentLineNb();
179179

@@ -182,7 +182,7 @@ private function doParse(string $value, int $flags)
182182
$sequenceYaml .= "\n".$this->getNextEmbedBlock($sequenceIndentation, true);
183183

184184
$data[] = $this->parseBlock($currentLineNumber, rtrim($sequenceYaml), $flags);
185-
} elseif (!isset($values['value']) || '' == trim($values['value'], ' ') || str_starts_with(ltrim($values['value'], ' '), '#')) {
185+
} elseif (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#')) {
186186
$data[] = $this->parseBlock($this->getRealCurrentLineNb() + 1, $this->getNextEmbedBlock(null, true) ?? '', $flags);
187187
} elseif (null !== $subTag = $this->getLineTag(ltrim($values['value'], ' '), $flags)) {
188188
$data[] = new TaggedValue(
@@ -214,7 +214,7 @@ private function doParse(string $value, int $flags)
214214
}
215215
} elseif (
216216
self::preg_match('#^(?P<key>(?:![^\s]++\s++)?(?:'.Inline::REGEX_QUOTED_STRING.'|(?:!?!php/const:)?[^ \'"\[\{!].*?)) *\:(( |\t)++(?P<value>.+))?$#u', rtrim($this->currentLine), $values)
217-
&& (!str_contains($values['key'], ' #') || \in_array($values['key'][0], ['"', "'"]))
217+
&& (false === strpos($values['key'], ' #') || \in_array($values['key'][0], ['"', "'"]))
218218
) {
219219
if ($context && 'sequence' == $context) {
220220
throw new ParseException('You cannot define a mapping item when in a sequence.', $this->currentLineNb + 1, $this->currentLine, $this->filename);
@@ -309,7 +309,7 @@ private function doParse(string $value, int $flags)
309309
$subTag = null;
310310
if ($mergeNode) {
311311
// Merge keys
312-
} elseif (!isset($values['value']) || '' === $values['value'] || str_starts_with($values['value'], '#') || (null !== $subTag = $this->getLineTag($values['value'], $flags)) || '<<' === $key) {
312+
} elseif (!isset($values['value']) || '' === $values['value'] || 0 === strpos($values['value'], '#') || (null !== $subTag = $this->getLineTag($values['value'], $flags)) || '<<' === $key) {
313313
// hash
314314
// if next line is less indented or equal, then it means that the current value is null
315315
if (!$this->isNextLineIndented() && !$this->isNextLineUnIndentedCollection()) {
@@ -457,7 +457,7 @@ private function doParse(string $value, int $flags)
457457
throw new ParseException('Unable to parse.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
458458
}
459459

460-
if (str_contains($line, ': ')) {
460+
if (false !== strpos($line, ': ')) {
461461
throw new ParseException('Mapping values are not allowed in multi-line blocks.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
462462
}
463463

@@ -467,7 +467,7 @@ private function doParse(string $value, int $flags)
467467
$value .= ' ';
468468
}
469469

470-
if ('' !== $trimmedLine && str_ends_with($line, '\\')) {
470+
if ('' !== $trimmedLine && '\\' === substr($line, -1)) {
471471
$value .= ltrim(substr($line, 0, -1));
472472
} elseif ('' !== $trimmedLine) {
473473
$value .= $trimmedLine;
@@ -476,7 +476,7 @@ private function doParse(string $value, int $flags)
476476
if ('' === $trimmedLine) {
477477
$previousLineWasNewline = true;
478478
$previousLineWasTerminatedWithBackslash = false;
479-
} elseif (str_ends_with($line, '\\')) {
479+
} elseif ('\\' === substr($line, -1)) {
480480
$previousLineWasNewline = false;
481481
$previousLineWasTerminatedWithBackslash = true;
482482
} else {
@@ -724,7 +724,7 @@ private function moveToPreviousLine(): bool
724724
*/
725725
private function parseValue(string $value, int $flags, string $context)
726726
{
727-
if (str_starts_with($value, '*')) {
727+
if (0 === strpos($value, '*')) {
728728
if (false !== $pos = strpos($value, '#')) {
729729
$value = substr($value, 1, $pos - 2);
730730
} else {
@@ -811,7 +811,7 @@ private function parseValue(string $value, int $flags, string $context)
811811

812812
$parsedValue = Inline::parse($value, $flags, $this->refs);
813813

814-
if ('mapping' === $context && \is_string($parsedValue) && '"' !== $value[0] && "'" !== $value[0] && '[' !== $value[0] && '{' !== $value[0] && '!' !== $value[0] && str_contains($parsedValue, ': ')) {
814+
if ('mapping' === $context && \is_string($parsedValue) && '"' !== $value[0] && "'" !== $value[0] && '[' !== $value[0] && '{' !== $value[0] && '!' !== $value[0] && false !== strpos($parsedValue, ': ')) {
815815
throw new ParseException('A colon cannot be used in an unquoted mapping value.', $this->getRealCurrentLineNb() + 1, $value, $this->filename);
816816
}
817817

@@ -1081,7 +1081,7 @@ private function isNextLineUnIndentedCollection(): bool
10811081
*/
10821082
private function isStringUnIndentedCollectionItem(): bool
10831083
{
1084-
return '-' === rtrim($this->currentLine) || str_starts_with($this->currentLine, '- ');
1084+
return '-' === rtrim($this->currentLine) || 0 === strpos($this->currentLine, '- ');
10851085
}
10861086

10871087
/**

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
"require": {
1919
"php": ">=7.2.5",
2020
"symfony/deprecation-contracts": "^2.1",
21-
"symfony/polyfill-ctype": "~1.8",
22-
"symfony/polyfill-php80": "^1.16"
21+
"symfony/polyfill-ctype": "~1.8"
2322
},
2423
"require-dev": {
2524
"symfony/console": "^4.4|^5.0"

0 commit comments

Comments
 (0)