Skip to content

Commit

Permalink
Revert PHP 5.3 break (#426)
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamCampbell authored Mar 27, 2020
1 parent db354ca commit c4a653e
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public static function parseValue($value)
if ($value === '') {
return '';
} elseif ($value[0] === '"' || $value[0] === '\'') {
return self::parseQuotedValue($value);
return Parser::parseQuotedValue($value);
} else {
return self::parseUnquotedValue($value);
return Parser::parseUnquotedValue($value);
}
}

Expand All @@ -57,42 +57,42 @@ public static function parseQuotedValue($value)
{
$data = array_reduce(str_split($value), function ($data, $char) use ($value) {
switch ($data[1]) {
case self::INITIAL_STATE:
case Parser::INITIAL_STATE:
if ($char === '"' || $char === '\'') {
return array($data[0], self::QUOTED_STATE);
return array($data[0], Parser::QUOTED_STATE);
} else {
throw new InvalidFileException(
'Expected the value to start with a quote.'
);
}
case self::QUOTED_STATE:
case Parser::QUOTED_STATE:
if ($char === $value[0]) {
return array($data[0], self::WHITESPACE_STATE);
return array($data[0], Parser::WHITESPACE_STATE);
} elseif ($char === '\\') {
return array($data[0], self::ESCAPE_STATE);
return array($data[0], Parser::ESCAPE_STATE);
} else {
return array($data[0].$char, self::QUOTED_STATE);
return array($data[0].$char, Parser::QUOTED_STATE);
}
case self::ESCAPE_STATE:
case Parser::ESCAPE_STATE:
if ($char === $value[0] || $char === '\\') {
return array($data[0].$char, self::QUOTED_STATE);
return array($data[0].$char, Parser::QUOTED_STATE);
} else {
return array($data[0].'\\'.$char, self::QUOTED_STATE);
return array($data[0].'\\'.$char, Parser::QUOTED_STATE);
}
case self::WHITESPACE_STATE:
case Parser::WHITESPACE_STATE:
if ($char === '#') {
return array($data[0], self::COMMENT_STATE);
return array($data[0], Parser::COMMENT_STATE);
} elseif (!ctype_space($char)) {
throw new InvalidFileException(
'Dotenv values containing spaces must be surrounded by quotes.'
);
} else {
return array($data[0], self::WHITESPACE_STATE);
return array($data[0], Parser::WHITESPACE_STATE);
}
case self::COMMENT_STATE:
return array($data[0], self::COMMENT_STATE);
case Parser::COMMENT_STATE:
return array($data[0], Parser::COMMENT_STATE);
}
}, array('', self::INITIAL_STATE));
}, array('', Parser::INITIAL_STATE));

return trim($data[0]);
}
Expand Down

0 comments on commit c4a653e

Please sign in to comment.