mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -12,7 +12,6 @@ declare(strict_types=1);
|
||||
namespace Chill\MainBundle\Doctrine\DQL;
|
||||
|
||||
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
|
||||
use Doctrine\ORM\Query\AST\PathExpression;
|
||||
use Doctrine\ORM\Query\Lexer;
|
||||
use Doctrine\ORM\Query\Parser;
|
||||
use Doctrine\ORM\Query\SqlWalker;
|
||||
|
@@ -30,9 +30,9 @@ class Extract extends FunctionNode
|
||||
private string $field;
|
||||
|
||||
private null|\Doctrine\ORM\Query\AST\Node|string $value = null;
|
||||
//private PathExpression $value;
|
||||
//private FunctionNode $value;
|
||||
//private DateDiffFunction $value;
|
||||
// private PathExpression $value;
|
||||
// private FunctionNode $value;
|
||||
// private DateDiffFunction $value;
|
||||
|
||||
public function getSql(SqlWalker $sqlWalker)
|
||||
{
|
||||
@@ -53,7 +53,7 @@ class Extract extends FunctionNode
|
||||
|
||||
$parser->match(Lexer::T_FROM);
|
||||
|
||||
//$this->value = $parser->ScalarExpression();
|
||||
// $this->value = $parser->ScalarExpression();
|
||||
$this->value = $parser->ArithmeticPrimary();
|
||||
|
||||
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
|
||||
|
@@ -33,7 +33,7 @@ class Greatest extends FunctionNode
|
||||
|
||||
public function getSql(SqlWalker $sqlWalker)
|
||||
{
|
||||
return 'GREATEST(' . implode(', ', array_map(static fn (Node $expr) => $expr->dispatch($sqlWalker), $this->exprs)) . ')';
|
||||
return 'GREATEST('.implode(', ', array_map(static fn (Node $expr) => $expr->dispatch($sqlWalker), $this->exprs)).')';
|
||||
}
|
||||
|
||||
public function parse(Parser $parser)
|
||||
|
@@ -32,7 +32,7 @@ class JsonBuildObject extends FunctionNode
|
||||
|
||||
public function getSql(SqlWalker $sqlWalker)
|
||||
{
|
||||
return 'JSONB_BUILD_OBJECT(' . implode(', ', array_map(static fn (Node $expr) => $expr->dispatch($sqlWalker), $this->exprs)) . ')';
|
||||
return 'JSONB_BUILD_OBJECT('.implode(', ', array_map(static fn (Node $expr) => $expr->dispatch($sqlWalker), $this->exprs)).')';
|
||||
}
|
||||
|
||||
public function parse(Parser $parser)
|
||||
|
@@ -33,7 +33,7 @@ class Least extends FunctionNode
|
||||
|
||||
public function getSql(SqlWalker $sqlWalker)
|
||||
{
|
||||
return 'LEAST(' . implode(', ', array_map(static fn (Node $expr) => $expr->dispatch($sqlWalker), $this->exprs)) . ')';
|
||||
return 'LEAST('.implode(', ', array_map(static fn (Node $expr) => $expr->dispatch($sqlWalker), $this->exprs)).')';
|
||||
}
|
||||
|
||||
public function parse(Parser $parser)
|
||||
|
@@ -15,7 +15,6 @@ use Doctrine\ORM\Query\AST\Functions\FunctionNode;
|
||||
use Doctrine\ORM\Query\AST\PathExpression;
|
||||
use Doctrine\ORM\Query\Lexer;
|
||||
use Doctrine\ORM\Query\Parser;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* DQL function for OVERLAPS function in postgresql.
|
||||
@@ -76,7 +75,7 @@ class OverlapsI extends FunctionNode
|
||||
$p = match ($position) {
|
||||
'start' => '-infinity',
|
||||
'end' => 'infinity',
|
||||
default => throw new Exception('Unexpected position value.'),
|
||||
default => throw new \Exception('Unexpected position value.'),
|
||||
};
|
||||
|
||||
if ($part instanceof PathExpression) {
|
||||
|
@@ -24,12 +24,12 @@ class Replace extends FunctionNode
|
||||
|
||||
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker): string
|
||||
{
|
||||
return 'REPLACE(' .
|
||||
$this->string->dispatch($sqlWalker) .
|
||||
', ' .
|
||||
$this->from->dispatch($sqlWalker) .
|
||||
', ' .
|
||||
$this->to->dispatch($sqlWalker) .
|
||||
return 'REPLACE('.
|
||||
$this->string->dispatch($sqlWalker).
|
||||
', '.
|
||||
$this->from->dispatch($sqlWalker).
|
||||
', '.
|
||||
$this->to->dispatch($sqlWalker).
|
||||
')';
|
||||
}
|
||||
|
||||
|
@@ -25,8 +25,8 @@ class STContains extends FunctionNode
|
||||
|
||||
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
|
||||
{
|
||||
return 'ST_CONTAINS(' . $this->firstPart->dispatch($sqlWalker) .
|
||||
', ' . $this->secondPart->dispatch($sqlWalker) . ')';
|
||||
return 'ST_CONTAINS('.$this->firstPart->dispatch($sqlWalker).
|
||||
', '.$this->secondPart->dispatch($sqlWalker).')';
|
||||
}
|
||||
|
||||
public function parse(\Doctrine\ORM\Query\Parser $parser)
|
||||
|
@@ -22,8 +22,8 @@ class Similarity extends FunctionNode
|
||||
|
||||
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
|
||||
{
|
||||
return 'SIMILARITY(' . $this->firstPart->dispatch($sqlWalker) .
|
||||
', ' . $this->secondPart->dispatch($sqlWalker) . ')';
|
||||
return 'SIMILARITY('.$this->firstPart->dispatch($sqlWalker).
|
||||
', '.$this->secondPart->dispatch($sqlWalker).')';
|
||||
}
|
||||
|
||||
public function parse(\Doctrine\ORM\Query\Parser $parser)
|
||||
|
@@ -23,8 +23,8 @@ class StrictWordSimilarityOPS extends \Doctrine\ORM\Query\AST\Functions\Function
|
||||
|
||||
public function getSql(SqlWalker $sqlWalker)
|
||||
{
|
||||
return $this->firstPart->dispatch($sqlWalker) .
|
||||
' <<% ' . $this->secondPart->dispatch($sqlWalker);
|
||||
return $this->firstPart->dispatch($sqlWalker).
|
||||
' <<% '.$this->secondPart->dispatch($sqlWalker);
|
||||
}
|
||||
|
||||
public function parse(Parser $parser)
|
||||
|
@@ -26,7 +26,7 @@ class Unaccent extends FunctionNode
|
||||
|
||||
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
|
||||
{
|
||||
return 'UNACCENT(' . $this->string->dispatch($sqlWalker) . ')';
|
||||
return 'UNACCENT('.$this->string->dispatch($sqlWalker).')';
|
||||
}
|
||||
|
||||
public function parse(\Doctrine\ORM\Query\Parser $parser)
|
||||
|
@@ -14,7 +14,6 @@ namespace Chill\MainBundle\Doctrine\Event;
|
||||
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
||||
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\Common\EventSubscriber;
|
||||
use Doctrine\ORM\Events;
|
||||
use Doctrine\Persistence\Event\LifecycleEventArgs;
|
||||
@@ -37,7 +36,7 @@ class TrackCreateUpdateSubscriber implements EventSubscriber
|
||||
$object = $args->getObject();
|
||||
|
||||
if ($object instanceof TrackCreationInterface) {
|
||||
$object->setCreatedAt(new DateTimeImmutable('now'));
|
||||
$object->setCreatedAt(new \DateTimeImmutable('now'));
|
||||
|
||||
if ($this->security->getUser() instanceof User) {
|
||||
$object->setCreatedBy($this->security->getUser());
|
||||
@@ -57,7 +56,7 @@ class TrackCreateUpdateSubscriber implements EventSubscriber
|
||||
protected function onUpdate(object $object): void
|
||||
{
|
||||
if ($object instanceof TrackUpdateInterface) {
|
||||
$object->setUpdatedAt(new DateTimeImmutable('now'));
|
||||
$object->setUpdatedAt(new \DateTimeImmutable('now'));
|
||||
|
||||
if ($this->security->getUser() instanceof User) {
|
||||
$object->setUpdatedBy($this->security->getUser());
|
||||
|
@@ -14,9 +14,6 @@ namespace Chill\MainBundle\Doctrine\Migrations;
|
||||
use Doctrine\Migrations\Version\Comparator;
|
||||
use Doctrine\Migrations\Version\Version;
|
||||
|
||||
use function explode;
|
||||
use function strcmp;
|
||||
|
||||
/**
|
||||
* Compare Version classes names from different namespaces and order them.
|
||||
*
|
||||
@@ -26,12 +23,12 @@ final class VersionComparator implements Comparator
|
||||
{
|
||||
public function compare(Version $a, Version $b): int
|
||||
{
|
||||
return strcmp($this->getNumber($a), $this->getNumber($b));
|
||||
return \strcmp($this->getNumber($a), $this->getNumber($b));
|
||||
}
|
||||
|
||||
private function getNumber(Version $version): string
|
||||
{
|
||||
$names = explode('\\', (string) $version);
|
||||
$names = \explode('\\', (string) $version);
|
||||
|
||||
return end($names);
|
||||
}
|
||||
|
@@ -11,12 +11,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\Doctrine\Model;
|
||||
|
||||
use Exception;
|
||||
use JsonSerializable;
|
||||
|
||||
use function json_encode;
|
||||
|
||||
class Point implements JsonSerializable
|
||||
class Point implements \JsonSerializable
|
||||
{
|
||||
public static string $SRID = '4326';
|
||||
|
||||
@@ -28,7 +23,7 @@ class Point implements JsonSerializable
|
||||
return self::fromLonLat($array['coordinates'][0], $array['coordinates'][1]);
|
||||
}
|
||||
|
||||
throw new Exception('Unable to build a point from input data.');
|
||||
throw new \Exception('Unable to build a point from input data.');
|
||||
}
|
||||
|
||||
public static function fromGeoJson(string $geojson): self
|
||||
@@ -88,7 +83,7 @@ class Point implements JsonSerializable
|
||||
{
|
||||
$array = $this->toArrayGeoJson();
|
||||
|
||||
return json_encode($array, JSON_THROW_ON_ERROR);
|
||||
return \json_encode($array, JSON_THROW_ON_ERROR);
|
||||
}
|
||||
|
||||
public function toWKT(): string
|
||||
|
@@ -11,12 +11,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\Doctrine\Model;
|
||||
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Description of PointException.
|
||||
*/
|
||||
class PointException extends Exception
|
||||
class PointException extends \Exception
|
||||
{
|
||||
public static function badCoordinates($lon, $lat): self
|
||||
{
|
||||
|
@@ -12,11 +12,10 @@ declare(strict_types=1);
|
||||
namespace Chill\MainBundle\Doctrine\Model;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use DateTimeInterface;
|
||||
|
||||
interface TrackCreationInterface
|
||||
{
|
||||
public function setCreatedAt(DateTimeInterface $datetime): self;
|
||||
public function setCreatedAt(\DateTimeInterface $datetime): self;
|
||||
|
||||
public function setCreatedBy(User $user): self;
|
||||
}
|
||||
|
@@ -13,8 +13,6 @@ namespace Chill\MainBundle\Doctrine\Model;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use DateTime;
|
||||
use DateTimeImmutable;
|
||||
use DateTimeInterface;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
|
||||
@@ -22,18 +20,21 @@ trait TrackCreationTrait
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(type="datetime_immutable", nullable=true, options={"default": NULL})
|
||||
*
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private ?DateTimeImmutable $createdAt = null;
|
||||
private ?\DateTimeImmutable $createdAt = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=User::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
*
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private ?User $createdBy = null;
|
||||
|
||||
public function getCreatedAt(): ?DateTimeInterface
|
||||
public function getCreatedAt(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
@@ -43,9 +44,9 @@ trait TrackCreationTrait
|
||||
return $this->createdBy;
|
||||
}
|
||||
|
||||
public function setCreatedAt(DateTimeInterface $datetime): self
|
||||
public function setCreatedAt(\DateTimeInterface $datetime): self
|
||||
{
|
||||
$this->createdAt = $datetime instanceof DateTime ? DateTimeImmutable::createFromMutable($datetime) : $datetime;
|
||||
$this->createdAt = $datetime instanceof \DateTime ? \DateTimeImmutable::createFromMutable($datetime) : $datetime;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@@ -12,11 +12,10 @@ declare(strict_types=1);
|
||||
namespace Chill\MainBundle\Doctrine\Model;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use DateTimeInterface;
|
||||
|
||||
interface TrackUpdateInterface
|
||||
{
|
||||
public function setUpdatedAt(DateTimeInterface $datetime): self;
|
||||
public function setUpdatedAt(\DateTimeInterface $datetime): self;
|
||||
|
||||
public function setUpdatedBy(User $user): self;
|
||||
}
|
||||
|
@@ -13,8 +13,6 @@ namespace Chill\MainBundle\Doctrine\Model;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use DateTime;
|
||||
use DateTimeImmutable;
|
||||
use DateTimeInterface;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
|
||||
@@ -22,18 +20,21 @@ trait TrackUpdateTrait
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(type="datetime_immutable", nullable=true, options={"default": NULL})
|
||||
*
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private ?DateTimeImmutable $updatedAt = null;
|
||||
private ?\DateTimeImmutable $updatedAt = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=User::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
*
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private ?User $updatedBy = null;
|
||||
|
||||
public function getUpdatedAt(): ?DateTimeInterface
|
||||
public function getUpdatedAt(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->updatedAt;
|
||||
}
|
||||
@@ -43,9 +44,9 @@ trait TrackUpdateTrait
|
||||
return $this->updatedBy;
|
||||
}
|
||||
|
||||
public function setUpdatedAt(DateTimeInterface $datetime): self
|
||||
public function setUpdatedAt(\DateTimeInterface $datetime): self
|
||||
{
|
||||
$this->updatedAt = $datetime instanceof DateTime ? DateTimeImmutable::createFromMutable($datetime) : $datetime;
|
||||
$this->updatedAt = $datetime instanceof \DateTime ? \DateTimeImmutable::createFromMutable($datetime) : $datetime;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@@ -12,7 +12,6 @@ declare(strict_types=1);
|
||||
namespace Chill\MainBundle\Doctrine\ORM\Hydration;
|
||||
|
||||
use Doctrine\ORM\Internal\Hydration\ObjectHydrator;
|
||||
use Generator;
|
||||
|
||||
final class FlatHierarchyEntityHydrator extends ObjectHydrator
|
||||
{
|
||||
@@ -40,7 +39,7 @@ final class FlatHierarchyEntityHydrator extends ObjectHydrator
|
||||
);
|
||||
}
|
||||
|
||||
private function flatListGenerator(array $hashMap, ?object $parent = null): Generator
|
||||
private function flatListGenerator(array $hashMap, object $parent = null): \Generator
|
||||
{
|
||||
$parent = null === $parent ? null : spl_object_id($parent);
|
||||
$hashMap += [$parent => []];
|
||||
|
@@ -11,17 +11,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\Doctrine\Type;
|
||||
|
||||
use DateInterval;
|
||||
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||
use Doctrine\DBAL\Types\ConversionException;
|
||||
use Doctrine\DBAL\Types\DateIntervalType;
|
||||
use Exception;
|
||||
|
||||
use LogicException;
|
||||
use function count;
|
||||
use function current;
|
||||
use function preg_match;
|
||||
use function reset;
|
||||
|
||||
/**
|
||||
* Re-declare the date interval to use the implementation of date interval in
|
||||
@@ -37,7 +29,7 @@ class NativeDateIntervalType extends DateIntervalType
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($value instanceof DateInterval) {
|
||||
if ($value instanceof \DateInterval) {
|
||||
return $value->format(self::FORMAT);
|
||||
}
|
||||
|
||||
@@ -46,25 +38,25 @@ class NativeDateIntervalType extends DateIntervalType
|
||||
|
||||
public function convertToPHPValue($value, AbstractPlatform $platform)
|
||||
{
|
||||
if (null === $value || $value instanceof DateInterval) {
|
||||
if (null === $value || $value instanceof \DateInterval) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
try {
|
||||
$strings = explode(' ', (string) $value);
|
||||
|
||||
if (count($strings) === 0) {
|
||||
if (1 === count($strings) && ('' === $strings[0])) {
|
||||
return null;
|
||||
}
|
||||
$intervalSpec = 'P';
|
||||
reset($strings);
|
||||
\reset($strings);
|
||||
|
||||
do {
|
||||
$intervalSpec .= $this->convertEntry($strings);
|
||||
} while (next($strings) !== false);
|
||||
} while (false !== next($strings));
|
||||
|
||||
return new DateInterval($intervalSpec);
|
||||
} catch (Exception $exception) {
|
||||
return new \DateInterval($intervalSpec);
|
||||
} catch (\Exception $exception) {
|
||||
throw $this->createConversionException($value, $exception);
|
||||
}
|
||||
}
|
||||
@@ -86,7 +78,7 @@ class NativeDateIntervalType extends DateIntervalType
|
||||
|
||||
private function convertEntry(&$strings)
|
||||
{
|
||||
$current = current($strings);
|
||||
$current = \current($strings);
|
||||
|
||||
if (is_numeric($current)) {
|
||||
$next = next($strings);
|
||||
@@ -98,19 +90,19 @@ class NativeDateIntervalType extends DateIntervalType
|
||||
default => throw $this->createConversionException(implode('', $strings)),
|
||||
};
|
||||
|
||||
return $current . $unit;
|
||||
return $current.$unit;
|
||||
}
|
||||
|
||||
if (preg_match('/([0-9]{2}\:[0-9]{2}:[0-9]{2})/', (string) $current) === 1) {
|
||||
if (1 === \preg_match('/([0-9]{2}\:[0-9]{2}:[0-9]{2})/', (string) $current)) {
|
||||
$tExploded = explode(':', (string) $current);
|
||||
$intervalSpec = 'T';
|
||||
$intervalSpec .= $tExploded[0] . 'H';
|
||||
$intervalSpec .= $tExploded[1] . 'M';
|
||||
$intervalSpec .= $tExploded[2] . 'S';
|
||||
$intervalSpec .= $tExploded[0].'H';
|
||||
$intervalSpec .= $tExploded[1].'M';
|
||||
$intervalSpec .= $tExploded[2].'S';
|
||||
|
||||
return $intervalSpec;
|
||||
}
|
||||
|
||||
throw new LogicException();
|
||||
throw new \LogicException();
|
||||
}
|
||||
}
|
||||
|
@@ -42,10 +42,7 @@ class PointType extends Type
|
||||
return $sqlExpr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function convertToPHPValue($value, AbstractPlatform $platform): ?\Chill\MainBundle\Doctrine\Model\Point
|
||||
public function convertToPHPValue($value, AbstractPlatform $platform): ?Point
|
||||
{
|
||||
if (null === $value) {
|
||||
return null;
|
||||
@@ -56,7 +53,7 @@ class PointType extends Type
|
||||
|
||||
public function convertToPHPValueSQL($sqlExpr, $platform)
|
||||
{
|
||||
return 'ST_AsGeoJSON(' . $sqlExpr . ') ';
|
||||
return 'ST_AsGeoJSON('.$sqlExpr.') ';
|
||||
}
|
||||
|
||||
public function getName()
|
||||
@@ -69,6 +66,6 @@ class PointType extends Type
|
||||
*/
|
||||
public function getSQLDeclaration(array $column, AbstractPlatform $platform)
|
||||
{
|
||||
return 'geometry(POINT,' . Point::$SRID . ')';
|
||||
return 'geometry(POINT,'.Point::$SRID.')';
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user