upgrade to laravel 8.x

This commit is contained in:
2021-05-30 08:20:41 +00:00
parent 41b78a0599
commit 3ad6ed8bfa
2333 changed files with 113904 additions and 59058 deletions
@@ -1,11 +1,40 @@
<?php
declare(strict_types=1);
namespace Dotenv\Repository\Adapter;
use PhpOption\None;
use PhpOption\Option;
use PhpOption\Some;
class ApacheAdapter implements AvailabilityInterface, ReaderInterface, WriterInterface
final class ApacheAdapter implements AdapterInterface
{
/**
* Create a new apache adapter instance.
*
* @return void
*/
private function __construct()
{
//
}
/**
* Create a new instance of the adapter, if it is available.
*
* @return \PhpOption\Option<\Dotenv\Repository\Adapter\AdapterInterface>
*/
public static function create()
{
if (self::isSupported()) {
/** @var \PhpOption\Option<AdapterInterface> */
return Some::create(new self());
}
return None::create();
}
/**
* Determines if the adapter is supported.
*
@@ -13,52 +42,48 @@ class ApacheAdapter implements AvailabilityInterface, ReaderInterface, WriterInt
*
* @return bool
*/
public function isSupported()
private static function isSupported()
{
return function_exists('apache_getenv') && function_exists('apache_setenv');
return \function_exists('apache_getenv') && \function_exists('apache_setenv');
}
/**
* Get an environment variable, if it exists.
*
* This is intentionally not implemented, since this adapter exists only as
* a means to overwrite existing apache environment variables.
* Read an environment variable, if it exists.
*
* @param string $name
*
* @return \PhpOption\Option<string|null>
* @return \PhpOption\Option<string>
*/
public function get($name)
public function read(string $name)
{
return None::create();
/** @var \PhpOption\Option<string> */
return Option::fromValue(apache_getenv($name))->filter(static function ($value) {
return \is_string($value) && $value !== '';
});
}
/**
* Set an environment variable.
* Write to an environment variable, if possible.
*
* Only if an existing apache variable exists do we overwrite it.
* @param string $name
* @param string $value
*
* @param string $name
* @param string|null $value
*
* @return void
* @return bool
*/
public function set($name, $value = null)
public function write(string $name, string $value)
{
if (apache_getenv($name) !== false) {
apache_setenv($name, (string) $value);
}
return apache_setenv($name, $value);
}
/**
* Clear an environment variable.
* Delete an environment variable, if possible.
*
* @param string $name
*
* @return void
* @return bool
*/
public function clear($name)
public function delete(string $name)
{
// Nothing to do here.
return apache_setenv($name, '');
}
}