mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-13 20:04:34 +02:00
Applied rector suggestions
This commit is contained in:
parent
4106bcef5f
commit
20f32c7f12
170 changed files with 808 additions and 761 deletions
|
@ -23,6 +23,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Doctrine\Functions;
|
||||
|
||||
use Doctrine\ORM\Query\Parser;
|
||||
use Doctrine\ORM\Query\SqlWalker;
|
||||
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
|
||||
use Doctrine\ORM\Query\TokenType;
|
||||
|
||||
|
@ -36,7 +38,7 @@ class Field2 extends FunctionNode
|
|||
|
||||
private $values = [];
|
||||
|
||||
public function parse(\Doctrine\ORM\Query\Parser $parser): void
|
||||
public function parse(Parser $parser): void
|
||||
{
|
||||
$parser->match(TokenType::T_IDENTIFIER);
|
||||
$parser->match(TokenType::T_OPEN_PARENTHESIS);
|
||||
|
@ -58,15 +60,16 @@ class Field2 extends FunctionNode
|
|||
$parser->match(TokenType::T_CLOSE_PARENTHESIS);
|
||||
}
|
||||
|
||||
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker): string
|
||||
public function getSql(SqlWalker $sqlWalker): string
|
||||
{
|
||||
$query = 'FIELD2(';
|
||||
|
||||
$query .= $this->field->dispatch($sqlWalker);
|
||||
|
||||
$query .= ', ';
|
||||
$counter = count($this->values);
|
||||
|
||||
for ($i = 0; $i < count($this->values); $i++) {
|
||||
for ($i = 0; $i < $counter; $i++) {
|
||||
if ($i > 0) {
|
||||
$query .= ', ';
|
||||
}
|
||||
|
@ -74,8 +77,6 @@ class Field2 extends FunctionNode
|
|||
$query .= $this->values[$i]->dispatch($sqlWalker);
|
||||
}
|
||||
|
||||
$query .= ')';
|
||||
|
||||
return $query;
|
||||
return $query . ')';
|
||||
}
|
||||
}
|
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Doctrine\Functions;
|
||||
|
||||
use Doctrine\DBAL\Exception;
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Doctrine\DBAL\Driver\AbstractPostgreSQLDriver;
|
||||
use Doctrine\DBAL\Platforms\AbstractMySQLPlatform;
|
||||
|
@ -59,9 +60,9 @@ class Natsort extends FunctionNode
|
|||
* The result is cached in memory.
|
||||
* @param Connection $connection
|
||||
* @return bool
|
||||
* @throws \Doctrine\DBAL\Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
private static function mariaDBSupportsNaturalSort(Connection $connection): bool
|
||||
private function mariaDBSupportsNaturalSort(Connection $connection): bool
|
||||
{
|
||||
if (self::$supportsNaturalSort !== null) {
|
||||
return self::$supportsNaturalSort;
|
||||
|
@ -95,7 +96,7 @@ class Natsort extends FunctionNode
|
|||
return $this->field->dispatch($sqlWalker) . ' COLLATE numeric';
|
||||
}
|
||||
|
||||
if ($platform instanceof MariaDBPlatform && self::mariaDBSupportsNaturalSort($sqlWalker->getConnection())) {
|
||||
if ($platform instanceof MariaDBPlatform && $this->mariaDBSupportsNaturalSort($sqlWalker->getConnection())) {
|
||||
return 'NATURAL_SORT_KEY(' . $this->field->dispatch($sqlWalker) . ')';
|
||||
}
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ final class FieldHelper
|
|||
//If we are on MySQL, we can just use the FIELD function
|
||||
if ($db_platform instanceof AbstractMySQLPlatform) {
|
||||
$qb->orderBy("FIELD2($field_expr, :field_arr)", $order);
|
||||
} else if ($db_platform instanceof PostgreSQLPlatform) {
|
||||
} elseif ($db_platform instanceof PostgreSQLPlatform) {
|
||||
//Use the postgres native array_position function
|
||||
self::addPostgresOrderBy($qb, $field_expr, $key, $values, $order);
|
||||
} else {
|
||||
|
|
|
@ -98,10 +98,9 @@ class SQLiteRegexExtensionMiddlewareDriver extends AbstractDriverMiddleware
|
|||
* This function returns the index (position) of the first argument in the subsequent arguments.
|
||||
* If the first argument is not found or is NULL, 0 is returned.
|
||||
* @param string|int|null $value
|
||||
* @param mixed ...$array
|
||||
* @return int
|
||||
*/
|
||||
final public static function field(string|int|null $value, ...$array): int
|
||||
final public static function field(string|int|null $value, mixed ...$array): int
|
||||
{
|
||||
if ($value === null) {
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue