mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-21 03:14:52 +02:00
Applied rector with PHP8.1 migration rules
This commit is contained in:
parent
dc6a67c2f0
commit
7ee01d9a05
303 changed files with 1228 additions and 3465 deletions
|
@ -31,13 +31,8 @@ use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
|
|||
|
||||
class EntityColumn extends AbstractColumn
|
||||
{
|
||||
protected EntityURLGenerator $urlGenerator;
|
||||
protected PropertyAccessorInterface $accessor;
|
||||
|
||||
public function __construct(EntityURLGenerator $URLGenerator, PropertyAccessorInterface $accessor)
|
||||
public function __construct(protected EntityURLGenerator $urlGenerator, protected PropertyAccessorInterface $accessor)
|
||||
{
|
||||
$this->urlGenerator = $URLGenerator;
|
||||
$this->accessor = $accessor;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -58,34 +53,30 @@ class EntityColumn extends AbstractColumn
|
|||
|
||||
$resolver->setRequired('property');
|
||||
|
||||
$resolver->setDefault('field', static function (Options $option) {
|
||||
return $option['property'].'.name';
|
||||
});
|
||||
$resolver->setDefault('field', static fn(Options $option): string => $option['property'].'.name');
|
||||
|
||||
$resolver->setDefault('render', function (Options $options) {
|
||||
return function ($value, $context) use ($options) {
|
||||
if ($this->accessor->isReadable($context, $options['property'])) {
|
||||
$entity = $this->accessor->getValue($context, $options['property']);
|
||||
} else {
|
||||
$entity = null;
|
||||
$resolver->setDefault('render', fn(Options $options) => function ($value, $context) use ($options): string {
|
||||
if ($this->accessor->isReadable($context, $options['property'])) {
|
||||
$entity = $this->accessor->getValue($context, $options['property']);
|
||||
} else {
|
||||
$entity = null;
|
||||
}
|
||||
|
||||
/** @var AbstractNamedDBElement|null $entity */
|
||||
|
||||
if ($entity instanceof \App\Entity\Base\AbstractNamedDBElement) {
|
||||
if (null !== $entity->getID()) {
|
||||
return sprintf(
|
||||
'<a href="%s">%s</a>',
|
||||
$this->urlGenerator->listPartsURL($entity),
|
||||
htmlspecialchars($entity->getName())
|
||||
);
|
||||
}
|
||||
|
||||
/** @var AbstractNamedDBElement|null $entity */
|
||||
return sprintf('<i>%s</i>', $value);
|
||||
}
|
||||
|
||||
if (null !== $entity) {
|
||||
if (null !== $entity->getID()) {
|
||||
return sprintf(
|
||||
'<a href="%s">%s</a>',
|
||||
$this->urlGenerator->listPartsURL($entity),
|
||||
htmlspecialchars($entity->getName())
|
||||
);
|
||||
}
|
||||
|
||||
return sprintf('<i>%s</i>', $value);
|
||||
}
|
||||
|
||||
return '';
|
||||
};
|
||||
return '';
|
||||
});
|
||||
|
||||
return $this;
|
||||
|
|
|
@ -38,7 +38,6 @@ class LocaleDateTimeColumn extends AbstractColumn
|
|||
{
|
||||
/**
|
||||
* @param $value
|
||||
* @return string
|
||||
* @throws Exception
|
||||
*/
|
||||
public function normalize($value): string
|
||||
|
|
|
@ -28,13 +28,8 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
|||
|
||||
class LogEntryExtraColumn extends AbstractColumn
|
||||
{
|
||||
protected TranslatorInterface $translator;
|
||||
protected LogEntryExtraFormatter $formatter;
|
||||
|
||||
public function __construct(TranslatorInterface $translator, LogEntryExtraFormatter $formatter)
|
||||
public function __construct(protected TranslatorInterface $translator, protected LogEntryExtraFormatter $formatter)
|
||||
{
|
||||
$this->translator = $translator;
|
||||
$this->formatter = $formatter;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -44,11 +44,8 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
|||
|
||||
class LogEntryTargetColumn extends AbstractColumn
|
||||
{
|
||||
private LogTargetHelper $logTargetHelper;
|
||||
|
||||
public function __construct(LogTargetHelper $logTargetHelper)
|
||||
public function __construct(private readonly LogTargetHelper $logTargetHelper)
|
||||
{
|
||||
$this->logTargetHelper = $logTargetHelper;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -27,11 +27,8 @@ use Omines\DataTablesBundle\Column\AbstractColumn;
|
|||
|
||||
class MarkdownColumn extends AbstractColumn
|
||||
{
|
||||
protected MarkdownParser $markdown;
|
||||
|
||||
public function __construct(MarkdownParser $markdown)
|
||||
public function __construct(protected MarkdownParser $markdown)
|
||||
{
|
||||
$this->markdown = $markdown;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -33,15 +33,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
|||
|
||||
class PartAttachmentsColumn extends AbstractColumn
|
||||
{
|
||||
protected FAIconGenerator $FAIconGenerator;
|
||||
protected EntityURLGenerator $urlGenerator;
|
||||
protected AttachmentManager $attachmentManager;
|
||||
|
||||
public function __construct(FAIconGenerator $FAIconGenerator, EntityURLGenerator $urlGenerator, AttachmentManager $attachmentManager)
|
||||
public function __construct(protected FAIconGenerator $FAIconGenerator, protected EntityURLGenerator $urlGenerator, protected AttachmentManager $attachmentManager)
|
||||
{
|
||||
$this->FAIconGenerator = $FAIconGenerator;
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
$this->attachmentManager = $attachmentManager;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -61,9 +54,7 @@ class PartAttachmentsColumn extends AbstractColumn
|
|||
throw new RuntimeException('$context must be a Part object!');
|
||||
}
|
||||
$tmp = '';
|
||||
$attachments = $context->getAttachments()->filter(function (Attachment $attachment) {
|
||||
return $attachment->getShowInTable() && $this->attachmentManager->isFileExisting($attachment);
|
||||
});
|
||||
$attachments = $context->getAttachments()->filter(fn(Attachment $attachment) => $attachment->getShowInTable() && $this->attachmentManager->isFileExisting($attachment));
|
||||
|
||||
$count = 5;
|
||||
foreach ($attachments as $attachment) {
|
||||
|
|
|
@ -25,11 +25,8 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
|||
|
||||
class PrettyBoolColumn extends AbstractColumn
|
||||
{
|
||||
protected TranslatorInterface $translator;
|
||||
|
||||
public function __construct(TranslatorInterface $translator)
|
||||
public function __construct(protected TranslatorInterface $translator)
|
||||
{
|
||||
$this->translator = $translator;
|
||||
}
|
||||
|
||||
public function normalize($value): ?bool
|
||||
|
|
|
@ -51,13 +51,8 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
|||
|
||||
class RevertLogColumn extends AbstractColumn
|
||||
{
|
||||
protected TranslatorInterface $translator;
|
||||
protected \Symfony\Bundle\SecurityBundle\Security $security;
|
||||
|
||||
public function __construct(TranslatorInterface $translator, \Symfony\Bundle\SecurityBundle\Security $security)
|
||||
public function __construct(protected TranslatorInterface $translator, protected \Symfony\Bundle\SecurityBundle\Security $security)
|
||||
{
|
||||
$this->translator = $translator;
|
||||
$this->security = $security;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -105,8 +100,6 @@ class RevertLogColumn extends AbstractColumn
|
|||
$this->translator->trans('log.undo.revert')
|
||||
);
|
||||
|
||||
$tmp .= '</div>';
|
||||
|
||||
return $tmp;
|
||||
return $tmp . '</div>';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,11 +26,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
|||
|
||||
class SIUnitNumberColumn extends AbstractColumn
|
||||
{
|
||||
protected SIFormatter $formatter;
|
||||
|
||||
public function __construct(SIFormatter $formatter)
|
||||
public function __construct(protected SIFormatter $formatter)
|
||||
{
|
||||
$this->formatter = $formatter;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): self
|
||||
|
|
|
@ -27,11 +27,8 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
|||
|
||||
class TagsColumn extends AbstractColumn
|
||||
{
|
||||
protected UrlGeneratorInterface $urlGenerator;
|
||||
|
||||
public function __construct(UrlGeneratorInterface $urlGenerator)
|
||||
public function __construct(protected UrlGeneratorInterface $urlGenerator)
|
||||
{
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -46,7 +43,7 @@ class TagsColumn extends AbstractColumn
|
|||
return [];
|
||||
}
|
||||
|
||||
return explode(',', $value);
|
||||
return explode(',', (string) $value);
|
||||
}
|
||||
|
||||
public function render($tags, $context): string
|
||||
|
@ -61,7 +58,7 @@ class TagsColumn extends AbstractColumn
|
|||
$html .= sprintf(
|
||||
'<a href="%s" class="badge bg-primary badge-table">%s</a>',
|
||||
$this->urlGenerator->generate('part_list_tags', ['tag' => $tag]),
|
||||
htmlspecialchars($tag)
|
||||
htmlspecialchars((string) $tag)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue