Applied rector with PHP8.1 migration rules

This commit is contained in:
Jan Böhmer 2023-06-11 14:15:46 +02:00
parent dc6a67c2f0
commit 7ee01d9a05
303 changed files with 1228 additions and 3465 deletions

View file

@ -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;