You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -99,8 +109,7 @@ public function validateDirectory(array $files)
99
109
}
100
110
101
111
/**
102
-
* This method scans through all global-scoped calls to array_merge
103
-
* and extracts all string keys of all array arguments.
112
+
* This method scans through all array literals and collects all their string keys.
104
113
*
105
114
* @param string $filename File name to a phpBB language file
106
115
* @return array
@@ -109,50 +118,9 @@ public function validateDirectory(array $files)
109
118
protectedfunctionload_language_keys($filename)
110
119
{
111
120
$contents = @file_get_contents($filename);
112
-
113
-
$keys = [];
114
-
115
121
$nodes = $this->parser->parse($contents);
116
-
117
-
foreach ($nodesas$node)
118
-
{
119
-
if ($nodeinstanceof Assign && $node->exprinstanceof FuncCall)
120
-
{
121
-
/** @var FuncCall $expr */
122
-
$expr = $node->expr;
123
-
124
-
if ($expr->name->getFirst() === 'array_merge')
125
-
{
126
-
for ($i = 1; $i < sizeof($expr->args); $i++)
127
-
{
128
-
/** @var Array_ $array */
129
-
$array = $expr->args[$i]->value;
130
-
131
-
if ($arrayinstanceof Array_)
132
-
{
133
-
foreach ($array->itemsas$item)
134
-
{
135
-
/** @var ArrayItem $item */
136
-
if ($item->keyinstanceof String_)
137
-
{
138
-
$keys[] = $item->key->value;
139
-
}
140
-
else
141
-
{
142
-
$this->output->addMessage(OutputInterface::NOTICE, 'Language key is not a string value in ' . substr($filename, strlen($this->basedir)) . ' on line ' . $item->key->getLine());
143
-
}
144
-
}
145
-
}
146
-
else
147
-
{
148
-
$this->output->addMessage(OutputInterface::ERROR, sprintf('Expected argument %d of array_merge() to be %s, got %s on line %d', $i + 1, Array_::class, get_class($array), $array->getLine()));
0 commit comments