summaryrefslogtreecommitdiffstatshomepage
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/phpstan.neon.dist2
-rwxr-xr-xcore/scripts/update-countries.sh12
2 files changed, 13 insertions, 1 deletions
diff --git a/core/phpstan.neon.dist b/core/phpstan.neon.dist
index 4cd4f9cfa591..40e1c821d029 100644
--- a/core/phpstan.neon.dist
+++ b/core/phpstan.neon.dist
@@ -36,6 +36,8 @@ parameters:
# Skip Drupal 6 & 7 code.
- scripts/dump-database-d?.sh
- scripts/generate-d?-content.sh
+ # Skip update countries script for fake t() declaration.
+ - scripts/update-countries.sh
# Skip data files.
- lib/Drupal/Component/Transliteration/data/*.php
# The following classes deliberately extend non-existent classes for testing.
diff --git a/core/scripts/update-countries.sh b/core/scripts/update-countries.sh
index 52676e9f30bb..59f04b196ee6 100755
--- a/core/scripts/update-countries.sh
+++ b/core/scripts/update-countries.sh
@@ -35,6 +35,16 @@ USAGE;
exit('CLDR data file not found. (' . $uri . ")\n\n" . $usage . "\n");
}
+// Fake the t() function used in CountryManager.php instead of attempting a full
+// Drupal bootstrap of core/includes/bootstrap.inc (where t() is declared).
+if (!function_exists('t')) {
+
+ function t($string): string {
+ return $string;
+ }
+
+}
+
// Read in existing codes.
// @todo Allow to remove previously existing country codes.
// @see https://www.drupal.org/node/1436754
@@ -93,7 +103,7 @@ $out = '';
foreach ($countries as $code => $name) {
// For .po translation file's sake, use double-quotes instead of escaped
// single-quotes.
- $name = str_contains($name, '\'' ? '"' . $name . '"' : "'" . $name . "'");
+ $name = str_contains($name, '\'') ? '"' . $name . '"' : "'" . $name . "'";
$out .= ' ' . var_export($code, TRUE) . ' => t(' . $name . '),' . "\n";
}