Skip to content

Commit

Permalink
Merge branch '4.4' into 5.2
Browse files Browse the repository at this point in the history
* 4.4:
  Leverage str_contains/str_starts_with
  Leverage str_ends_with
  • Loading branch information
nicolas-grekas committed Jul 21, 2021
2 parents 2c6d410 + c5a2797 commit ae17d00
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Dumper/XliffFileDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ private function dumpXliff2(string $defaultLocale, MessageCatalogue $messages, ?
$xliff->setAttribute('trgLang', str_replace('_', '-', $messages->getLocale()));

$xliffFile = $xliff->appendChild($dom->createElement('file'));
if (MessageCatalogue::INTL_DOMAIN_SUFFIX === substr($domain, -($suffixLength = \strlen(MessageCatalogue::INTL_DOMAIN_SUFFIX)))) {
$xliffFile->setAttribute('id', substr($domain, 0, -$suffixLength).'.'.$messages->getLocale());
if (str_ends_with($domain, MessageCatalogue::INTL_DOMAIN_SUFFIX)) {
$xliffFile->setAttribute('id', substr($domain, 0, -\strlen(MessageCatalogue::INTL_DOMAIN_SUFFIX)).'.'.$messages->getLocale());
} else {
$xliffFile->setAttribute('id', $domain.'.'.$messages->getLocale());
}
Expand Down
2 changes: 1 addition & 1 deletion Extractor/PhpStringTokenParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public static function parseDocString(string $startToken, string $str)
$str = preg_replace('~(\r\n|\n|\r)$~', '', $str);

// nowdoc string
if (false !== strpos($startToken, '\'')) {
if (str_contains($startToken, '\'')) {
return $str;
}

Expand Down
4 changes: 2 additions & 2 deletions Loader/MoFileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ protected function loadResource(string $resource)
fseek($stream, $offset);
$singularId = fread($stream, $length);

if (false !== strpos($singularId, "\000")) {
if (str_contains($singularId, "\000")) {
[$singularId, $pluralId] = explode("\000", $singularId);
}

Expand All @@ -104,7 +104,7 @@ protected function loadResource(string $resource)
fseek($stream, $offset);
$translated = fread($stream, $length);

if (false !== strpos($translated, "\000")) {
if (str_contains($translated, "\000")) {
$translated = explode("\000", $translated);
}

Expand Down
4 changes: 2 additions & 2 deletions MessageCatalogue.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function all(string $domain = null)
{
if (null !== $domain) {
// skip messages merge if intl-icu requested explicitly
if (false !== strpos($domain, self::INTL_DOMAIN_SUFFIX)) {
if (str_contains($domain, self::INTL_DOMAIN_SUFFIX)) {
return $this->messages[$domain] ?? [];
}

Expand Down Expand Up @@ -162,7 +162,7 @@ public function add(array $messages, string $domain = 'messages')
}
$intlDomain = $domain;
$suffixLength = \strlen(self::INTL_DOMAIN_SUFFIX);
if (\strlen($domain) < $suffixLength || false === strpos($domain, self::INTL_DOMAIN_SUFFIX, -$suffixLength)) {
if (\strlen($domain) < $suffixLength || !str_contains($domain, self::INTL_DOMAIN_SUFFIX, -$suffixLength)) {
$intlDomain .= self::INTL_DOMAIN_SUFFIX;
}
foreach ($messages as $id => $message) {
Expand Down
2 changes: 1 addition & 1 deletion Resources/bin/translation-status.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
}

foreach (array_slice($argv, 1) as $argumentOrOption) {
if (0 === strpos($argumentOrOption, '-')) {
if (str_starts_with($argumentOrOption, '-')) {
$config['verbose_output'] = true;
} else {
$config['locale_to_analyze'] = $argumentOrOption;
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"require": {
"php": ">=7.2.5",
"symfony/polyfill-mbstring": "~1.0",
"symfony/polyfill-php80": "^1.15",
"symfony/polyfill-php80": "^1.16",
"symfony/translation-contracts": "^2.3"
},
"require-dev": {
Expand Down

0 comments on commit ae17d00

Please sign in to comment.