Skip to content

Commit 44ed959

Browse files
committed
triggers warnings when $ignoreDirs or $acceptFiles is not array (BC break)
1 parent 8116b52 commit 44ed959

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/RobotLoader/RobotLoader.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,15 +231,22 @@ private function createFileIterator(string $dir): Nette\Utils\Finder
231231
throw new Nette\IOException("File or directory '$dir' not found.");
232232
}
233233

234-
$ignoreDirs = is_array($this->ignoreDirs) ? $this->ignoreDirs : preg_split('#[,\s]+#', $this->ignoreDirs);
234+
if (!is_array($ignoreDirs = $this->ignoreDirs)) {
235+
trigger_error(__CLASS__ . ': $ignoreDirs must be an array.', E_USER_WARNING);
236+
$ignoreDirs = preg_split('#[,\s]+#', $ignoreDirs);
237+
}
235238
$disallow = [];
236239
foreach (array_merge($ignoreDirs, $this->excludeDirs) as $item) {
237240
if ($item = realpath($item)) {
238241
$disallow[str_replace('\\', '/', $item)] = true;
239242
}
240243
}
241244

242-
$acceptFiles = is_array($this->acceptFiles) ? $this->acceptFiles : preg_split('#[,\s]+#', $this->acceptFiles);
245+
if (!is_array($acceptFiles = $this->acceptFiles)) {
246+
trigger_error(__CLASS__ . ': $acceptFiles must be an array.', E_USER_WARNING);
247+
$acceptFiles = preg_split('#[,\s]+#', $acceptFiles);
248+
}
249+
243250
$iterator = Nette\Utils\Finder::findFiles($acceptFiles)
244251
->filter(function (SplFileInfo $file) use (&$disallow) {
245252
return !isset($disallow[str_replace('\\', '/', $file->getRealPath())]);

0 commit comments

Comments
 (0)