|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Lenevor Framework |
|
5
|
|
|
* |
|
6
|
|
|
* LICENSE |
|
7
|
|
|
* |
|
8
|
|
|
* This source file is subject to the new BSD license that is bundled |
|
9
|
|
|
* with this package in the file license.md. |
|
10
|
|
|
* It is also available through the world-wide-web at this URL: |
|
11
|
|
|
* https://lenevor.com/license |
|
12
|
|
|
* If you did not receive a copy of the license and are unable to |
|
13
|
|
|
* obtain it through the world-wide-web, please send an email |
|
14
|
|
|
* to [email protected] so we can send you a copy immediately. |
|
15
|
|
|
* |
|
16
|
|
|
* @package Lenevor |
|
17
|
|
|
* @subpackage Base |
|
18
|
|
|
* @link https://lenevor.com |
|
19
|
|
|
* @copyright Copyright (c) 2019 - 2021 Alexander Campo <[email protected]> |
|
20
|
|
|
* @license https://opensource.org/licenses/BSD-3-Clause New BSD license or see https://lenevor.com/license or see /license.md |
|
21
|
|
|
*/ |
|
22
|
|
|
|
|
23
|
|
|
namespace Syscodes\Dotenv; |
|
24
|
|
|
|
|
25
|
|
|
use InvalidArgumentException; |
|
26
|
|
|
use Syscodes\Dotenv\Loader\Loader; |
|
27
|
|
|
use Syscodes\Dotenv\Store\StoreBuilder; |
|
28
|
|
|
use Syscodes\Dotenv\Repository\RepositoryCreator; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Manages .env files. |
|
32
|
|
|
* |
|
33
|
|
|
* @author Alexander Campo <[email protected]> |
|
34
|
|
|
*/ |
|
35
|
|
|
final class Dotenv |
|
36
|
|
|
{ |
|
37
|
|
|
/** |
|
38
|
|
|
* The Loader instance. |
|
39
|
|
|
* |
|
40
|
|
|
* @var \Syscodes\Dotenv\Loader\Loader $loader |
|
41
|
|
|
*/ |
|
42
|
|
|
protected $loader; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* The Repository creator instance. |
|
46
|
|
|
* |
|
47
|
|
|
* @var \Syscodes\Dotenv\Repository\RepositoryCreator $repository |
|
48
|
|
|
*/ |
|
49
|
|
|
protected $repository; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* The file store instance. |
|
53
|
|
|
* |
|
54
|
|
|
* @var \Syscodes\Dotenv\Repository\FileStore $store |
|
|
|
|
|
|
55
|
|
|
*/ |
|
56
|
|
|
protected $store; |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* Activate use of putenv, by default is true. |
|
60
|
|
|
* |
|
61
|
|
|
* @var bool $usePutenv |
|
62
|
|
|
*/ |
|
63
|
|
|
protected $usePutenv = true; |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Constructor. Create a new Dotenv instance. |
|
67
|
|
|
* |
|
68
|
|
|
* @param \Syscodes\Dotenv\Store\StoreBuilder $store |
|
69
|
|
|
* @param \Syscodes\Dotenv\Loader\Loader $loader |
|
70
|
|
|
* @param \Syscodes\Dotenv\Repository\RepositoryCreator $repository |
|
71
|
|
|
* |
|
72
|
|
|
* @return void |
|
73
|
|
|
*/ |
|
74
|
|
|
public function __construct($store, Loader $loader, $repository) |
|
75
|
|
|
{ |
|
76
|
|
|
$this->store = $store; |
|
|
|
|
|
|
77
|
|
|
$this->loader = $loader; |
|
78
|
|
|
$this->repository = $repository; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* Create a new Dotenv instance. |
|
83
|
|
|
* Builds the path to our file. |
|
84
|
|
|
* |
|
85
|
|
|
* @param \Syscodes\Dotenv\Repository\RepositoryCreator $repository |
|
86
|
|
|
* @param string|string[] $path |
|
87
|
|
|
* @param string|string[] $names |
|
88
|
|
|
* @param bool $modeEnabled (true by default) |
|
89
|
|
|
* |
|
90
|
|
|
* @return \Syscodes\Dotenv\Dotenv |
|
91
|
|
|
*/ |
|
92
|
|
|
public static function create($repository, $paths, $names = null, bool $modeEnabled = true) |
|
93
|
|
|
{ |
|
94
|
|
|
$store = $names === null ? StoreBuilder::createWithDefaultName() : StoreBuilder::createWithNoNames(); |
|
95
|
|
|
|
|
96
|
|
|
foreach ((array) $paths as $path) { |
|
97
|
|
|
$store = $store->addPath($path); |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
foreach ((array) $names as $name) { |
|
101
|
|
|
$store = $store->addName($name); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
if ($modeEnabled) { |
|
105
|
|
|
$store = $store->modeEnabled(); |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
return new self($store->make(), new Loader($repository), $repository); |
|
|
|
|
|
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* Will load the .env file and process it. So that we end all settings in the PHP |
|
113
|
|
|
* environment vars: getenv(), $_ENV, and $_SERVER. |
|
114
|
|
|
* |
|
115
|
|
|
* @return bool |
|
116
|
|
|
*/ |
|
117
|
|
|
public function load() |
|
118
|
|
|
{ |
|
119
|
|
|
return $this->loader->load($this->store->read()); |
|
120
|
|
|
} |
|
121
|
|
|
} |
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