mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-30 13:34:28 +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
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue