bug #22343 [Dotenv] Throwing an exception when loading a directory (sanpii)
This PR was merged into the 3.3-dev branch.
Discussion
----------
[Dotenv] Throwing an exception when loading a directory
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | n/a
| License | MIT
| Doc PR | n/a
Commits
-------
8b83b58aa5
Throwing an exception when loading a directory
This commit is contained in:
commit
f7debe8a30
@ -48,7 +48,7 @@ final class Dotenv
|
||||
{
|
||||
// func_get_args() to be replaced by a variadic argument for Symfony 4.0
|
||||
foreach (func_get_args() as $path) {
|
||||
if (!is_readable($path)) {
|
||||
if (!is_readable($path) || is_dir($path)) {
|
||||
throw new PathException($path);
|
||||
}
|
||||
|
||||
|
@ -145,4 +145,13 @@ class DotenvTest extends TestCase
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Dotenv\Exception\PathException
|
||||
*/
|
||||
public function testLoadDirectory()
|
||||
{
|
||||
$dotenv = new Dotenv();
|
||||
$dotenv->load(__DIR__);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user