Skip to content

Commit

Permalink
bug #22343 [Dotenv] Throwing an exception when loading a directory (s…
Browse files Browse the repository at this point in the history
…anpii)

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
-------

8b83b58 Throwing an exception when loading a directory
  • Loading branch information
fabpot committed Apr 10, 2017
2 parents eeb36eb + 8b83b58 commit f7debe8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Symfony/Component/Dotenv/Dotenv.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function load(/*...$paths*/)
{
// 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);
}

Expand Down
9 changes: 9 additions & 0 deletions src/Symfony/Component/Dotenv/Tests/DotenvTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,13 @@ public function getEnvData()

return $tests;
}

/**
* @expectedException \Symfony\Component\Dotenv\Exception\PathException
*/
public function testLoadDirectory()
{
$dotenv = new Dotenv();
$dotenv->load(__DIR__);
}
}

0 comments on commit f7debe8

Please sign in to comment.