Skip to content

Commit 5c8934c

Browse files
Graceful preg error handling when parsing names
1 parent 10d3f85 commit 5c8934c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Parser.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Dotenv;
44

55
use Dotenv\Exception\InvalidFileException;
6+
use Dotenv\Regex\Regex;
67

78
class Parser
89
{
@@ -87,7 +88,7 @@ private static function parseName($name)
8788
*/
8889
private static function isValidName($name)
8990
{
90-
return preg_match('~\A[a-zA-Z0-9_.]+\z~', $name) === 1;
91+
return Regex::match('~\A[a-zA-Z0-9_.]+\z~', $name)->success()->getOrElse(0) === 1;
9192
}
9293

9394
/**

0 commit comments

Comments
 (0)