Update to laravel 7

This commit is contained in:
KodeStar
2022-03-10 11:54:29 +00:00
parent 61a5a1a8b0
commit f9a19fce91
7170 changed files with 274189 additions and 283773 deletions

View File

@@ -23,9 +23,9 @@ class ArrayLoader implements LoaderInterface
/**
* {@inheritdoc}
*/
public function load($resource, $locale, $domain = 'messages')
public function load($resource, string $locale, string $domain = 'messages')
{
$this->flatten($resource);
$resource = $this->flatten($resource);
$catalogue = new MessageCatalogue($locale);
$catalogue->add($resource, $domain);
@@ -39,28 +39,20 @@ class ArrayLoader implements LoaderInterface
* 'key' => ['key2' => ['key3' => 'value']]
* Becomes:
* 'key.key2.key3' => 'value'
*
* This function takes an array by reference and will modify it
*
* @param array &$messages The array that will be flattened
* @param array $subnode Current subnode being parsed, used internally for recursive calls
* @param string $path Current path being parsed, used internally for recursive calls
*/
private function flatten(array &$messages, array $subnode = null, $path = null)
private function flatten(array $messages): array
{
if (null === $subnode) {
$subnode = &$messages;
}
foreach ($subnode as $key => $value) {
$result = [];
foreach ($messages as $key => $value) {
if (\is_array($value)) {
$nodePath = $path ? $path.'.'.$key : $key;
$this->flatten($messages, $value, $nodePath);
if (null === $path) {
unset($messages[$key]);
foreach ($this->flatten($value) as $k => $v) {
$result[$key.'.'.$k] = $v;
}
} elseif (null !== $path) {
$messages[$path.'.'.$key] = $value;
} else {
$result[$key] = $value;
}
}
return $result;
}
}