apply more cs rules for php-cs

This commit is contained in:
2023-10-17 13:27:03 +02:00
parent 0b0cbed9db
commit bc2041cbdd
1485 changed files with 8169 additions and 9620 deletions

View File

@@ -12,7 +12,7 @@ declare(strict_types=1);
namespace Chill\MainBundle\Templating\Entity;
/**
* @deprecated load @link{BoxUtilsChillEntityRenderTrait} in the render
* @deprecated load @see{BoxUtilsChillEntityRenderTrait} in the render
*/
abstract class AbstractChillEntityRender implements ChillEntityRenderInterface
{

View File

@@ -13,12 +13,6 @@ namespace Chill\MainBundle\Templating\Entity;
use Chill\MainBundle\Entity\Address;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Templating\EngineInterface;
use function array_merge;
use function strtr;
/**
* @implements ChillEntityRenderInterface<Address>
@@ -40,7 +34,7 @@ class AddressRender implements ChillEntityRenderInterface
public function renderBox($addr, array $options): string
{
$options = array_merge(self::DEFAULT_OPTIONS, $options);
$options = \array_merge(self::DEFAULT_OPTIONS, $options);
return $this->templating
->render('@ChillMain/Entity/address.html.twig', [
@@ -60,7 +54,7 @@ class AddressRender implements ChillEntityRenderInterface
$lines = [];
if (null !== $addr->getPostcode()) {
if ($addr->getPostcode()->getCountry()->getCountryCode() === 'FR') {
if ('FR' === $addr->getPostcode()->getCountry()->getCountryCode()) {
$lines[] = $this->renderIntraBuildingLine($addr);
$lines[] = $this->renderBuildingLine($addr);
$lines[] = $this->renderStreetLine($addr);
@@ -105,10 +99,10 @@ class AddressRender implements ChillEntityRenderInterface
$streetNumber = '';
}
$res = trim($street . ', ' . $streetNumber, ', ');
$res = trim($street.', '.$streetNumber, ', ');
if ($addr->getPostcode()->getCountry()->getCountryCode() === 'FR') {
$res = trim($streetNumber . ', ' . $street, ', ');
if ('FR' === $addr->getPostcode()->getCountry()->getCountryCode()) {
$res = trim($streetNumber.', '.$street, ', ');
}
if ((',' === $res) || ('' === $res)) {
@@ -130,7 +124,7 @@ class AddressRender implements ChillEntityRenderInterface
private function renderBuildingLine(Address $addr): ?string
{
if ($addr->getBuildingName() !== '') {
if ('' !== $addr->getBuildingName()) {
$building = $addr->getBuildingName();
} else {
$building = '';
@@ -141,13 +135,13 @@ class AddressRender implements ChillEntityRenderInterface
$intraBuilding = '';
}
$res = trim($building . ' - ' . $intraBuilding, ' - ');
$res = trim($building.' - '.$intraBuilding, ' - ');
if ('' === $res) {
$res = null;
}
if ($addr->getPostcode()->getCountry()->getCountryCode() === 'FR') {
if ('FR' === $addr->getPostcode()->getCountry()->getCountryCode()) {
$res = $addr->getBuildingName();
}
@@ -157,14 +151,14 @@ class AddressRender implements ChillEntityRenderInterface
private function renderCityLine(Address $addr): string
{
if (null !== $addr->getPostcode()) {
$res = strtr('{postcode} {label}', [
$res = \strtr('{postcode} {label}', [
'{postcode}' => $addr->getPostcode()->getCode(),
'{label}' => $addr->getPostcode()->getName(),
]);
if ($addr->getPostcode()->getCountry()->getCountryCode() === 'FR') {
if ('FR' === $addr->getPostcode()->getCountry()->getCountryCode()) {
if ('' !== $addr->getDistribution()) {
$res = $res . ' ' . $addr->getDistribution();
$res = $res.' '.$addr->getDistribution();
}
}
}
@@ -189,19 +183,19 @@ class AddressRender implements ChillEntityRenderInterface
$arr = [];
if ('' !== $addr->getFlat()) {
$arr[] = 'appart ' . $addr->getFlat();
$arr[] = 'appart '.$addr->getFlat();
}
if ('' !== $addr->getFloor()) {
$arr[] = 'ét ' . $addr->getFloor();
$arr[] = 'ét '.$addr->getFloor();
}
if ('' !== $addr->getCorridor()) {
$arr[] = 'coul ' . $addr->getCorridor();
$arr[] = 'coul '.$addr->getCorridor();
}
if ('' !== $addr->getSteps()) {
$arr[] = 'esc ' . $addr->getSteps();
$arr[] = 'esc '.$addr->getSteps();
}
$res = implode(' - ', $arr);

View File

@@ -20,6 +20,6 @@ trait BoxUtilsChillEntityRenderTrait
protected function getDefaultOpeningBox($classSuffix): string
{
return '<section class="chill-entity entity-' . $classSuffix . '">';
return '<section class="chill-entity entity-'.$classSuffix.'">';
}
}

View File

@@ -20,8 +20,8 @@ class ChillEntityRender implements ChillEntityRenderInterface
public function renderBox($entity, array $options): string
{
return $this->getDefaultOpeningBox('default') . $entity
. $this->getDefaultClosingBox();
return $this->getDefaultOpeningBox('default').$entity
.$this->getDefaultClosingBox();
}
public function renderString($entity, array $options): string

View File

@@ -53,9 +53,6 @@ class ChillEntityRenderExtension extends AbstractExtension
];
}
/**
* @param $entity
*/
public function renderBox($entity, array $options = []): string
{
if (null === $entity) {
@@ -66,9 +63,6 @@ class ChillEntityRenderExtension extends AbstractExtension
->renderBox($entity, $options);
}
/**
* @param $entity
*/
public function renderString($entity, array $options = []): string
{
if (null === $entity) {
@@ -79,10 +73,6 @@ class ChillEntityRenderExtension extends AbstractExtension
->renderString($entity, $options);
}
/**
* @param $entity
* @param $options
*/
protected function getRender($entity, $options): ?ChillEntityRenderInterface
{
foreach ($this->renders as $render) {

View File

@@ -32,6 +32,7 @@ interface ChillEntityRenderInterface
* ```
*
* @param T $entity
*
* @phpstan-pure
*/
public function renderBox($entity, array $options): string;
@@ -42,6 +43,7 @@ interface ChillEntityRenderInterface
* Example: returning the name of a person.
*
* @param T $entity
*
* @phpstan-pure
*/
public function renderString($entity, array $options): string;

View File

@@ -12,11 +12,7 @@ declare(strict_types=1);
namespace Chill\MainBundle\Templating\Entity;
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
use Chill\MainBundle\Repository\UserRepository;
use Chill\MainBundle\Repository\UserRepositoryInterface;
use Symfony\Component\Templating\EngineInterface;
use function array_merge;
/**
* @implements ChillEntityRenderInterface<CommentEmbeddable>
@@ -30,7 +26,7 @@ class CommentRender implements ChillEntityRenderInterface
public function renderBox($entity, array $options): string
{
// default options
$options = array_merge([
$options = \array_merge([
'user' => [],
'disable_markdown' => false,
'limit_lines' => null,

View File

@@ -13,11 +13,7 @@ namespace Chill\MainBundle\Templating\Entity;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use DateTimeImmutable;
use Symfony\Component\Templating\EngineInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use function array_merge;
/**
* @implements ChillEntityRenderInterface<User>
@@ -33,12 +29,9 @@ class UserRender implements ChillEntityRenderInterface
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, private readonly \Twig\Environment $engine, private readonly TranslatorInterface $translator) {}
/**
* @param mixed $entity
*/
public function renderBox($entity, array $options): string
{
$opts = array_merge(self::DEFAULT_OPTIONS, $options);
$opts = \array_merge(self::DEFAULT_OPTIONS, $options);
return $this->engine->render('@ChillMain/Entity/user.html.twig', [
'user' => $entity,
@@ -46,27 +39,24 @@ class UserRender implements ChillEntityRenderInterface
]);
}
/**
* @param mixed $entity
*/
public function renderString($entity, array $options): string
{
$opts = array_merge(self::DEFAULT_OPTIONS, $options);
$opts = \array_merge(self::DEFAULT_OPTIONS, $options);
$str = $entity->getLabel();
if (null !== $entity->getUserJob($opts['at']) && $opts['user_job']) {
$str .= ' (' . $this->translatableStringHelper
->localize($entity->getUserJob($opts['at'])->getLabel()) . ')';
$str .= ' ('.$this->translatableStringHelper
->localize($entity->getUserJob($opts['at'])->getLabel()).')';
}
if (null !== $entity->getMainScope($opts['at']) && $opts['main_scope']) {
$str .= ' (' . $this->translatableStringHelper
->localize($entity->getMainScope($opts['at'])->getName()) . ')';
$str .= ' ('.$this->translatableStringHelper
->localize($entity->getMainScope($opts['at'])->getName()).')';
}
if ($entity->isAbsent() && $opts['absence']) {
$str .= ' (' . $this->translator->trans('absence.Absent') . ')';
$str .= ' ('.$this->translator->trans('absence.Absent').')';
}
return $str;