File tree 3 files changed +17
-6
lines changed
3 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,6 @@ class Env
13
13
private $ data = array ();
14
14
private $ set = array ();
15
15
private $ drop = array ();
16
- //private $readOnly = false;
17
16
18
17
public function __construct (?string $ file = null )
19
18
{
@@ -22,7 +21,6 @@ public function __construct(?string $file = null)
22
21
}
23
22
}
24
23
25
-
26
24
public function loadEnvFile (string $ file ): void
27
25
{
28
26
$ this ->fileData = parse_ini_file ($ file );
@@ -122,10 +120,12 @@ public function putenvArray(array $array): self
122
120
private function put (array $ data , bool $ overwrite = false )
123
121
{
124
122
foreach ($ data as $ key => $ value ) {
123
+ /*
125
124
if (!$overwrite && getenv($key) !== false) {
126
125
throw new InvalidArgumentException("The Environmental variable \"{$key}\" already exists. " .
127
126
"It's recommended to make every variable unique.", 1);
128
127
}
128
+ */
129
129
$ _ENV [$ key ] = $ value ;
130
130
if (is_array ($ value )) {
131
131
$ value = json_encode ($ value );
Original file line number Diff line number Diff line change @@ -120,7 +120,6 @@ public function getAuthority(): string
120
120
$ this ->authority .= ": {$ port }" ;
121
121
}
122
122
}
123
-
124
123
return $ this ->authority ;
125
124
}
126
125
@@ -139,7 +138,7 @@ public function getUserInfo(): string
139
138
$ this ->encoded ['pass ' ] = $ pass ;
140
139
}
141
140
142
- if (! is_null ($ user )) {
141
+ if (is_string ( $ user ) && ! empty ($ user )) {
143
142
$ this ->userInfo .= "{$ user }" ;
144
143
if (!is_null ($ pass )) {
145
144
$ this ->userInfo .= ": {$ pass }" ;
@@ -156,8 +155,13 @@ public function getUserInfo(): string
156
155
public function getHost (): string
157
156
{
158
157
if ($ val = $ this ->getUniquePart ("host " )) {
158
+ if (($ pos = strpos ($ val , ": " )) !== false ) {
159
+ $ val = substr ($ val , 0 , $ pos );
160
+ }
159
161
$ this ->encoded ['host ' ] = Format \Str::value ($ val )->tolower ()->get ();
160
162
}
163
+
164
+
161
165
return (string )$ this ->encoded ['host ' ];
162
166
}
163
167
@@ -196,6 +200,7 @@ public function getPath(): string
196
200
{
197
201
if ($ val = $ this ->getUniquePart ("path " )) {
198
202
$ this ->encoded ['path ' ] = Format \Str::value ($ val )->toggleUrlencode (['%2F ' ], ['/ ' ])->get ();
203
+ if ($ this ->encoded ['path ' ]) $ this ->encoded ['path ' ] = "/ " .ltrim ($ this ->encoded ['path ' ], "/ " );
199
204
}
200
205
return (string )$ this ->encoded ['path ' ];
201
206
}
Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ public function withType(null|string|array $type = null): self
59
59
$ type = [];
60
60
}
61
61
62
+
62
63
$ inst = clone $ this ;
63
64
$ parts = $ vars = array ();
64
65
foreach ($ inst ->parts as $ sel => $ row ) {
@@ -256,8 +257,13 @@ public function getRootDir(string $path = "", bool $endSlash = false): string
256
257
if ($ scheme = $ this ->getScheme ()) {
257
258
$ url .= "{$ scheme }: " ;
258
259
}
259
- if ($ authority = $ this ->getHost ()) {
260
- $ url .= "// {$ authority }" ;
260
+ if ($ host = $ this ->getHost ()) {
261
+ $ url .= "// {$ host }" ;
262
+ }
263
+
264
+ // Do not show standard ports becouse they are not needed.
265
+ if (($ port = $ this ->getPort ()) && $ port !== 80 && $ port !== 443 ) {
266
+ $ url .= ": {$ port }" ;
261
267
}
262
268
263
269
if ($ dir = $ this ->getDirPath ()) {
You can’t perform that action at this time.
0 commit comments