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:
Fabien Potencier 2017-04-10 10:15:08 -07:00
commit f7debe8a30
2 changed files with 10 additions and 1 deletions

View File

@ -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);
}

View File

@ -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__);
}
}