| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Yiisoft\Composer\Config\Reader; |
||
| 6 | |||
| 7 | use Dotenv\Dotenv; |
||
|
0 ignored issues
–
show
|
|||
| 8 | use Yiisoft\Composer\Config\Exception\UnsupportedFileTypeException; |
||
| 9 | |||
| 10 | /** |
||
| 11 | * EnvReader - reads `.env` files. |
||
| 12 | */ |
||
| 13 | class EnvReader extends AbstractReader |
||
| 14 | { |
||
| 15 | protected function readRaw(string $path) |
||
| 16 | { |
||
| 17 | if (!class_exists(Dotenv::class)) { |
||
| 18 | throw new UnsupportedFileTypeException('for .env support require `vlucas/phpdotenv` in your composer.json'); |
||
| 19 | } |
||
| 20 | $info = pathinfo($path); |
||
| 21 | $this->loadEnvs($info['dirname'], $info['basename']); |
||
| 22 | |||
| 23 | return $_ENV; |
||
| 24 | } |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Creates and loads Dotenv object. |
||
| 28 | * Supports all 2, 3 and 4 version of `phpdotenv` |
||
| 29 | * |
||
| 30 | * @param mixed $dir |
||
| 31 | * @param mixed $file |
||
| 32 | */ |
||
| 33 | private function loadEnvs(string $dir, string $file): void |
||
| 34 | { |
||
| 35 | /** @psalm-suppress UndefinedClass */ |
||
| 36 | if (method_exists(Dotenv::class, 'createMutable')) { |
||
| 37 | Dotenv::createMutable($dir, $file)->load(); |
||
| 38 | } elseif (method_exists(Dotenv::class, 'create')) { |
||
| 39 | Dotenv::create($dir, $file)->overload(); |
||
| 40 | } else { |
||
| 41 | (new Dotenv($dir, $file))->overload(); |
||
| 42 | } |
||
| 43 | } |
||
| 44 | } |
||
| 45 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths