mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-12-17 00:19:31 +00: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
|
|
@ -46,11 +46,8 @@ use App\Services\ElementTypeNameGenerator;
|
|||
|
||||
final class AbstractDBElementProvider implements PlaceholderProviderInterface
|
||||
{
|
||||
private ElementTypeNameGenerator $elementTypeNameGenerator;
|
||||
|
||||
public function __construct(ElementTypeNameGenerator $elementTypeNameGenerator)
|
||||
public function __construct(private readonly ElementTypeNameGenerator $elementTypeNameGenerator)
|
||||
{
|
||||
$this->elementTypeNameGenerator = $elementTypeNameGenerator;
|
||||
}
|
||||
|
||||
public function replace(string $placeholder, object $label_target, array $options = []): ?string
|
||||
|
|
|
|||
|
|
@ -26,13 +26,8 @@ use App\Services\LabelSystem\Barcodes\BarcodeContentGenerator;
|
|||
|
||||
final class BarcodeProvider implements PlaceholderProviderInterface
|
||||
{
|
||||
private BarcodeGenerator $barcodeGenerator;
|
||||
private BarcodeContentGenerator $barcodeContentGenerator;
|
||||
|
||||
public function __construct(BarcodeGenerator $barcodeGenerator, BarcodeContentGenerator $barcodeContentGenerator)
|
||||
public function __construct(private readonly BarcodeGenerator $barcodeGenerator, private readonly BarcodeContentGenerator $barcodeContentGenerator)
|
||||
{
|
||||
$this->barcodeGenerator = $barcodeGenerator;
|
||||
$this->barcodeContentGenerator = $barcodeContentGenerator;
|
||||
}
|
||||
|
||||
public function replace(string $placeholder, object $label_target, array $options = []): ?string
|
||||
|
|
@ -40,7 +35,7 @@ final class BarcodeProvider implements PlaceholderProviderInterface
|
|||
if ('[[1D_CONTENT]]' === $placeholder) {
|
||||
try {
|
||||
return $this->barcodeContentGenerator->get1DBarcodeContent($label_target);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
} catch (\InvalidArgumentException) {
|
||||
return 'ERROR!';
|
||||
}
|
||||
}
|
||||
|
|
@ -48,7 +43,7 @@ final class BarcodeProvider implements PlaceholderProviderInterface
|
|||
if ('[[2D_CONTENT]]' === $placeholder) {
|
||||
try {
|
||||
return $this->barcodeContentGenerator->getURLContent($label_target);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
} catch (\InvalidArgumentException) {
|
||||
return 'ERROR!';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,15 +53,8 @@ use Symfony\Component\Security\Core\Security;
|
|||
*/
|
||||
final class GlobalProviders implements PlaceholderProviderInterface
|
||||
{
|
||||
private string $partdb_title;
|
||||
private \Symfony\Bundle\SecurityBundle\Security $security;
|
||||
private UrlGeneratorInterface $url_generator;
|
||||
|
||||
public function __construct(string $partdb_title, \Symfony\Bundle\SecurityBundle\Security $security, UrlGeneratorInterface $url_generator)
|
||||
public function __construct(private readonly string $partdb_title, private readonly \Symfony\Bundle\SecurityBundle\Security $security, private readonly UrlGeneratorInterface $url_generator)
|
||||
{
|
||||
$this->partdb_title = $partdb_title;
|
||||
$this->security = $security;
|
||||
$this->url_generator = $url_generator;
|
||||
}
|
||||
|
||||
public function replace(string $placeholder, object $label_target, array $options = []): ?string
|
||||
|
|
|
|||
|
|
@ -49,13 +49,8 @@ use Locale;
|
|||
|
||||
final class PartLotProvider implements PlaceholderProviderInterface
|
||||
{
|
||||
private LabelTextReplacer $labelTextReplacer;
|
||||
private AmountFormatter $amountFormatter;
|
||||
|
||||
public function __construct(LabelTextReplacer $labelTextReplacer, AmountFormatter $amountFormatter)
|
||||
public function __construct(private readonly LabelTextReplacer $labelTextReplacer, private readonly AmountFormatter $amountFormatter)
|
||||
{
|
||||
$this->labelTextReplacer = $labelTextReplacer;
|
||||
$this->amountFormatter = $amountFormatter;
|
||||
}
|
||||
|
||||
public function replace(string $placeholder, object $label_target, array $options = []): ?string
|
||||
|
|
@ -74,7 +69,7 @@ final class PartLotProvider implements PlaceholderProviderInterface
|
|||
}
|
||||
|
||||
if ('[[EXPIRATION_DATE]]' === $placeholder) {
|
||||
if (null === $label_target->getExpirationDate()) {
|
||||
if (!$label_target->getExpirationDate() instanceof \DateTimeInterface) {
|
||||
return '';
|
||||
}
|
||||
$formatter = IntlDateFormatter::create(
|
||||
|
|
@ -95,19 +90,19 @@ final class PartLotProvider implements PlaceholderProviderInterface
|
|||
}
|
||||
|
||||
if ('[[LOCATION]]' === $placeholder) {
|
||||
return $label_target->getStorageLocation() ? $label_target->getStorageLocation()->getName() : '';
|
||||
return $label_target->getStorageLocation() instanceof \App\Entity\Parts\Storelocation ? $label_target->getStorageLocation()->getName() : '';
|
||||
}
|
||||
|
||||
if ('[[LOCATION_FULL]]' === $placeholder) {
|
||||
return $label_target->getStorageLocation() ? $label_target->getStorageLocation()->getFullPath() : '';
|
||||
return $label_target->getStorageLocation() instanceof \App\Entity\Parts\Storelocation ? $label_target->getStorageLocation()->getFullPath() : '';
|
||||
}
|
||||
|
||||
if ('[[OWNER]]' === $placeholder) {
|
||||
return $label_target->getOwner() ? $label_target->getOwner()->getFullName() : '';
|
||||
return $label_target->getOwner() instanceof \App\Entity\UserSystem\User ? $label_target->getOwner()->getFullName() : '';
|
||||
}
|
||||
|
||||
if ('[[OWNER_USERNAME]]' === $placeholder) {
|
||||
return $label_target->getOwner() ? $label_target->getOwner()->getUsername() : '';
|
||||
return $label_target->getOwner() instanceof \App\Entity\UserSystem\User ? $label_target->getOwner()->getUsername() : '';
|
||||
}
|
||||
|
||||
return $this->labelTextReplacer->handlePlaceholder($placeholder, $label_target->getPart());
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -28,11 +28,11 @@ class StorelocationProvider implements PlaceholderProviderInterface
|
|||
{
|
||||
if ($label_target instanceof Storelocation) {
|
||||
if ('[[OWNER]]' === $placeholder) {
|
||||
return $label_target->getOwner() ? $label_target->getOwner()->getFullName() : '';
|
||||
return $label_target->getOwner() instanceof \App\Entity\UserSystem\User ? $label_target->getOwner()->getFullName() : '';
|
||||
}
|
||||
|
||||
if ('[[OWNER_USERNAME]]' === $placeholder) {
|
||||
return $label_target->getOwner() ? $label_target->getOwner()->getUsername() : '';
|
||||
return $label_target->getOwner() instanceof \App\Entity\UserSystem\User ? $label_target->getOwner()->getUsername() : '';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -58,10 +58,10 @@ final class StructuralDBElementProvider implements PlaceholderProviderInterface
|
|||
return $label_target->getFullPath();
|
||||
}
|
||||
if ('[[PARENT]]' === $placeholder) {
|
||||
return $label_target->getParent() ? $label_target->getParent()->getName() : '';
|
||||
return $label_target->getParent() instanceof \App\Entity\Base\AbstractStructuralDBElement ? $label_target->getParent()->getName() : '';
|
||||
}
|
||||
if ('[[PARENT_FULL_PATH]]' === $placeholder) {
|
||||
return $label_target->getParent() ? $label_target->getParent()->getFullPath() : '';
|
||||
return $label_target->getParent() instanceof \App\Entity\Base\AbstractStructuralDBElement ? $label_target->getParent()->getFullPath() : '';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue