Skip to content

Commit e9fde16

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

File tree

9 files changed

+11
-10
lines changed

9 files changed

+11
-10
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
@@ -530,7 +530,7 @@ public function setTimeZoneId($timeZoneId)
530530
$timeZone = $timeZoneId;
531531

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

NumberFormatter/NumberFormatter.php

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

Tests/Data/Provider/AbstractDataProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ protected function getRootLocales()
787787
if (null === self::$rootLocales) {
788788
self::$rootLocales = array_filter(static::getLocales(), function ($locale) {
789789
// no locales for which fallback is possible (e.g "en_GB")
790-
return false === strpos($locale, '_');
790+
return !str_contains($locale, '_');
791791
});
792792
}
793793

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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
],
2626
"require": {
2727
"php": ">=7.1.3",
28-
"symfony/polyfill-intl-icu": "~1.0"
28+
"symfony/polyfill-intl-icu": "~1.0",
29+
"symfony/polyfill-php80": "^1.16"
2930
},
3031
"require-dev": {
3132
"symfony/filesystem": "^3.4|^4.0|^5.0"

0 commit comments

Comments
 (0)