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

@ -48,13 +48,8 @@ use Symfony\Contracts\Translation\TranslatorInterface;
final class PartProvider implements PlaceholderProviderInterface
{
private SIFormatter $siFormatter;
private TranslatorInterface $translator;
public function __construct(SIFormatter $SIFormatter, TranslatorInterface $translator)
public function __construct(private readonly SIFormatter $siFormatter, private readonly TranslatorInterface $translator)
{
$this->siFormatter = $SIFormatter;
$this->translator = $translator;
}
public function replace(string $placeholder, object $part, array $options = []): ?string
@ -64,27 +59,27 @@ final class PartProvider implements PlaceholderProviderInterface
}
if ('[[CATEGORY]]' === $placeholder) {
return $part->getCategory() ? $part->getCategory()->getName() : '';
return $part->getCategory() instanceof \App\Entity\Parts\Category ? $part->getCategory()->getName() : '';
}
if ('[[CATEGORY_FULL]]' === $placeholder) {
return $part->getCategory() ? $part->getCategory()->getFullPath() : '';
return $part->getCategory() instanceof \App\Entity\Parts\Category ? $part->getCategory()->getFullPath() : '';
}
if ('[[MANUFACTURER]]' === $placeholder) {
return $part->getManufacturer() ? $part->getManufacturer()->getName() : '';
return $part->getManufacturer() instanceof \App\Entity\Parts\Manufacturer ? $part->getManufacturer()->getName() : '';
}
if ('[[MANUFACTURER_FULL]]' === $placeholder) {
return $part->getManufacturer() ? $part->getManufacturer()->getFullPath() : '';
return $part->getManufacturer() instanceof \App\Entity\Parts\Manufacturer ? $part->getManufacturer()->getFullPath() : '';
}
if ('[[FOOTPRINT]]' === $placeholder) {
return $part->getFootprint() ? $part->getFootprint()->getName() : '';
return $part->getFootprint() instanceof \App\Entity\Parts\Footprint ? $part->getFootprint()->getName() : '';
}
if ('[[FOOTPRINT_FULL]]' === $placeholder) {
return $part->getFootprint() ? $part->getFootprint()->getFullPath() : '';
return $part->getFootprint() instanceof \App\Entity\Parts\Footprint ? $part->getFootprint()->getFullPath() : '';
}
if ('[[MASS]]' === $placeholder) {
@ -114,7 +109,7 @@ final class PartProvider implements PlaceholderProviderInterface
}
if ('[[DESCRIPTION_T]]' === $placeholder) {
return strip_tags($parsedown->line($part->getDescription()));
return strip_tags((string) $parsedown->line($part->getDescription()));
}
if ('[[COMMENT]]' === $placeholder) {
@ -122,7 +117,7 @@ final class PartProvider implements PlaceholderProviderInterface
}
if ('[[COMMENT_T]]' === $placeholder) {
return strip_tags($parsedown->line($part->getComment()));
return strip_tags((string) $parsedown->line($part->getComment()));
}
return null;