Skip to content

Commit

Permalink
Merge branch '4.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamCampbell committed Oct 15, 2022
2 parents dd46c26 + 3b56df1 commit 4c16545
Show file tree
Hide file tree
Showing 21 changed files with 119 additions and 54 deletions.
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
"preferred-install": "dist"
},
"extra": {
"bamarni-bin": {
"bin-links": true,
"forward-command": true
},
"branch-alias": {
"dev-master": "5.4-dev"
}
Expand Down
1 change: 1 addition & 0 deletions src/Parser/EntryParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ private static function parseValue(string $value)
});
});
}, Success::create([Value::blank(), self::INITIAL_STATE]))->flatMap(static function (array $result) {
/** @psalm-suppress DocblockTypeContradiction */
if (in_array($result[1], self::REJECT_STATES, true)) {
return Error::create('a missing closing quote');
}
Expand Down
8 changes: 4 additions & 4 deletions src/Repository/Adapter/ApacheAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private static function isSupported()
/**
* Read an environment variable, if it exists.
*
* @param string $name
* @param non-empty-string $name
*
* @return \PhpOption\Option<string>
*/
Expand All @@ -65,8 +65,8 @@ public function read(string $name)
/**
* Write to an environment variable, if possible.
*
* @param string $name
* @param string $value
* @param non-empty-string $name
* @param string $value
*
* @return bool
*/
Expand All @@ -78,7 +78,7 @@ public function write(string $name, string $value)
/**
* Delete an environment variable, if possible.
*
* @param string $name
* @param non-empty-string $name
*
* @return bool
*/
Expand Down
8 changes: 4 additions & 4 deletions src/Repository/Adapter/ArrayAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static function create()
/**
* Read an environment variable, if it exists.
*
* @param string $name
* @param non-empty-string $name
*
* @return \PhpOption\Option<string>
*/
Expand All @@ -52,8 +52,8 @@ public function read(string $name)
/**
* Write to an environment variable, if possible.
*
* @param string $name
* @param string $value
* @param non-empty-string $name
* @param string $value
*
* @return bool
*/
Expand All @@ -67,7 +67,7 @@ public function write(string $name, string $value)
/**
* Delete an environment variable, if possible.
*
* @param string $name
* @param non-empty-string $name
*
* @return bool
*/
Expand Down
15 changes: 8 additions & 7 deletions src/Repository/Adapter/EnvConstAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,17 @@ public static function create()
/**
* Read an environment variable, if it exists.
*
* @param string $name
* @param non-empty-string $name
*
* @return \PhpOption\Option<string>
*/
public function read(string $name)
{
/** @var \PhpOption\Option<string> */
return Option::fromArraysValue($_ENV, $name)
->filter(static function ($value) {
return \is_scalar($value);
})
->map(static function ($value) {
if ($value === false) {
return 'false';
Expand All @@ -50,17 +53,15 @@ public function read(string $name)
return 'true';
}

return $value;
})->filter(static function ($value) {
return \is_string($value);
return (string) $value;
});
}

/**
* Write to an environment variable, if possible.
*
* @param string $name
* @param string $value
* @param non-empty-string $name
* @param string $value
*
* @return bool
*/
Expand All @@ -74,7 +75,7 @@ public function write(string $name, string $value)
/**
* Delete an environment variable, if possible.
*
* @param string $name
* @param non-empty-string $name
*
* @return bool
*/
Expand Down
8 changes: 4 additions & 4 deletions src/Repository/Adapter/GuardedWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public function __construct(WriterInterface $writer, array $allowList)
/**
* Write to an environment variable, if possible.
*
* @param string $name
* @param string $value
* @param non-empty-string $name
* @param string $value
*
* @return bool
*/
Expand All @@ -56,7 +56,7 @@ public function write(string $name, string $value)
/**
* Delete an environment variable, if possible.
*
* @param string $name
* @param non-empty-string $name
*
* @return bool
*/
Expand All @@ -74,7 +74,7 @@ public function delete(string $name)
/**
* Determine if the given variable is allowed.
*
* @param string $name
* @param non-empty-string $name
*
* @return bool
*/
Expand Down
8 changes: 4 additions & 4 deletions src/Repository/Adapter/ImmutableWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public function __construct(WriterInterface $writer, ReaderInterface $reader)
/**
* Write to an environment variable, if possible.
*
* @param string $name
* @param string $value
* @param non-empty-string $name
* @param string $value
*
* @return bool
*/
Expand All @@ -72,7 +72,7 @@ public function write(string $name, string $value)
/**
* Delete an environment variable, if possible.
*
* @param string $name
* @param non-empty-string $name
*
* @return bool
*/
Expand All @@ -99,7 +99,7 @@ public function delete(string $name)
*
* That is, is it an "existing" variable.
*
* @param string $name
* @param non-empty-string $name
*
* @return bool
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Repository/Adapter/MultiReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct(array $readers)
/**
* Read an environment variable, if it exists.
*
* @param string $name
* @param non-empty-string $name
*
* @return \PhpOption\Option<string>
*/
Expand Down
6 changes: 3 additions & 3 deletions src/Repository/Adapter/MultiWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public function __construct(array $writers)
/**
* Write to an environment variable, if possible.
*
* @param string $name
* @param string $value
* @param non-empty-string $name
* @param string $value
*
* @return bool
*/
Expand All @@ -47,7 +47,7 @@ public function write(string $name, string $value)
/**
* Delete an environment variable, if possible.
*
* @param string $name
* @param non-empty-string $name
*
* @return bool
*/
Expand Down
8 changes: 4 additions & 4 deletions src/Repository/Adapter/PutenvAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private static function isSupported()
/**
* Read an environment variable, if it exists.
*
* @param string $name
* @param non-empty-string $name
*
* @return \PhpOption\Option<string>
*/
Expand All @@ -63,8 +63,8 @@ public function read(string $name)
/**
* Write to an environment variable, if possible.
*
* @param string $name
* @param string $value
* @param non-empty-string $name
* @param string $value
*
* @return bool
*/
Expand All @@ -78,7 +78,7 @@ public function write(string $name, string $value)
/**
* Delete an environment variable, if possible.
*
* @param string $name
* @param non-empty-string $name
*
* @return bool
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Repository/Adapter/ReaderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface ReaderInterface
/**
* Read an environment variable, if it exists.
*
* @param string $name
* @param non-empty-string $name
*
* @return \PhpOption\Option<string>
*/
Expand Down
8 changes: 4 additions & 4 deletions src/Repository/Adapter/ReplacingWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public function __construct(WriterInterface $writer, ReaderInterface $reader)
/**
* Write to an environment variable, if possible.
*
* @param string $name
* @param string $value
* @param non-empty-string $name
* @param string $value
*
* @return bool
*/
Expand All @@ -63,7 +63,7 @@ public function write(string $name, string $value)
/**
* Delete an environment variable, if possible.
*
* @param string $name
* @param non-empty-string $name
*
* @return bool
*/
Expand All @@ -83,7 +83,7 @@ public function delete(string $name)
* Returns true if it currently exists, or existed at any point in the past
* that we are aware of.
*
* @param string $name
* @param non-empty-string $name
*
* @return bool
*/
Expand Down
15 changes: 8 additions & 7 deletions src/Repository/Adapter/ServerConstAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,17 @@ public static function create()
/**
* Read an environment variable, if it exists.
*
* @param string $name
* @param non-empty-string $name
*
* @return \PhpOption\Option<string>
*/
public function read(string $name)
{
/** @var \PhpOption\Option<string> */
return Option::fromArraysValue($_SERVER, $name)
->filter(static function ($value) {
return \is_scalar($value);
})
->map(static function ($value) {
if ($value === false) {
return 'false';
Expand All @@ -50,17 +53,15 @@ public function read(string $name)
return 'true';
}

return $value;
})->filter(static function ($value) {
return \is_string($value);
return (string) $value;
});
}

/**
* Write to an environment variable, if possible.
*
* @param string $name
* @param string $value
* @param non-empty-string $name
* @param string $value
*
* @return bool
*/
Expand All @@ -74,7 +75,7 @@ public function write(string $name, string $value)
/**
* Delete an environment variable, if possible.
*
* @param string $name
* @param non-empty-string $name
*
* @return bool
*/
Expand Down
6 changes: 3 additions & 3 deletions src/Repository/Adapter/WriterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ interface WriterInterface
/**
* Write to an environment variable, if possible.
*
* @param string $name
* @param string $value
* @param non-empty-string $name
* @param string $value
*
* @return bool
*/
Expand All @@ -19,7 +19,7 @@ public function write(string $name, string $value);
/**
* Delete an environment variable, if possible.
*
* @param string $name
* @param non-empty-string $name
*
* @return bool
*/
Expand Down
Loading

0 comments on commit 4c16545

Please sign in to comment.