Update website
This commit is contained in:
parent
4413528994
commit
1d90fbf296
6865 changed files with 1091082 additions and 0 deletions
85
vendor/doctrine/dbal/src/SQL/Builder/CreateSchemaObjectsSQLBuilder.php
vendored
Normal file
85
vendor/doctrine/dbal/src/SQL/Builder/CreateSchemaObjectsSQLBuilder.php
vendored
Normal file
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\DBAL\SQL\Builder;
|
||||
|
||||
use Doctrine\DBAL\Exception;
|
||||
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\DBAL\Schema\Sequence;
|
||||
use Doctrine\DBAL\Schema\Table;
|
||||
|
||||
use function array_merge;
|
||||
|
||||
final class CreateSchemaObjectsSQLBuilder
|
||||
{
|
||||
private AbstractPlatform $platform;
|
||||
|
||||
public function __construct(AbstractPlatform $platform)
|
||||
{
|
||||
$this->platform = $platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<string>
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function buildSQL(Schema $schema): array
|
||||
{
|
||||
return array_merge(
|
||||
$this->buildNamespaceStatements($schema->getNamespaces()),
|
||||
$this->buildSequenceStatements($schema->getSequences()),
|
||||
$this->buildTableStatements($schema->getTables()),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<string> $namespaces
|
||||
*
|
||||
* @return list<string>
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private function buildNamespaceStatements(array $namespaces): array
|
||||
{
|
||||
$statements = [];
|
||||
|
||||
if ($this->platform->supportsSchemas()) {
|
||||
foreach ($namespaces as $namespace) {
|
||||
$statements[] = $this->platform->getCreateSchemaSQL($namespace);
|
||||
}
|
||||
}
|
||||
|
||||
return $statements;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<Table> $tables
|
||||
*
|
||||
* @return list<string>
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private function buildTableStatements(array $tables): array
|
||||
{
|
||||
return $this->platform->getCreateTablesSQL($tables);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<Sequence> $sequences
|
||||
*
|
||||
* @return list<string>
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private function buildSequenceStatements(array $sequences): array
|
||||
{
|
||||
$statements = [];
|
||||
|
||||
foreach ($sequences as $sequence) {
|
||||
$statements[] = $this->platform->getCreateSequenceSQL($sequence);
|
||||
}
|
||||
|
||||
return $statements;
|
||||
}
|
||||
}
|
95
vendor/doctrine/dbal/src/SQL/Builder/DefaultSelectSQLBuilder.php
vendored
Normal file
95
vendor/doctrine/dbal/src/SQL/Builder/DefaultSelectSQLBuilder.php
vendored
Normal file
|
@ -0,0 +1,95 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\DBAL\SQL\Builder;
|
||||
|
||||
use Doctrine\DBAL\Exception;
|
||||
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||
use Doctrine\DBAL\Query\ForUpdate\ConflictResolutionMode;
|
||||
use Doctrine\DBAL\Query\SelectQuery;
|
||||
|
||||
use function count;
|
||||
use function implode;
|
||||
|
||||
final class DefaultSelectSQLBuilder implements SelectSQLBuilder
|
||||
{
|
||||
private AbstractPlatform $platform;
|
||||
private ?string $forUpdateSQL;
|
||||
private ?string $skipLockedSQL;
|
||||
|
||||
/** @internal The SQL builder should be instantiated only by database platforms. */
|
||||
public function __construct(AbstractPlatform $platform, ?string $forUpdateSQL, ?string $skipLockedSQL)
|
||||
{
|
||||
$this->platform = $platform;
|
||||
$this->forUpdateSQL = $forUpdateSQL;
|
||||
$this->skipLockedSQL = $skipLockedSQL;
|
||||
}
|
||||
|
||||
/** @throws Exception */
|
||||
public function buildSQL(SelectQuery $query): string
|
||||
{
|
||||
$parts = ['SELECT'];
|
||||
|
||||
if ($query->isDistinct()) {
|
||||
$parts[] = 'DISTINCT';
|
||||
}
|
||||
|
||||
$parts[] = implode(', ', $query->getColumns());
|
||||
|
||||
$from = $query->getFrom();
|
||||
|
||||
if (count($from) > 0) {
|
||||
$parts[] = 'FROM ' . implode(', ', $from);
|
||||
}
|
||||
|
||||
$where = $query->getWhere();
|
||||
|
||||
if ($where !== null) {
|
||||
$parts[] = 'WHERE ' . $where;
|
||||
}
|
||||
|
||||
$groupBy = $query->getGroupBy();
|
||||
|
||||
if (count($groupBy) > 0) {
|
||||
$parts[] = 'GROUP BY ' . implode(', ', $groupBy);
|
||||
}
|
||||
|
||||
$having = $query->getHaving();
|
||||
|
||||
if ($having !== null) {
|
||||
$parts[] = 'HAVING ' . $having;
|
||||
}
|
||||
|
||||
$orderBy = $query->getOrderBy();
|
||||
|
||||
if (count($orderBy) > 0) {
|
||||
$parts[] = 'ORDER BY ' . implode(', ', $orderBy);
|
||||
}
|
||||
|
||||
$sql = implode(' ', $parts);
|
||||
$limit = $query->getLimit();
|
||||
|
||||
if ($limit->isDefined()) {
|
||||
$sql = $this->platform->modifyLimitQuery($sql, $limit->getMaxResults(), $limit->getFirstResult());
|
||||
}
|
||||
|
||||
$forUpdate = $query->getForUpdate();
|
||||
|
||||
if ($forUpdate !== null) {
|
||||
if ($this->forUpdateSQL === null) {
|
||||
throw Exception::notSupported('FOR UPDATE');
|
||||
}
|
||||
|
||||
$sql .= ' ' . $this->forUpdateSQL;
|
||||
|
||||
if ($forUpdate->getConflictResolutionMode() === ConflictResolutionMode::SKIP_LOCKED) {
|
||||
if ($this->skipLockedSQL === null) {
|
||||
throw Exception::notSupported('SKIP LOCKED');
|
||||
}
|
||||
|
||||
$sql .= ' ' . $this->skipLockedSQL;
|
||||
}
|
||||
}
|
||||
|
||||
return $sql;
|
||||
}
|
||||
}
|
62
vendor/doctrine/dbal/src/SQL/Builder/DropSchemaObjectsSQLBuilder.php
vendored
Normal file
62
vendor/doctrine/dbal/src/SQL/Builder/DropSchemaObjectsSQLBuilder.php
vendored
Normal file
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\DBAL\SQL\Builder;
|
||||
|
||||
use Doctrine\DBAL\Exception;
|
||||
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\DBAL\Schema\Sequence;
|
||||
use Doctrine\DBAL\Schema\Table;
|
||||
|
||||
use function array_merge;
|
||||
|
||||
final class DropSchemaObjectsSQLBuilder
|
||||
{
|
||||
private AbstractPlatform $platform;
|
||||
|
||||
public function __construct(AbstractPlatform $platform)
|
||||
{
|
||||
$this->platform = $platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<string>
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function buildSQL(Schema $schema): array
|
||||
{
|
||||
return array_merge(
|
||||
$this->buildSequenceStatements($schema->getSequences()),
|
||||
$this->buildTableStatements($schema->getTables()),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<Table> $tables
|
||||
*
|
||||
* @return list<string>
|
||||
*/
|
||||
private function buildTableStatements(array $tables): array
|
||||
{
|
||||
return $this->platform->getDropTablesSQL($tables);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<Sequence> $sequences
|
||||
*
|
||||
* @return list<string>
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private function buildSequenceStatements(array $sequences): array
|
||||
{
|
||||
$statements = [];
|
||||
|
||||
foreach ($sequences as $sequence) {
|
||||
$statements[] = $this->platform->getDropSequenceSQL($sequence);
|
||||
}
|
||||
|
||||
return $statements;
|
||||
}
|
||||
}
|
12
vendor/doctrine/dbal/src/SQL/Builder/SelectSQLBuilder.php
vendored
Normal file
12
vendor/doctrine/dbal/src/SQL/Builder/SelectSQLBuilder.php
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\DBAL\SQL\Builder;
|
||||
|
||||
use Doctrine\DBAL\Exception;
|
||||
use Doctrine\DBAL\Query\SelectQuery;
|
||||
|
||||
interface SelectSQLBuilder
|
||||
{
|
||||
/** @throws Exception */
|
||||
public function buildSQL(SelectQuery $query): string;
|
||||
}
|
127
vendor/doctrine/dbal/src/SQL/Parser.php
vendored
Normal file
127
vendor/doctrine/dbal/src/SQL/Parser.php
vendored
Normal file
|
@ -0,0 +1,127 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\DBAL\SQL;
|
||||
|
||||
use Doctrine\DBAL\SQL\Parser\Exception;
|
||||
use Doctrine\DBAL\SQL\Parser\Exception\RegularExpressionError;
|
||||
use Doctrine\DBAL\SQL\Parser\Visitor;
|
||||
|
||||
use function array_merge;
|
||||
use function assert;
|
||||
use function current;
|
||||
use function implode;
|
||||
use function key;
|
||||
use function next;
|
||||
use function preg_last_error;
|
||||
use function preg_match;
|
||||
use function reset;
|
||||
use function sprintf;
|
||||
use function strlen;
|
||||
|
||||
use const PREG_NO_ERROR;
|
||||
|
||||
/**
|
||||
* The SQL parser that focuses on identifying prepared statement parameters. It implements parsing other tokens like
|
||||
* string literals and comments only as a way to not confuse their contents with the the parameter placeholders.
|
||||
*
|
||||
* The parsing logic and the implementation is inspired by the PHP PDO parser.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @see https://github.com/php/php-src/blob/php-7.4.12/ext/pdo/pdo_sql_parser.re#L49-L69
|
||||
*/
|
||||
final class Parser
|
||||
{
|
||||
private const SPECIAL_CHARS = ':\?\'"`\\[\\-\\/';
|
||||
|
||||
private const BACKTICK_IDENTIFIER = '`[^`]*`';
|
||||
private const BRACKET_IDENTIFIER = '(?<!\b(?i:ARRAY))\[(?:[^\]])*\]';
|
||||
private const MULTICHAR = ':{2,}';
|
||||
private const NAMED_PARAMETER = ':[a-zA-Z0-9_]+';
|
||||
private const POSITIONAL_PARAMETER = '(?<!\\?)\\?(?!\\?)';
|
||||
private const ONE_LINE_COMMENT = '--[^\r\n]*';
|
||||
private const MULTI_LINE_COMMENT = '/\*([^*]+|\*+[^/*])*\**\*/';
|
||||
private const SPECIAL = '[' . self::SPECIAL_CHARS . ']';
|
||||
private const OTHER = '[^' . self::SPECIAL_CHARS . ']+';
|
||||
|
||||
private string $sqlPattern;
|
||||
|
||||
public function __construct(bool $mySQLStringEscaping)
|
||||
{
|
||||
if ($mySQLStringEscaping) {
|
||||
$patterns = [
|
||||
$this->getMySQLStringLiteralPattern("'"),
|
||||
$this->getMySQLStringLiteralPattern('"'),
|
||||
];
|
||||
} else {
|
||||
$patterns = [
|
||||
$this->getAnsiSQLStringLiteralPattern("'"),
|
||||
$this->getAnsiSQLStringLiteralPattern('"'),
|
||||
];
|
||||
}
|
||||
|
||||
$patterns = array_merge($patterns, [
|
||||
self::BACKTICK_IDENTIFIER,
|
||||
self::BRACKET_IDENTIFIER,
|
||||
self::MULTICHAR,
|
||||
self::ONE_LINE_COMMENT,
|
||||
self::MULTI_LINE_COMMENT,
|
||||
self::OTHER,
|
||||
]);
|
||||
|
||||
$this->sqlPattern = sprintf('(%s)', implode('|', $patterns));
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the given SQL statement
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function parse(string $sql, Visitor $visitor): void
|
||||
{
|
||||
/** @var array<string,callable> $patterns */
|
||||
$patterns = [
|
||||
self::NAMED_PARAMETER => static function (string $sql) use ($visitor): void {
|
||||
$visitor->acceptNamedParameter($sql);
|
||||
},
|
||||
self::POSITIONAL_PARAMETER => static function (string $sql) use ($visitor): void {
|
||||
$visitor->acceptPositionalParameter($sql);
|
||||
},
|
||||
$this->sqlPattern => static function (string $sql) use ($visitor): void {
|
||||
$visitor->acceptOther($sql);
|
||||
},
|
||||
self::SPECIAL => static function (string $sql) use ($visitor): void {
|
||||
$visitor->acceptOther($sql);
|
||||
},
|
||||
];
|
||||
|
||||
$offset = 0;
|
||||
|
||||
while (($handler = current($patterns)) !== false) {
|
||||
if (preg_match('~\G' . key($patterns) . '~s', $sql, $matches, 0, $offset) === 1) {
|
||||
$handler($matches[0]);
|
||||
reset($patterns);
|
||||
|
||||
$offset += strlen($matches[0]);
|
||||
} elseif (preg_last_error() !== PREG_NO_ERROR) {
|
||||
// @codeCoverageIgnoreStart
|
||||
throw RegularExpressionError::new();
|
||||
// @codeCoverageIgnoreEnd
|
||||
} else {
|
||||
next($patterns);
|
||||
}
|
||||
}
|
||||
|
||||
assert($offset === strlen($sql));
|
||||
}
|
||||
|
||||
private function getMySQLStringLiteralPattern(string $delimiter): string
|
||||
{
|
||||
return $delimiter . '((\\\\.)|(?![' . $delimiter . '\\\\]).)*' . $delimiter;
|
||||
}
|
||||
|
||||
private function getAnsiSQLStringLiteralPattern(string $delimiter): string
|
||||
{
|
||||
return $delimiter . '[^' . $delimiter . ']*' . $delimiter;
|
||||
}
|
||||
}
|
11
vendor/doctrine/dbal/src/SQL/Parser/Exception.php
vendored
Normal file
11
vendor/doctrine/dbal/src/SQL/Parser/Exception.php
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\SQL\Parser;
|
||||
|
||||
use Throwable;
|
||||
|
||||
interface Exception extends Throwable
|
||||
{
|
||||
}
|
19
vendor/doctrine/dbal/src/SQL/Parser/Exception/RegularExpressionError.php
vendored
Normal file
19
vendor/doctrine/dbal/src/SQL/Parser/Exception/RegularExpressionError.php
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\SQL\Parser\Exception;
|
||||
|
||||
use Doctrine\DBAL\SQL\Parser\Exception;
|
||||
use RuntimeException;
|
||||
|
||||
use function preg_last_error;
|
||||
use function preg_last_error_msg;
|
||||
|
||||
class RegularExpressionError extends RuntimeException implements Exception
|
||||
{
|
||||
public static function new(): self
|
||||
{
|
||||
return new self(preg_last_error_msg(), preg_last_error());
|
||||
}
|
||||
}
|
26
vendor/doctrine/dbal/src/SQL/Parser/Visitor.php
vendored
Normal file
26
vendor/doctrine/dbal/src/SQL/Parser/Visitor.php
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\DBAL\SQL\Parser;
|
||||
|
||||
/**
|
||||
* SQL parser visitor
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
interface Visitor
|
||||
{
|
||||
/**
|
||||
* Accepts an SQL fragment containing a positional parameter
|
||||
*/
|
||||
public function acceptPositionalParameter(string $sql): void;
|
||||
|
||||
/**
|
||||
* Accepts an SQL fragment containing a named parameter
|
||||
*/
|
||||
public function acceptNamedParameter(string $sql): void;
|
||||
|
||||
/**
|
||||
* Accepts other SQL fragments
|
||||
*/
|
||||
public function acceptOther(string $sql): void;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue