Skip to content
Permalink
Browse files

RobotLoader: Fixed the empty variadic array in addDirectory() [Closes #…

  • Loading branch information...
josefsabl authored and dg committed Sep 5, 2019
1 parent 9ae6fc2 commit 97b4f44acc843e0ac523202288e104206c9b4c28
Showing with 30 additions and 2 deletions.
  1. +2 −2 src/RobotLoader/RobotLoader.php
  2. +28 −0 tests/Loaders/RobotLoader.emptyArrayVariadicArgument.phpt
@@ -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];
}
@@ -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];
}
@@ -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(...[]);
}
);

0 comments on commit 97b4f44

Please sign in to comment.
You can’t perform that action at this time.