validation-bugsnag-email

This commit is contained in:
RafficMohammed
2023-01-31 13:17:59 +05:30
parent 2ec836b447
commit 9dd3f53910
769 changed files with 20242 additions and 14060 deletions

View File

@@ -7,7 +7,6 @@ namespace Doctrine\Common\Lexer;
use ReflectionClass;
use UnitEnum;
use function get_class;
use function implode;
use function preg_split;
use function sprintf;
@@ -27,31 +26,25 @@ abstract class AbstractLexer
{
/**
* Lexer original input string.
*
* @var string
*/
private $input;
private string $input;
/**
* Array of scanned tokens.
*
* @var list<Token<T, V>>
*/
private $tokens = [];
private array $tokens = [];
/**
* Current lexer position in input string.
*
* @var int
*/
private $position = 0;
private int $position = 0;
/**
* Current peek of current lexer position.
*
* @var int
*/
private $peek = 0;
private int $peek = 0;
/**
* The next token in the input.
@@ -59,7 +52,7 @@ abstract class AbstractLexer
* @var mixed[]|null
* @psalm-var Token<T, V>|null
*/
public $lookahead;
public Token|null $lookahead;
/**
* The last matched/seen token.
@@ -67,14 +60,12 @@ abstract class AbstractLexer
* @var mixed[]|null
* @psalm-var Token<T, V>|null
*/
public $token;
public Token|null $token;
/**
* Composed regex for input parsing.
*
* @var string|null
*/
private $regex;
private string|null $regex = null;
/**
* Sets the input data to be tokenized.
@@ -86,7 +77,7 @@ abstract class AbstractLexer
*
* @return void
*/
public function setInput($input)
public function setInput(string $input)
{
$this->input = $input;
$this->tokens = [];
@@ -125,7 +116,7 @@ abstract class AbstractLexer
*
* @return void
*/
public function resetPosition($position = 0)
public function resetPosition(int $position = 0)
{
$this->position = $position;
}
@@ -133,11 +124,9 @@ abstract class AbstractLexer
/**
* Retrieve the original lexer's input until a given position.
*
* @param int $position
*
* @return string
*/
public function getInputUntilPosition($position)
public function getInputUntilPosition(int $position)
{
return substr($this->input, 0, $position);
}
@@ -151,7 +140,7 @@ abstract class AbstractLexer
*
* @psalm-assert-if-true !=null $this->lookahead
*/
public function isNextToken($type)
public function isNextToken(int|string|UnitEnum $type)
{
return $this->lookahead !== null && $this->lookahead->isA($type);
}
@@ -194,7 +183,7 @@ abstract class AbstractLexer
*
* @return void
*/
public function skipUntil($type)
public function skipUntil(int|string|UnitEnum $type)
{
while ($this->lookahead !== null && ! $this->lookahead->isA($type)) {
$this->moveNext();
@@ -204,12 +193,9 @@ abstract class AbstractLexer
/**
* Checks if given value is identical to the given token.
*
* @param string $value
* @param int|string $token
*
* @return bool
*/
public function isA($value, $token)
public function isA(string $value, int|string|UnitEnum $token)
{
return $this->getType($value) === $token;
}
@@ -250,14 +236,14 @@ abstract class AbstractLexer
*
* @return void
*/
protected function scan($input)
protected function scan(string $input)
{
if (! isset($this->regex)) {
$this->regex = sprintf(
'/(%s)|%s/%s',
implode(')|(', $this->getCatchablePatterns()),
implode('|', $this->getNonCatchablePatterns()),
$this->getModifiers()
$this->getModifiers(),
);
}
@@ -277,7 +263,7 @@ abstract class AbstractLexer
$this->tokens[] = new Token(
$firstMatch,
$type,
$match[1]
$match[1],
);
}
}
@@ -289,10 +275,10 @@ abstract class AbstractLexer
*
* @return int|string
*/
public function getLiteral($token)
public function getLiteral(int|string|UnitEnum $token)
{
if ($token instanceof UnitEnum) {
return get_class($token) . '::' . $token->name;
return $token::class . '::' . $token->name;
}
$className = static::class;
@@ -336,11 +322,9 @@ abstract class AbstractLexer
/**
* Retrieve token type. Also processes the token value if necessary.
*
* @param string $value
*
* @return T|null
*
* @param-out V $value
*/
abstract protected function getType(&$value);
abstract protected function getType(string &$value);
}