Fixed some more inspection issues

This commit is contained in:
Jan Böhmer 2023-04-15 22:05:29 +02:00
parent de96aae9a5
commit 29d1d49aca
83 changed files with 153 additions and 172 deletions

View file

@ -91,12 +91,12 @@ final class UpgradePermissionsSchemaCommand extends Command
//List all users and groups that need an update
$io->section('Groups that need an update:');
$io->listing(array_map(function (Group $group) {
$io->listing(array_map(static function (Group $group) {
return $group->getName() . ' (ID: '. $group->getID() .', Current version: ' . $group->getPermissions()->getSchemaVersion() . ')';
}, $groups_to_upgrade));
$io->section('Users that need an update:');
$io->listing(array_map(function (User $user) {
$io->listing(array_map(static function (User $user) {
return $user->getUsername() . ' (ID: '. $user->getID() .', Current version: ' . $user->getPermissions()->getSchemaVersion() . ')';
}, $users_to_upgrade));

View file

@ -87,7 +87,7 @@ class UserEnableCommand extends Command
$io->note('The following users will be enabled:');
}
$io->table(['Username', 'Enabled/Disabled'],
array_map(function(User $user) {
array_map(static function(User $user) {
return [$user->getFullName(true), $user->isDisabled() ? 'Disabled' : 'Enabled'];
}, $users));

View file

@ -74,9 +74,9 @@ class GroupController extends BaseAdminController
//We need to stop the execution here, or our permissions changes will be overwritten by the form values
return $this->redirectToRoute('group_edit', ['id' => $entity->getID()]);
} else {
$this->addFlash('danger', 'csfr_invalid');
}
$this->addFlash('danger', 'csfr_invalid');
}
return $this->_edit($entity, $request, $em, $timestamp);

View file

@ -52,7 +52,7 @@ class LogController extends AbstractController
{
protected EntityManagerInterface $entityManager;
protected TimeTravel $timeTravel;
protected DBElementRepository $dbRepository;
protected EntityRepository $dbRepository;
public function __construct(EntityManagerInterface $entityManager, TimeTravel $timeTravel)
{

View file

@ -114,9 +114,9 @@ class ProjectController extends AbstractController
$request->get('_redirect',
$this->generateUrl('project_info', ['id' => $project->getID()]
)));
} else {
$this->addFlash('error', 'project.build.flash.invalid_input');
}
$this->addFlash('error', 'project.build.flash.invalid_input');
}
return $this->renderForm('projects/build/build.html.twig', [

View file

@ -106,7 +106,7 @@ class SelectAPIController extends AbstractController
3 => $this->translator->trans('export.level.full'),
];
return $this->json(array_map(function ($key, $value) {
return $this->json(array_map(static function ($key, $value) {
return [
'text' => $value,
'value' => $key,
@ -198,7 +198,7 @@ class SelectAPIController extends AbstractController
]);
//Remove the data-* prefix for each key
$data = array_combine(
array_map(function ($key) {
array_map(static function ($key) {
if (strpos($key, 'data-') === 0) {
return substr($key, 5);
}

View file

@ -129,9 +129,9 @@ class UserController extends AdminPages\BaseAdminController
//We need to stop the execution here, or our permissions changes will be overwritten by the form values
return $this->redirectToRoute('user_edit', ['id' => $entity->getID()]);
} else {
$this->addFlash('danger', 'csfr_invalid');
}
$this->addFlash('danger', 'csfr_invalid');
}
return $this->_edit($entity, $request, $em, $timestamp);

View file

@ -45,7 +45,9 @@ class LocaleDateTimeColumn extends AbstractColumn
{
if (null === $value) {
return $this->options['nullValue'];
} elseif (!$value instanceof DateTimeInterface) {
}
if (!$value instanceof DateTimeInterface) {
$value = new DateTime((string) $value);
}

View file

@ -51,7 +51,7 @@ trait FilterTrait
protected function generateParameterIdentifier(string $property): string
{
//Replace all special characters with underscores
$property = preg_replace('/[^a-zA-Z0-9_]/', '_', $property);
$property = preg_replace('/\W/', '_', $property);
//Add a random number to the end of the property name for uniqueness
return $property . '_' . uniqid("", false);
}

View file

@ -63,27 +63,19 @@ use Symfony\Contracts\Translation\TranslatorInterface;
final class PartsDataTable implements DataTableTypeInterface
{
private TranslatorInterface $translator;
private NodesListBuilder $treeBuilder;
private AmountFormatter $amountFormatter;
private AttachmentURLGenerator $attachmentURLGenerator;
private Security $security;
private PartDataTableHelper $partDataTableHelper;
/**
* @var EntityURLGenerator
*/
private $urlGenerator;
private EntityURLGenerator $urlGenerator;
public function __construct(EntityURLGenerator $urlGenerator, TranslatorInterface $translator,
NodesListBuilder $treeBuilder, AmountFormatter $amountFormatter,PartDataTableHelper $partDataTableHelper,
AttachmentURLGenerator $attachmentURLGenerator, Security $security)
AmountFormatter $amountFormatter,PartDataTableHelper $partDataTableHelper, Security $security)
{
$this->urlGenerator = $urlGenerator;
$this->translator = $translator;
$this->treeBuilder = $treeBuilder;
$this->amountFormatter = $amountFormatter;
$this->attachmentURLGenerator = $attachmentURLGenerator;
$this->security = $security;
$this->partDataTableHelper = $partDataTableHelper;
}

View file

@ -53,21 +53,21 @@ class ResetAutoIncrementORMPurger implements PurgerInterface, ORMPurgerInterface
public const PURGE_MODE_TRUNCATE = 2;
/** @var EntityManagerInterface|null */
private $em;
private ?EntityManagerInterface $em;
/**
* If the purge should be done through DELETE or TRUNCATE statements
*
* @var int
*/
private $purgeMode = self::PURGE_MODE_DELETE;
private int $purgeMode = self::PURGE_MODE_DELETE;
/**
* Table/view names to be excluded from purge
*
* @var string[]
*/
private $excluded;
private array $excluded;
/**
* Construct new purger instance.

View file

@ -51,7 +51,7 @@ class AttachmentType extends AbstractStructuralDBElement
* @ORM\ManyToOne(targetEntity="AttachmentType", inversedBy="children")
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
*/
protected $parent;
protected ?AbstractStructuralDBElement $parent;
/**
* @var string

View file

@ -94,7 +94,7 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement
* @NoneOfItsChildren()
* @Groups({"include_parents", "import"})
*/
protected $parent = null;
protected ?AbstractStructuralDBElement $parent = null;
/** @var string[] all names of all parent elements as a array of strings,
* the last array element is the name of the element itself
@ -155,10 +155,8 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement
if ($this->getParent() === $another_element) {
return true;
}
} else { //If the IDs are defined, we can compare the IDs
if ($this->getParent()->getID() === $another_element->getID()) {
return true;
}
} elseif ($this->getParent()->getID() === $another_element->getID()) {
return true;
}
//Otherwise, check recursively

View file

@ -183,7 +183,7 @@ abstract class AbstractLogEntry extends AbstractDBElement
/** @var array The extra data in raw (short form) saved in the DB
* @ORM\Column(name="extra", type="json")
*/
protected $extra = [];
protected array $extra = [];
public function __construct()
{

View file

@ -143,7 +143,7 @@ abstract class AbstractParameter extends AbstractNamedDBElement
*
* @var AbstractDBElement|null the element to which this parameter belongs to
*/
protected $element;
protected ?AbstractDBElement $element;
public function __construct()
{

View file

@ -57,5 +57,5 @@ class AttachmentTypeParameter extends AbstractParameter
* @ORM\ManyToOne(targetEntity="App\Entity\Attachments\AttachmentType", inversedBy="parameters")
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/
protected $element;
protected ?\App\Entity\Base\AbstractDBElement $element;
}

View file

@ -57,5 +57,5 @@ class CategoryParameter extends AbstractParameter
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Category", inversedBy="parameters")
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/
protected $element;
protected ?\App\Entity\Base\AbstractDBElement $element;
}

View file

@ -60,5 +60,5 @@ class CurrencyParameter extends AbstractParameter
* @ORM\ManyToOne(targetEntity="App\Entity\PriceInformations\Currency", inversedBy="parameters")
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/
protected $element;
protected ?\App\Entity\Base\AbstractDBElement $element;
}

View file

@ -58,5 +58,5 @@ class FootprintParameter extends AbstractParameter
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Footprint", inversedBy="parameters")
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/
protected $element;
protected ?\App\Entity\Base\AbstractDBElement $element;
}

View file

@ -58,5 +58,5 @@ class GroupParameter extends AbstractParameter
* @ORM\ManyToOne(targetEntity="App\Entity\UserSystem\Group", inversedBy="parameters")
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/
protected $element;
protected ?\App\Entity\Base\AbstractDBElement $element;
}

View file

@ -58,5 +58,5 @@ class ManufacturerParameter extends AbstractParameter
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Manufacturer", inversedBy="parameters")
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/
protected $element;
protected ?\App\Entity\Base\AbstractDBElement $element;
}

View file

@ -58,5 +58,5 @@ class MeasurementUnitParameter extends AbstractParameter
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\MeasurementUnit", inversedBy="parameters")
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/
protected $element;
protected ?\App\Entity\Base\AbstractDBElement $element;
}

View file

@ -52,7 +52,7 @@ trait ParametersTrait
* @var Collection<int, AbstractParameter>
* @Assert\Valid()
*/
protected $parameters;
protected Collection $parameters;
/**
* Return all associated specifications.

View file

@ -58,5 +58,5 @@ class PartParameter extends AbstractParameter
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Part", inversedBy="parameters")
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/
protected $element;
protected ?\App\Entity\Base\AbstractDBElement $element;
}

View file

@ -58,5 +58,5 @@ class ProjectParameter extends AbstractParameter
* @ORM\ManyToOne(targetEntity="App\Entity\ProjectSystem\Project", inversedBy="parameters")
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/
protected $element;
protected ?\App\Entity\Base\AbstractDBElement $element;
}

View file

@ -58,5 +58,5 @@ class StorelocationParameter extends AbstractParameter
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Storelocation", inversedBy="parameters")
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/
protected $element;
protected ?\App\Entity\Base\AbstractDBElement $element;
}

View file

@ -58,5 +58,5 @@ class SupplierParameter extends AbstractParameter
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Supplier", inversedBy="parameters")
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/
protected $element;
protected ?\App\Entity\Base\AbstractDBElement $element;
}

View file

@ -52,7 +52,7 @@ class Category extends AbstractPartsContainingDBElement
* @ORM\ManyToOne(targetEntity="Category", inversedBy="children")
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
*/
protected $parent;
protected ?\App\Entity\Base\AbstractStructuralDBElement $parent;
/**
* @var string

View file

@ -44,7 +44,7 @@ class Footprint extends AbstractPartsContainingDBElement
* @ORM\ManyToOne(targetEntity="Footprint", inversedBy="children")
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
*/
protected $parent;
protected ?\App\Entity\Base\AbstractStructuralDBElement $parent;
/**
* @ORM\OneToMany(targetEntity="Footprint", mappedBy="parent")

View file

@ -44,7 +44,7 @@ class Manufacturer extends AbstractCompany
* @ORM\ManyToOne(targetEntity="Manufacturer", inversedBy="children")
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
*/
protected $parent;
protected ?\App\Entity\Base\AbstractStructuralDBElement $parent;
/**
* @ORM\OneToMany(targetEntity="Manufacturer", mappedBy="parent")

View file

@ -81,7 +81,7 @@ class MeasurementUnit extends AbstractPartsContainingDBElement
* @ORM\ManyToOne(targetEntity="MeasurementUnit", inversedBy="children")
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
*/
protected $parent;
protected ?\App\Entity\Base\AbstractStructuralDBElement $parent;
/**
* @var Collection<int, MeasurementUnitAttachment>

View file

@ -53,7 +53,7 @@ class Storelocation extends AbstractPartsContainingDBElement
* @ORM\ManyToOne(targetEntity="Storelocation", inversedBy="children")
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
*/
protected $parent;
protected ?\App\Entity\Base\AbstractStructuralDBElement $parent;
/**
* @var MeasurementUnit|null The measurement unit, which parts can be stored in here

View file

@ -56,7 +56,7 @@ class Supplier extends AbstractCompany
* @ORM\ManyToOne(targetEntity="Supplier", inversedBy="children")
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
*/
protected $parent;
protected ?\App\Entity\Base\AbstractStructuralDBElement $parent;
/**
* @ORM\OneToMany(targetEntity="App\Entity\PriceInformations\Orderdetail", mappedBy="supplier")

View file

@ -75,7 +75,7 @@ class Currency extends AbstractStructuralDBElement
* @ORM\ManyToOne(targetEntity="Currency", inversedBy="children")
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
*/
protected $parent;
protected ?AbstractStructuralDBElement $parent;
/**
* @var Collection<int, CurrencyAttachment>

View file

@ -57,7 +57,7 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
* @ORM\OrderBy({"min_discount_quantity" = "ASC"})
* @Groups({"extended", "full", "import"})
*/
protected $pricedetails;
protected Collection $pricedetails;
/**
* @var string

View file

@ -53,14 +53,14 @@ class Project extends AbstractStructuralDBElement
* @ORM\ManyToOne(targetEntity="Project", inversedBy="children")
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
*/
protected $parent;
protected ?AbstractStructuralDBElement $parent;
/**
* @ORM\OneToMany(targetEntity="ProjectBOMEntry", mappedBy="project", cascade={"persist", "remove"}, orphanRemoval=true)
* @Assert\Valid()
* @Groups({"extended", "full"})
*/
protected $bom_entries;
protected Collection $bom_entries;
/**
* @ORM\Column(type="integer")

View file

@ -55,7 +55,7 @@ class Group extends AbstractStructuralDBElement implements HasPermissionsInterfa
* @ORM\ManyToOne(targetEntity="Group", inversedBy="children")
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
*/
protected $parent;
protected ?AbstractStructuralDBElement $parent;
/**
* @ORM\OneToMany(targetEntity="User", mappedBy="group")
@ -68,7 +68,7 @@ class Group extends AbstractStructuralDBElement implements HasPermissionsInterfa
* @ORM\Column(type="boolean", name="enforce_2fa")
* @Groups({"extended", "full", "import"})
*/
protected $enforce2FA = false;
protected bool $enforce2FA = false;
/**
* @var Collection<int, GroupAttachment>
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\GroupAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)

View file

@ -216,7 +216,7 @@ final class PermissionData implements \JsonSerializable
continue;
}
$ret[$permission] = array_filter($operations, function ($value) {
$ret[$permission] = array_filter($operations, static function ($value) {
return $value !== null;
});

View file

@ -255,10 +255,10 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
* @Selectable()
* @Groups({"extended", "full", "import"})
*/
protected $currency;
protected ?Currency $currency;
/**
* @var PermissionData
* @var PermissionData|null
* @ValidPermission()
* @ORM\Embedded(class="PermissionData", columnPrefix="permissions_")
* @Groups({"simple", "extended", "full", "import"})
@ -266,10 +266,10 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
protected ?PermissionData $permissions = null;
/**
* @var DateTime the time until the password reset token is valid
* @var DateTime|null the time until the password reset token is valid
* @ORM\Column(type="datetime", nullable=true, options={"default": null})
*/
protected $pw_reset_expires;
protected ?DateTime $pw_reset_expires;
/**
* @var bool True if the user was created by a SAML provider (and therefore cannot change its password)

View file

@ -25,14 +25,12 @@ namespace App\Form\AdminPages;
use App\Entity\Base\AbstractNamedDBElement;
use App\Entity\Base\AbstractStructuralDBElement;
use App\Entity\LabelSystem\LabelProfile;
use App\Entity\Parameters\AbstractParameter;
use App\Form\AttachmentFormType;
use App\Form\ParameterType;
use App\Form\Type\MasterPictureAttachmentType;
use App\Form\Type\RichTextEditorType;
use App\Form\Type\StructuralEntityType;
use App\Services\LogSystem\EventCommentNeededHelper;
use FOS\CKEditorBundle\Form\Type\CKEditorType;
use function get_class;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;

View file

@ -27,7 +27,6 @@ use App\Entity\Attachments\AttachmentType;
use App\Form\Type\StructuralEntityType;
use App\Services\Attachments\AttachmentManager;
use App\Services\Attachments\AttachmentSubmitHandler;
use App\Validator\Constraints\AllowedFileExtension;
use App\Validator\Constraints\UrlOrBuiltin;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;

View file

@ -27,7 +27,6 @@ use App\Entity\Parts\Supplier;
use App\Entity\PriceInformations\Orderdetail;
use App\Entity\PriceInformations\Pricedetail;
use App\Form\Type\StructuralEntityType;
use App\Form\WorkaroundCollectionType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;

View file

@ -36,7 +36,6 @@ use App\Form\Type\MasterPictureAttachmentType;
use App\Form\Type\RichTextEditorType;
use App\Form\Type\SIUnitType;
use App\Form\Type\StructuralEntityType;
use App\Form\WorkaroundCollectionType;
use App\Services\LogSystem\EventCommentNeededHelper;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;

View file

@ -43,12 +43,12 @@ class PartLotSelectType extends AbstractType
$resolver->setDefaults([
'class' => PartLot::class,
'choice_label' => ChoiceList::label($this, function (PartLot $part_lot) {
'choice_label' => ChoiceList::label($this, static function (PartLot $part_lot) {
return ($part_lot->getStorageLocation() ? $part_lot->getStorageLocation()->getFullPath() : '')
. ' (' . $part_lot->getName() . '): ' . $part_lot->getAmount();
}),
'query_builder' => function (Options $options) {
return function (EntityRepository $er) use ($options) {
return static function (EntityRepository $er) use ($options) {
return $er->createQueryBuilder('l')
->where('l.part = :part')
->setParameter('part', $options['part']);

View file

@ -30,17 +30,17 @@ use JsonSerializable;
*/
final class TreeViewNode implements JsonSerializable
{
private $text;
private $href;
private $nodes;
private string $text;
private ?string $href;
private ?array $nodes;
private $state = null;
private ?TreeViewNodeState $state = null;
private $tags;
private ?array $tags;
private $id;
private ?int $id;
private $icon;
private ?string $icon;
/**
* Creates a new TreeView node with the given parameters.

View file

@ -29,17 +29,17 @@ final class TreeViewNodeState implements JsonSerializable
/**
* @var bool|null
*/
private $disabled = null;
private ?bool $disabled = null;
/**
* @var bool|null
*/
private $expanded = null;
private ?bool $expanded = null;
/**
* @var bool|null
*/
private $selected = null;
private ?bool $selected = null;
public function getDisabled(): ?bool
{

View file

@ -21,13 +21,8 @@
namespace App\Migration;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver\AbstractMySQLDriver;
use Doctrine\DBAL\Driver\AbstractSQLiteDriver;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Platforms\AbstractMySQLPlatform;
use Doctrine\DBAL\Platforms\MariaDBPlatform;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
@ -43,7 +38,7 @@ abstract class AbstractMultiPlatformMigration extends AbstractMigration
public function __construct(Connection $connection, LoggerInterface $logger)
{
$this->logger = $logger;
AbstractMigration::__construct($connection, $logger);
parent::__construct($connection, $logger);
}
public function up(Schema $schema): void

View file

@ -35,7 +35,7 @@ use Symfony\Component\Security\Core\User\UserInterface;
*/
final class UserRepository extends NamedDBElementRepository implements PasswordUpgraderInterface
{
protected $anonymous_user;
protected ?User $anonymous_user;
/**
* Returns the anonymous user.

View file

@ -32,7 +32,7 @@ use function in_array;
class AttachmentVoter extends ExtendedVoter
{
protected $security;
protected Security $security;
public function __construct(PermissionManager $resolver, EntityManagerInterface $entityManager, Security $security)
{

View file

@ -48,7 +48,7 @@ class StructuralElementDenormalizer implements ContextAwareDenormalizerInterface
return is_array($data)
&& is_subclass_of($type, AbstractStructuralDBElement::class)
//Only denormalize if we are doing an file import operation
&& in_array('import', $context['groups'] ?? []);
&& in_array('import', $context['groups'] ?? [], true);
}
public function denormalize($data, string $type, string $format = null, array $context = []): ?AbstractStructuralDBElement

View file

@ -443,11 +443,13 @@ class AttachmentSubmitHandler
];
if (ctype_digit((string) $maxSize)) {
return (int) $maxSize;
} elseif (preg_match('/^(\d++)('.implode('|', array_keys($factors)).')$/i', $maxSize, $matches)) {
return (((int) $matches[1]) * $factors[strtolower($matches[2])]);
} else {
throw new RuntimeException(sprintf('"%s" is not a valid maximum size.', $maxSize));
}
if (preg_match('/^(\d++)('.implode('|', array_keys($factors)).')$/i', $maxSize, $matches)) {
return (((int) $matches[1]) * $factors[strtolower($matches[2])]);
}
throw new RuntimeException(sprintf('"%s" is not a valid maximum size.', $maxSize));
}
/*

View file

@ -114,7 +114,7 @@ class BOMImporter
foreach ($csv->getRecords() as $offset => $entry) {
//Translate the german field names to english
$entry = array_combine(array_map(function ($key) {
$entry = array_combine(array_map(static function ($key) {
return self::MAP_KICAD_PCB_FIELDS[$key] ?? $key;
}, array_keys($entry)), $entry);

View file

@ -41,6 +41,8 @@ declare(strict_types=1);
namespace App\Services\LabelSystem;
use App\Entity\Base\AbstractDBElement;
use App\Entity\Base\AbstractStructuralDBElement;
use App\Entity\LabelSystem\LabelOptions;
use App\Services\LabelSystem\Barcodes\BarcodeContentGenerator;
use Com\Tecnick\Barcode\Barcode;
@ -125,7 +127,7 @@ final class BarcodeGenerator
return $bobj->getSvgCode();
}
public function getContent(LabelOptions $options, object $target): ?string
public function getContent(LabelOptions $options, AbstractDBElement $target): ?string
{
switch ($options->getBarcodeType()) {
case 'qr':

View file

@ -49,14 +49,14 @@ use function count;
class TreeViewGenerator
{
protected $urlGenerator;
protected $em;
protected $cache;
protected $keyGenerator;
protected $translator;
protected EntityURLGenerator $urlGenerator;
protected EntityManagerInterface $em;
protected TagAwareCacheInterface $cache;
protected UserCacheKeyGenerator $keyGenerator;
protected TranslatorInterface $translator;
protected $rootNodeExpandedByDefault;
protected $rootNodeEnabled;
protected bool $rootNodeExpandedByDefault;
protected bool $rootNodeEnabled;
public function __construct(EntityURLGenerator $URLGenerator, EntityManagerInterface $em,
TagAwareCacheInterface $treeCache, UserCacheKeyGenerator $keyGenerator, TranslatorInterface $translator, bool $rootNodeExpandedByDefault, bool $rootNodeEnabled)

View file

@ -36,11 +36,7 @@ class PermissionSchemaUpdater
{
$perm_data = $holder->getPermissions();
if ($perm_data->getSchemaVersion() < PermissionData::CURRENT_SCHEMA_VERSION) {
return true;
}
return false;
return $perm_data->getSchemaVersion() < PermissionData::CURRENT_SCHEMA_VERSION;
}
/**

View file

@ -48,5 +48,5 @@ use Symfony\Component\Validator\Constraint;
*/
class ValidRange extends Constraint
{
public $message = 'validator.invalid_range';
public string $message = 'validator.invalid_range';
}

View file

@ -31,5 +31,5 @@ use Symfony\Component\Validator\Constraint;
*/
class NoLockout extends Constraint
{
public $message = 'validator.noLockout';
public string $message = 'validator.noLockout';
}

View file

@ -35,9 +35,9 @@ class NoneOfItsChildren extends Constraint
/**
* @var string The message used if it is tried to assign a object as its own parent
*/
public $self_message = 'validator.noneofitschild.self';
public string $self_message = 'validator.noneofitschild.self';
/**
* @var string The message used if it is tried to use one of the children for as parent
*/
public $children_message = 'validator.noneofitschild.children';
public string $children_message = 'validator.noneofitschild.children';
}

View file

@ -35,5 +35,5 @@ class UrlOrBuiltin extends Url
/**
* @var array A list of the placeholders that are treated as builtin
*/
public $allowed_placeholders = Attachment::BUILTIN_PLACEHOLDER;
public array $allowed_placeholders = Attachment::BUILTIN_PLACEHOLDER;
}

View file

@ -31,8 +31,8 @@ use Symfony\Component\Security\Core\Exception\AccessDeniedException;
*/
abstract class AbstractAdminControllerTest extends WebTestCase
{
protected static $base_path = 'not_valid';
protected static $entity_class = 'not valid';
protected static string $base_path = 'not_valid';
protected static string $entity_class = 'not valid';
public function readDataProvider(): array
{

View file

@ -30,6 +30,6 @@ use App\Entity\Attachments\AttachmentType;
*/
class AttachmentTypeControllerTest extends AbstractAdminControllerTest
{
protected static $base_path = '/en'.'/attachment_type';
protected static $entity_class = AttachmentType::class;
protected static string $base_path = '/en'.'/attachment_type';
protected static string $entity_class = AttachmentType::class;
}

View file

@ -30,6 +30,6 @@ use App\Entity\Parts\Category;
*/
class CategoryControllerTest extends AbstractAdminControllerTest
{
protected static $base_path = '/en'.'/category';
protected static $entity_class = Category::class;
protected static string $base_path = '/en'.'/category';
protected static string $entity_class = Category::class;
}

View file

@ -30,6 +30,6 @@ use App\Entity\Parts\Footprint;
*/
class FootprintControllerTest extends AbstractAdminControllerTest
{
protected static $base_path = '/en'.'/footprint';
protected static $entity_class = Footprint::class;
protected static string $base_path = '/en'.'/footprint';
protected static string $entity_class = Footprint::class;
}

View file

@ -46,8 +46,8 @@ use Symfony\Component\Security\Core\Exception\AccessDeniedException;
class LabelProfileControllerTest extends AbstractAdminControllerTest
{
protected static $base_path = '/en'.'/label_profile';
protected static $entity_class = LabelProfile::class;
protected static string $base_path = '/en'.'/label_profile';
protected static string $entity_class = LabelProfile::class;
/**
* Tests if deleting an entity is working.

View file

@ -30,6 +30,6 @@ use App\Entity\Parts\Manufacturer;
*/
class ManufacturerControllerTest extends AbstractAdminControllerTest
{
protected static $base_path = '/en'.'/manufacturer';
protected static $entity_class = Manufacturer::class;
protected static string $base_path = '/en'.'/manufacturer';
protected static string $entity_class = Manufacturer::class;
}

View file

@ -30,6 +30,6 @@ use App\Entity\Parts\MeasurementUnit;
*/
class MeasurementUnitControllerTest extends AbstractAdminControllerTest
{
protected static $base_path = '/en'.'/measurement_unit';
protected static $entity_class = MeasurementUnit::class;
protected static string $base_path = '/en'.'/measurement_unit';
protected static string $entity_class = MeasurementUnit::class;
}

View file

@ -31,6 +31,6 @@ use App\Entity\ProjectSystem\Project;
*/
class ProjectControllerTest extends AbstractAdminControllerTest
{
protected static $base_path = '/en'.'/project';
protected static $entity_class = Project::class;
protected static string $base_path = '/en'.'/project';
protected static string $entity_class = Project::class;
}

View file

@ -30,6 +30,6 @@ use App\Entity\Parts\Storelocation;
*/
class StorelocationControllerTest extends AbstractAdminControllerTest
{
protected static $base_path = '/en'.'/store_location';
protected static $entity_class = Storelocation::class;
protected static string $base_path = '/en'.'/store_location';
protected static string $entity_class = Storelocation::class;
}

View file

@ -30,6 +30,6 @@ use App\Entity\Parts\Supplier;
*/
class SupplierControllerTest extends AbstractAdminControllerTest
{
protected static $base_path = '/en'.'/supplier';
protected static $entity_class = Supplier::class;
protected static string $base_path = '/en'.'/supplier';
protected static string $entity_class = Supplier::class;
}

View file

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace App\Tests\Controller;
use App\Entity\UserSystem\User;
use App\Repository\UserRepository;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@ -32,9 +33,9 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
*/
class RedirectControllerTest extends WebTestCase
{
protected $em;
protected $userRepo;
protected $client;
protected EntityManagerInterface $em;
protected UserRepository $userRepo;
protected \Symfony\Bundle\FrameworkBundle\KernelBrowser $client;
protected function setUp(): void
{

View file

@ -282,7 +282,7 @@ class AttachmentTest extends TestCase
* @param string $property - property on instance being modified
* @param mixed $value - new value of the property being modified
*/
public function setProtectedProperty($object, $property, $value): void
public function setProtectedProperty(object $object, string $property, $value): void
{
$reflection = new ReflectionClass($object);
$reflection_property = $reflection->getProperty($property);

View file

@ -33,12 +33,12 @@ use PHPUnit\Framework\TestCase;
*/
class AbstractStructuralDBElementTest extends TestCase
{
protected $root;
protected $child1;
protected $child2;
protected $child3;
protected $child1_1;
protected $child1_2;
protected AttachmentType $root;
protected AttachmentType $child1;
protected AttachmentType $child2;
protected AttachmentType $child3;
protected AttachmentType $child1_1;
protected AttachmentType $child1_2;
protected function setUp(): void
{

View file

@ -27,7 +27,7 @@ use PHPUnit\Framework\TestCase;
class BBCodeToMarkdownConverterTest extends TestCase
{
protected $converter;
protected BBCodeToMarkdownConverter $converter;
protected function setUp(): void
{

View file

@ -35,24 +35,24 @@ class ProjectBuildRequestTest extends TestCase
private MeasurementUnit $float_unit;
/** @var Project */
private $project1;
private Project $project1;
/** @var ProjectBOMEntry */
private $bom_entry1a;
private ProjectBOMEntry $bom_entry1a;
/** @var ProjectBOMEntry */
private $bom_entry1b;
private ProjectBOMEntry $bom_entry1b;
/** @var ProjectBOMEntry */
private $bom_entry1c;
private ProjectBOMEntry $bom_entry1c;
/** @var PartLot $lot1a */
private $lot1a;
/** @var PartLot $lot1b */
private $lot1b;
private $lot2;
private PartLot $lot2;
/** @var Part */
private $part1;
private Part $part1;
/** @var Part */
private $part2;
private Part $part2;
public function setUp(): void

View file

@ -30,11 +30,11 @@ class TreeViewNodeTest extends TestCase
/**
* @var TreeViewNode
*/
protected $node1;
protected TreeViewNode $node1;
/**
* @var TreeViewNode
*/
protected $node2;
protected TreeViewNode $node2;
protected function setUp(): void
{

View file

@ -29,8 +29,8 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class AttachmentPathResolverTest extends WebTestCase
{
protected $media_path;
protected $footprint_path;
protected string $media_path;
protected string $footprint_path;
protected $projectDir_orig;
protected $projectDir;
/**

View file

@ -27,7 +27,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class BuiltinAttachmentsFinderTest extends WebTestCase
{
protected static $mock_list = [
protected static array $mock_list = [
'%FOOTPRINTS%/test/test.jpg', '%FOOTPRINTS%/test/test.png', '%FOOTPRINTS%/123.jpg', '%FOOTPRINTS%/123.jpeg',
'%FOOTPRINTS_3D%/test.jpg', '%FOOTPRINTS_3D%/hallo.txt',
];

View file

@ -51,12 +51,12 @@ class LabelTextReplacerTest extends WebTestCase
/**
* @var LabelTextReplacer
*/
protected $service;
protected LabelTextReplacer $service;
/**
* @var Part
*/
protected $target;
protected Part $target;
protected function setUp(): void
{

View file

@ -53,9 +53,9 @@ class PartLotProviderTest extends WebTestCase
/**
* @var PartLotProvider
*/
protected $service;
protected PartLotProvider $service;
protected $target;
protected PartLot $target;
protected function setUp(): void
{

View file

@ -56,9 +56,9 @@ class PartProviderTest extends WebTestCase
/**
* @var PartProvider
*/
protected $service;
protected PartProvider $service;
protected $target;
protected Part $target;
/**
* @var \Doctrine\ORM\EntityManager

View file

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace App\Tests\Services\Misc;
use App\Services\Misc\FAIconGenerator;
use App\Tests\Services\AmountFormatter;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class FAIconGeneratorTest extends WebTestCase

View file

@ -27,24 +27,24 @@ class PartLotWithdrawAddHelperTest extends WebTestCase
protected $service;
/** @var Part */
private $part;
private Part $part;
/** @var Storelocation */
private $storageLocation;
private Storelocation $storageLocation;
/** @var Storelocation */
private $full_storageLocation;
private Storelocation $full_storageLocation;
/** @var PartLot */
private $partLot1;
private PartLot $partLot1;
/** @var PartLot */
private $partLot2;
private PartLot $partLot2;
/** @var PartLot */
private $partLot3;
private PartLot $partLot3;
/** @var PartLot */
private $fullLot;
private PartLot $fullLot;
/** @var PartLot */
private $lotWithUnknownInstock;
private PartLot $lotWithUnknownInstock;
protected function setUp(): void
{

View file

@ -24,7 +24,6 @@ namespace App\Tests\Services\UserSystem;
use App\Entity\UserSystem\Group;
use App\Entity\UserSystem\PermissionData;
use App\Entity\UserSystem\PermissionsEmbed;
use App\Entity\UserSystem\User;
use App\Services\UserSystem\PermissionManager;
use InvalidArgumentException;