new files
This commit is contained in:
57
pro_v3.5.1/vendor/doctrine/lexer/tests/ConcreteLexer.php
vendored
Normal file
57
pro_v3.5.1/vendor/doctrine/lexer/tests/ConcreteLexer.php
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Tests\Common\Lexer;
|
||||
|
||||
use Doctrine\Common\Lexer\AbstractLexer;
|
||||
|
||||
use function in_array;
|
||||
use function is_numeric;
|
||||
|
||||
/** @extends AbstractLexer<string, string|int> */
|
||||
class ConcreteLexer extends AbstractLexer
|
||||
{
|
||||
public const INT = 'int';
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function getCatchablePatterns(): array
|
||||
{
|
||||
return [
|
||||
'=|<|>',
|
||||
'[a-z]+',
|
||||
'\d+',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function getNonCatchablePatterns(): array
|
||||
{
|
||||
return [
|
||||
'\s+',
|
||||
'(.)',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function getType(&$value): string
|
||||
{
|
||||
if (is_numeric($value)) {
|
||||
$value = (int) $value;
|
||||
|
||||
return 'int';
|
||||
}
|
||||
|
||||
if (in_array($value, ['=', '<', '>'])) {
|
||||
return 'operator';
|
||||
}
|
||||
|
||||
return 'string';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user