composer update
This commit is contained in:
+2
-1
@@ -3,6 +3,7 @@
|
||||
namespace Dotenv;
|
||||
|
||||
use Dotenv\Exception\InvalidFileException;
|
||||
use Dotenv\Regex\Regex;
|
||||
|
||||
class Parser
|
||||
{
|
||||
@@ -87,7 +88,7 @@ class Parser
|
||||
*/
|
||||
private static function isValidName($name)
|
||||
{
|
||||
return preg_match('~\A[a-zA-Z0-9_.]+\z~', $name) === 1;
|
||||
return Regex::match('~\A[a-zA-Z0-9_.]+\z~', $name)->success()->getOrElse(0) === 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+18
-17
@@ -2,8 +2,6 @@
|
||||
|
||||
namespace Dotenv\Regex;
|
||||
|
||||
use PhpOption\Option;
|
||||
|
||||
class Regex
|
||||
{
|
||||
/**
|
||||
@@ -81,20 +79,23 @@ class Regex
|
||||
*/
|
||||
private static function lookupError($code)
|
||||
{
|
||||
return Option::fromValue(get_defined_constants(true))
|
||||
->filter(function (array $consts) {
|
||||
return isset($consts['pcre']) && defined('ARRAY_FILTER_USE_KEY');
|
||||
})
|
||||
->map(function (array $consts) {
|
||||
return array_filter($consts['pcre'], function ($msg) {
|
||||
return substr($msg, -6) === '_ERROR';
|
||||
}, ARRAY_FILTER_USE_KEY);
|
||||
})
|
||||
->flatMap(function (array $errors) use ($code) {
|
||||
return Option::fromValue(
|
||||
array_search($code, $errors, true)
|
||||
);
|
||||
})
|
||||
->getOrElse('PREG_ERROR');
|
||||
if (defined('PREG_JIT_STACKLIMIT_ERROR') && $code === PREG_JIT_STACKLIMIT_ERROR) {
|
||||
return 'JIT stack limit exhausted';
|
||||
}
|
||||
|
||||
switch ($code) {
|
||||
case PREG_INTERNAL_ERROR:
|
||||
return 'Internal error';
|
||||
case PREG_BAD_UTF8_ERROR:
|
||||
return 'Malformed UTF-8 characters, possibly incorrectly encoded';
|
||||
case PREG_BAD_UTF8_OFFSET_ERROR:
|
||||
return 'The offset did not correspond to the beginning of a valid UTF-8 code point';
|
||||
case PREG_BACKTRACK_LIMIT_ERROR:
|
||||
return 'Backtrack limit exhausted';
|
||||
case PREG_RECURSION_LIMIT_ERROR:
|
||||
return 'Recursion limit exhausted';
|
||||
default:
|
||||
return 'Unknown error';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user