Skip to content

Commit 67f9743

Browse files
committed
Reject empty path
1 parent d3ac7c1 commit 67f9743

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

src/Console/ConfigurationResolver.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,10 @@ public function getPath()
380380
} else {
381381
$this->path = array_map(
382382
static function ($path) use ($cwd, $filesystem) {
383+
if ('' === $path) {
384+
throw new InvalidConfigurationException('Invalid path: "".');
385+
}
386+
383387
$absolutePath = $filesystem->isAbsolutePath($path)
384388
? $path
385389
: $cwd.\DIRECTORY_SEPARATOR.$path;

tests/Console/ConfigurationResolverTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,30 @@ public function testResolvePathRelativeB()
344344
static::assertSame([__DIR__], $resolver->getPath());
345345
}
346346

347+
/**
348+
* @dataProvider provideEmptyPathCases
349+
*/
350+
public function testRejectInvalidPath(array $paths)
351+
{
352+
$resolver = $this->createConfigurationResolver(
353+
['path' => $paths],
354+
null,
355+
\dirname(__DIR__)
356+
);
357+
358+
$this->expectException(InvalidConfigurationException::class);
359+
$this->expectExceptionMessage('Invalid path: "".');
360+
361+
$resolver->getPath();
362+
}
363+
364+
public function provideEmptyPathCases()
365+
{
366+
yield [['']];
367+
yield [[__DIR__, '']];
368+
yield [['', __DIR__]];
369+
}
370+
347371
public function testResolvePathWithFileThatIsExcludedDirectlyOverridePathMode()
348372
{
349373
$config = new Config();

0 commit comments

Comments
 (0)