mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-12-06 19:19:29 +00: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) . ')';
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue