Skip to content

Commit 4841205

Browse files
Merge branch '4.4' into 5.2
* 4.4: Leverage str_contains/str_starts_with Leverage str_ends_with
2 parents ce917b6 + e9fde16 commit 4841205

File tree

8 files changed

+9
-9
lines changed

8 files changed

+9
-9
lines changed

Data/Bundle/Writer/TextBundleWriter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ private function writeTable($file, iterable $value, int $indentation, bool $fall
194194
fwrite($file, str_repeat(' ', $indentation + 1));
195195

196196
// escape colons, otherwise they are interpreted as resource types
197-
if (false !== strpos($key, ':') || false !== strpos($key, ' ')) {
197+
if (str_contains($key, ':') || str_contains($key, ' ')) {
198198
$key = '"'.$key.'"';
199199
}
200200

Data/Generator/LanguageDataGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ protected function generateDataForLocale(BundleEntryReaderInterface $reader, str
135135
$names = [];
136136
$localizedNames = [];
137137
foreach (self::generateLanguageNames($localeBundle) as $language => $name) {
138-
if (false === strpos($language, '_')) {
138+
if (!str_contains($language, '_')) {
139139
$this->languageCodes[] = $language;
140140
$names[$language] = $name;
141141
} else {

DateFormatter/DateFormat/FullTransformer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ private function formatReplace(string $dateChars, \DateTime $dateTime): string
103103
}
104104

105105
// handle unimplemented characters
106-
if (false !== strpos($this->notImplementedChars, $dateChars[0])) {
106+
if (str_contains($this->notImplementedChars, $dateChars[0])) {
107107
throw new NotImplementedException(sprintf('Unimplemented date character "%s" in format "%s".', $dateChars[0], $this->pattern));
108108
}
109109

DateFormatter/IntlDateFormatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ public function setTimeZoneId(?string $timeZoneId)
529529
$timeZone = $timeZoneId;
530530

531531
// Get an Etc/GMT time zone that is accepted for \DateTimeZone
532-
if ('GMT' !== $timeZoneId && 0 === strpos($timeZoneId, 'GMT')) {
532+
if ('GMT' !== $timeZoneId && str_starts_with($timeZoneId, 'GMT')) {
533533
try {
534534
$timeZoneId = DateFormat\TimezoneTransformer::getEtcTimeZoneId($timeZoneId);
535535
} catch (\InvalidArgumentException $e) {

NumberFormatter/NumberFormatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ public function parse(string $value, int $type = self::TYPE_DOUBLE, int &$positi
531531
// value is not valid if grouping is used, but digits are not grouped in groups of three
532532
if ($error = isset($matches['grouping']) && !preg_match('/^-?(?:\d{1,3}+)?(?:(?:,\d{3})++|\d*+)(?:\.\d*+)?$/', $value)) {
533533
// the position on error is 0 for positive and 1 for negative numbers
534-
$position = 0 === strpos($value, '-') ? 1 : 0;
534+
$position = str_starts_with($value, '-') ? 1 : 0;
535535
}
536536
} else {
537537
$error = true;

Tests/ResourceBundleTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ protected function getRootLocales()
779779
if (null === self::$rootLocales) {
780780
self::$rootLocales = array_filter($this->getLocales(), function ($locale) {
781781
// no locales for which fallback is possible (e.g "en_GB")
782-
return false === strpos($locale, '_');
782+
return !str_contains($locale, '_');
783783
});
784784
}
785785

Tests/Util/GitRepositoryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ public function testItClonesTheRepository()
5858
$this->assertNotEmpty($git->getLastAuthor());
5959
$this->assertInstanceOf(\DateTime::class, $git->getLastAuthoredDate());
6060
$this->assertStringMatchesFormat('v%s', $git->getLastTag());
61-
$this->assertStringMatchesFormat('v3%s', $git->getLastTag(function ($tag) { return 0 === strpos($tag, 'v3'); }));
61+
$this->assertStringMatchesFormat('v3%s', $git->getLastTag(function ($tag) { return str_starts_with($tag, 'v3'); }));
6262
}
6363

6464
public function testItCheckoutsToTheLastTag()
6565
{
6666
$git = GitRepository::download(self::REPO_URL, $this->targetDir);
6767
$lastCommitHash = $git->getLastCommitHash();
68-
$lastV3Tag = $git->getLastTag(function ($tag) { return 0 === strpos($tag, 'v3'); });
68+
$lastV3Tag = $git->getLastTag(function ($tag) { return str_starts_with($tag, 'v3'); });
6969

7070
$git->checkout($lastV3Tag);
7171

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"require": {
2727
"php": ">=7.2.5",
2828
"symfony/polyfill-intl-icu": "~1.0",
29-
"symfony/polyfill-php80": "^1.15"
29+
"symfony/polyfill-php80": "^1.16"
3030
},
3131
"require-dev": {
3232
"symfony/filesystem": "^4.4|^5.0"

0 commit comments

Comments
 (0)