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

@ -62,11 +62,8 @@ final class BarcodeContentGenerator
Storelocation::class => 'location',
];
private UrlGeneratorInterface $urlGenerator;
public function __construct(UrlGeneratorInterface $urlGenerator)
public function __construct(private readonly UrlGeneratorInterface $urlGenerator)
{
$this->urlGenerator = $urlGenerator;
}
/**
@ -97,17 +94,17 @@ final class BarcodeContentGenerator
private function classToString(array $map, object $target): string
{
$class = get_class($target);
$class = $target::class;
if (isset($map[$class])) {
return $map[$class];
}
foreach ($map as $class => $string) {
if (is_a($target, $class)) {
if ($target instanceof $class) {
return $string;
}
}
throw new InvalidArgumentException('Unknown object class '.get_class($target));
throw new InvalidArgumentException('Unknown object class '.$target::class);
}
}

View file

@ -49,13 +49,8 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
final class BarcodeRedirector
{
private UrlGeneratorInterface $urlGenerator;
private EntityManagerInterface $em;
public function __construct(UrlGeneratorInterface $urlGenerator, EntityManagerInterface $entityManager)
public function __construct(private readonly UrlGeneratorInterface $urlGenerator, private readonly EntityManagerInterface $em)
{
$this->urlGenerator = $urlGenerator;
$this->em = $entityManager;
}
/**
@ -76,7 +71,7 @@ final class BarcodeRedirector
case 'lot':
//Try to determine the part to the given lot
$lot = $this->em->find(PartLot::class, $id);
if (null === $lot) {
if (!$lot instanceof \App\Entity\Parts\PartLot) {
throw new EntityNotFoundException();
}