File tree Expand file tree Collapse file tree 2 files changed +26
-3
lines changed
src/Symfony/Component/Dotenv Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -45,10 +45,11 @@ final class Dotenv
4545 * @throws FormatException when a file has a syntax error
4646 * @throws PathException when a file does not exist or is not readable
4747 */
48- public function load ($ path/* , ...$paths*/ )
48+ public function load ($ path , ...$ paths )
4949 {
50- // func_get_args() to be replaced by a variadic argument for Symfony 4.0
51- foreach (func_get_args () as $ path ) {
50+ array_unshift ($ paths , $ path );
51+
52+ foreach ($ paths as $ path ) {
5253 if (!is_readable ($ path ) || is_dir ($ path )) {
5354 throw new PathException ($ path );
5455 }
Original file line number Diff line number Diff line change @@ -155,6 +155,28 @@ public function testLoadDirectory()
155155 $ dotenv ->load (__DIR__ );
156156 }
157157
158+ public function testLoad ()
159+ {
160+ @mkdir ($ tmpdir = sys_get_temp_dir ().'/dotenv ' );
161+
162+ $ path1 = tempnam ($ tmpdir , 'sf- ' );
163+ $ path2 = tempnam ($ tmpdir , 'sf- ' );
164+
165+ file_put_contents ($ path1 , 'FOO=BAR ' );
166+ file_put_contents ($ path2 , 'BAR=BAZ ' );
167+
168+ (new DotEnv ())->load ($ path1 , $ path2 );
169+
170+ $ this ->assertSame ('BAR ' , getenv ('FOO ' ));
171+ $ this ->assertSame ('BAZ ' , getenv ('BAR ' ));
172+
173+ putenv ('FOO ' );
174+ putenv ('BAR ' );
175+ unlink ($ path1 );
176+ unlink ($ path2 );
177+ rmdir ($ tmpdir );
178+ }
179+
158180 public function testServerSuperglobalIsNotOverriden ()
159181 {
160182 $ originalValue = $ _SERVER ['argc ' ];
You can’t perform that action at this time.
0 commit comments