Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/RobotLoader/RobotLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function tryLoad(string $type): void
*/
public function addDirectory(...$paths): self
{
if (is_array($paths[0])) {
if (is_array($paths[0] ?? null)) {
trigger_error(__METHOD__ . '() use variadics ...$paths to add an array of paths.', E_USER_WARNING);
$paths = $paths[0];
}
Expand All @@ -144,7 +144,7 @@ public function reportParseErrors(bool $on = true): self
*/
public function excludeDirectory(...$paths): self
{
if (is_array($paths[0])) {
if (is_array($paths[0] ?? null)) {
trigger_error(__METHOD__ . '() use variadics ...$paths to add an array of paths.', E_USER_WARNING);
$paths = $paths[0];
}
Expand Down
28 changes: 28 additions & 0 deletions tests/Loaders/RobotLoader.emptyArrayVariadicArgument.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

/**
* Test: Nette\Loaders\RobotLoader bug # 17 POC.
*/

declare(strict_types=1);

use Nette\Loaders\RobotLoader;
use Tester\Assert;


require __DIR__ . '/../bootstrap.php';

$loader = new RobotLoader;
$loader->setTempDirectory(TEMP_DIR);

Assert::noError(
function () use ($loader) {
$loader->addDirectory(...[]);
}
);

Assert::noError(
function () use ($loader) {
$loader->excludeDirectory(...[]);
}
);