Fixed further inspection issues

This commit is contained in:
Jan Böhmer 2024-03-03 20:33:24 +01:00
parent 33e36f3d2b
commit 87533b6031
37 changed files with 46 additions and 71 deletions

View file

@ -74,10 +74,11 @@ abstract class BaseAdminController extends AbstractController
protected string $route_base = '';
protected string $attachment_class = '';
protected ?string $parameter_class = '';
/**
* @var EventDispatcher|EventDispatcherInterface
*/
protected $eventDispatcher;
protected EventDispatcher|EventDispatcherInterface $eventDispatcher;
public function __construct(protected TranslatorInterface $translator, protected UserPasswordHasherInterface $passwordEncoder,
protected AttachmentSubmitHandler $attachmentSubmitHandler,

View file

@ -31,7 +31,6 @@ use App\Services\Attachments\AttachmentSubmitHandler;
use App\Services\InfoProviderSystem\PartInfoRetriever;
use App\Services\InfoProviderSystem\ProviderRegistry;
use App\Services\LogSystem\EventCommentHelper;
use App\Services\Parts\PartFormHelper;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Bridge\Doctrine\Attribute\MapEntity;

View file

@ -22,7 +22,6 @@ declare(strict_types=1);
namespace App\Controller;
use App\DataTables\Column\LogEntryTargetColumn;
use App\DataTables\Filters\LogFilter;
use App\DataTables\LogDataTable;
use App\Entity\Base\AbstractDBElement;
@ -48,7 +47,7 @@ use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Attribute\Route;
#[Route(path: '/log')]
class LogController extends AbstractController

View file

@ -50,7 +50,6 @@ use DateTime;
use Doctrine\ORM\EntityManagerInterface;
use Exception;
use Omines\DataTablesBundle\DataTableFactory;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Bridge\Doctrine\Attribute\MapEntity;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\FormInterface;

View file

@ -73,6 +73,7 @@ class RedirectController extends AbstractController
* Check if mod_rewrite is available (URL rewriting is possible).
* If this is true, we can redirect to /en, otherwise we have to redirect to index.php/en.
* When the PHP is not used via Apache SAPI, we just assume that URL rewriting is available.
* @noinspection PhpUndefinedFunctionInspection
*/
public function checkIfModRewriteAvailable(): bool
{

View file

@ -60,10 +60,7 @@ use Symfony\Component\Validator\Constraints\Length;
#[Route(path: '/user')]
class UserSettingsController extends AbstractController
{
/**
* @var EventDispatcher|EventDispatcherInterface
*/
protected $eventDispatcher;
protected EventDispatcher|EventDispatcherInterface $eventDispatcher;
public function __construct(protected bool $demo_mode, EventDispatcherInterface $eventDispatcher)
{

View file

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace App\DataTables\Adapters;
use App\DataTables\Events\ORMPostQueryEvent;
use Doctrine\ORM\AbstractQuery;
use Doctrine\ORM\QueryBuilder;
use Omines\DataTablesBundle\Adapter\AdapterQuery;
@ -45,7 +44,7 @@ class FetchResultsAtOnceORMAdapter extends ORMAdapter
$state = $query->getState();
// Apply definitive view state for current 'page' of the table
foreach ($state->getOrderBy() as list($column, $direction)) {
foreach ($state->getOrderBy() as [$column, $direction]) {
/** @var AbstractColumn $column */
if ($column->isOrderable()) {
$builder->addOrderBy($column->getOrderField(), $direction);

View file

@ -157,7 +157,7 @@ class TwoStepORMAdapter extends ORMAdapter
$state = $query->getState();
// Apply definitive view state for current 'page' of the table
foreach ($state->getOrderBy() as list($column, $direction)) {
foreach ($state->getOrderBy() as [$column, $direction]) {
/** @var AbstractColumn $column */
if ($column->isOrderable()) {
$builder->addOrderBy($column->getOrderField(), $direction);

View file

@ -42,7 +42,7 @@ class EntityColumn extends AbstractColumn
* @param mixed $value The single value of the column
* @return mixed
*/
public function normalize($value): mixed
public function normalize(mixed $value): mixed
{
/** @var AbstractNamedDBElement $value */
return $value;

View file

@ -37,7 +37,7 @@ class MarkdownColumn extends AbstractColumn
* @param mixed $value The single value of the column
* @return string
*/
public function normalize($value): string
public function normalize(mixed $value): string
{
return $this->markdown->markForRendering($value, true);
}

View file

@ -43,7 +43,7 @@ class PartAttachmentsColumn extends AbstractColumn
* @param mixed $value The single value of the column
* @return mixed
*/
public function normalize($value): mixed
public function normalize(mixed $value): mixed
{
return $value;
}

View file

@ -37,7 +37,7 @@ class TagsColumn extends AbstractColumn
* @param mixed $value The single value of the column
* @return mixed
*/
public function normalize($value): mixed
public function normalize(mixed $value): mixed
{
if (empty($value)) {
return [];

View file

@ -40,14 +40,14 @@ class EntityConstraint extends AbstractConstraint
* @param class-string<T> $class
* @param string $property
* @param string|null $identifier
* @param null|T $value
* @param T|null $value
* @param string|null $operator
*/
public function __construct(protected ?NodesListBuilder $nodesListBuilder,
protected string $class,
string $property,
string $identifier = null,
protected $value = null,
protected ?AbstractDBElement $value = null,
protected ?string $operator = null)
{
if (!$nodesListBuilder instanceof NodesListBuilder && $this->isStructural()) {

View file

@ -24,7 +24,6 @@ namespace App\Entity\Attachments;
use App\Entity\Parts\Part;
use App\Serializer\APIPlatform\OverrideClassDenormalizer;
use App\Serializer\TypeOverride\TypeOverridableSerializer;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Serializer\Attribute\Context;

View file

@ -37,7 +37,6 @@ use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Post;
use ApiPlatform\Serializer\Filter\PropertyFilter;
use App\ApiPlatform\Filter\LikeFilter;
use App\Repository\PartLotRepository;
use Doctrine\DBAL\Types\Types;
use App\Entity\Base\AbstractDBElement;
use App\Entity\Base\TimestampTrait;

View file

@ -75,6 +75,7 @@ class ConsoleEnsureWebserverUserListener
}
}
/** @noinspection PhpUndefinedFunctionInspection */
private function isRunningAsRoot(): bool
{
//If we are on windows, we can't run as root
@ -96,6 +97,7 @@ class ConsoleEnsureWebserverUserListener
* Determines the username of the user who started the current script if possible.
* Returns null if the username could not be determined.
* @return string|null
* @noinspection PhpUndefinedFunctionInspection
*/
private function getRunningUser(): ?string
{
@ -126,6 +128,7 @@ class ConsoleEnsureWebserverUserListener
if (PHP_OS_FAMILY === 'Windows') {
//If we have the COM extension available, we can use it to determine the owner
if (extension_loaded('com_dotnet')) {
/** @noinspection PhpUndefinedClassInspection */
$su = new \COM("ADsSecurityUtility"); // Call interface
//@phpstan-ignore-next-line
$securityInfo = $su->GetSecurityDescriptor($path_to_check, 1, 1); // Call method

View file

@ -47,7 +47,7 @@ final class PermissionsMapper implements DataMapperInterface
* @param mixed $viewData View data of the compound form being initialized
* @param Traversable $forms A list of {@link FormInterface} instances
*/
public function mapDataToForms($viewData, \Traversable $forms): void
public function mapDataToForms(mixed $viewData, \Traversable $forms): void
{
foreach ($forms as $form) {
if ($this->inherit) {
@ -94,7 +94,7 @@ final class PermissionsMapper implements DataMapperInterface
* @param mixed $viewData The compound form's view data that get mapped
* its children model data
*/
public function mapFormsToData(\Traversable $forms, &$viewData): void
public function mapFormsToData(\Traversable $forms, mixed &$viewData): void
{
if ($this->inherit) {
throw new RuntimeException('The permission type is readonly when it is showing read only data!');

View file

@ -153,7 +153,7 @@ final class SIUnitType extends AbstractType implements DataMapperInterface
*
* @throws Exception\UnexpectedTypeException if the type of the data parameter is not supported
*/
public function mapDataToForms($viewData, \Traversable $forms): void
public function mapDataToForms(mixed $viewData, \Traversable $forms): void
{
$forms = iterator_to_array($forms);
@ -204,7 +204,7 @@ final class SIUnitType extends AbstractType implements DataMapperInterface
*
* @throws Exception\UnexpectedTypeException if the type of the data parameter is not supported
*/
public function mapFormsToData(\Traversable $forms, &$viewData): void
public function mapFormsToData(\Traversable $forms, mixed &$viewData): void
{
//Convert both fields to a single float value.

View file

@ -101,7 +101,7 @@ final class TriStateCheckboxType extends AbstractType implements DataTransformer
*
* @throws TransformationFailedException when the transformation fails
*/
public function transform($value)
public function transform(mixed $value)
{
if (true === $value) {
return 'true';
@ -145,7 +145,7 @@ final class TriStateCheckboxType extends AbstractType implements DataTransformer
*
* @throws TransformationFailedException when the transformation fails
*/
public function reverseTransform($value)
public function reverseTransform(mixed $value)
{
return match ($value) {
'true' => true,

View file

@ -165,7 +165,7 @@ class LogEntryRepository extends DBElementRepository
* @param int|null $limit
* @param int|null $offset
*/
public function getLogsOrderedByTimestamp(string $order = 'DESC', $limit = null, $offset = null): array
public function getLogsOrderedByTimestamp(string $order = 'DESC', int $limit = null, int $offset = null): array
{
return $this->findBy([], ['timestamp' => $order], $limit, $offset);
}

View file

@ -135,7 +135,7 @@ final class AttachmentVoter extends Voter
*
* @return bool True if the attribute and subject are supported, false otherwise
*/
protected function supports(string $attribute, $subject): bool
protected function supports(string $attribute, mixed $subject): bool
{
if (is_a($subject, Attachment::class, true)) {
//These are the allowed attributes

View file

@ -57,7 +57,7 @@ final class GroupVoter extends Voter
*
* @return bool True if the attribute and subject are supported, false otherwise
*/
protected function supports(string $attribute, $subject): bool
protected function supports(string $attribute, mixed $subject): bool
{
if (is_a($subject, Group::class, true)) {
return $this->helper->isValidOperation('groups', $attribute);

View file

@ -62,7 +62,7 @@ final class PermissionVoter extends Voter
*
* @return bool True if the attribute and subject are supported, false otherwise
*/
protected function supports(string $attribute, $subject): bool
protected function supports(string $attribute, mixed $subject): bool
{
//Check if the attribute has the form @permission.operation
if (preg_match('#^@\\w+\\.\\w+$#', $attribute)) {

View file

@ -68,7 +68,7 @@ final class StructureVoter extends Voter
*
* @return bool True if the attribute and subject are supported, false otherwise
*/
protected function supports(string $attribute, $subject): bool
protected function supports(string $attribute, mixed $subject): bool
{
if (is_object($subject) || is_string($subject)) {
$permission_name = $this->instanceToPermissionName($subject);
@ -91,7 +91,7 @@ final class StructureVoter extends Voter
*
* @return string|null the name of the permission for the subject's type or null, if the subject is not supported
*/
protected function instanceToPermissionName($subject): ?string
protected function instanceToPermissionName(object|string $subject): ?string
{
$class_name = is_string($subject) ? $subject : $subject::class;

View file

@ -47,7 +47,7 @@ final class UserVoter extends Voter
*
* @return bool True if the attribute and subject are supported, false otherwise
*/
protected function supports(string $attribute, $subject): bool
protected function supports(string $attribute, mixed $subject): bool
{
if (is_a($subject, User::class, true)) {
return in_array($attribute,

View file

@ -175,8 +175,7 @@ class DigikeyProvider implements InfoProviderInterface
null => null,
'Active' => ManufacturingStatus::ACTIVE,
'Obsolete' => ManufacturingStatus::DISCONTINUED,
'Discontinued at Digi-Key' => ManufacturingStatus::EOL,
'Last Time Buy' => ManufacturingStatus::EOL,
'Discontinued at Digi-Key', 'Last Time Buy' => ManufacturingStatus::EOL,
'Not For New Designs' => ManufacturingStatus::NRFND,
'Preliminary' => ManufacturingStatus::ANNOUNCED,
default => ManufacturingStatus::NOT_SET,

View file

@ -190,41 +190,20 @@ class Element14Provider implements InfoProviderInterface
{
//Decide based on the shop ID
return match ($this->store_id) {
'bg.farnell.com' => 'EUR',
'bg.farnell.com', 'at.farnell.com', 'si.farnell.com', 'sk.farnell.com', 'ro.farnell.com', 'pt.farnell.com', 'nl.farnell.com', 'be.farnell.com', 'lv.farnell.com', 'lt.farnell.com', 'it.farnell.com', 'fr.farnell.com', 'fi.farnell.com', 'ee.farnell.com', 'es.farnell.com', 'ie.farnell.com', 'cpcireland.farnell.com', 'de.farnell.com' => 'EUR',
'cz.farnell.com' => 'CZK',
'dk.farnell.com' => 'DKK',
'at.farnell.com' => 'EUR',
'ch.farnell.com' => 'CHF',
'de.farnell.com' => 'EUR',
'cpc.farnell.com' => 'GBP',
'cpcireland.farnell.com' => 'EUR',
'export.farnell.com' => 'GBP',
'onecall.farnell.com' => 'GBP',
'ie.farnell.com' => 'EUR',
'il.farnell.com' => 'USD',
'uk.farnell.com' => 'GBP',
'es.farnell.com' => 'EUR',
'ee.farnell.com' => 'EUR',
'fi.farnell.com' => 'EUR',
'fr.farnell.com' => 'EUR',
'cpc.farnell.com', 'uk.farnell.com', 'onecall.farnell.com', 'export.farnell.com' => 'GBP',
'il.farnell.com', 'www.newark.com' => 'USD',
'hu.farnell.com' => 'HUF',
'it.farnell.com' => 'EUR',
'lt.farnell.com' => 'EUR',
'lv.farnell.com' => 'EUR',
'be.farnell.com' => 'EUR',
'nl.farnell.com' => 'EUR',
'no.farnell.com' => 'NOK',
'pl.farnell.com' => 'PLN',
'pt.farnell.com' => 'EUR',
'ro.farnell.com' => 'EUR',
'ru.farnell.com' => 'RUB',
'sk.farnell.com' => 'EUR',
'si.farnell.com' => 'EUR',
'se.farnell.com' => 'SEK',
'tr.farnell.com' => 'TRY',
'canada.newark.com' => 'CAD',
'mexico.newark.com' => 'MXN',
'www.newark.com' => 'USD',
'cn.element14.com' => 'CNY',
'au.element14.com' => 'AUD',
'nz.element14.com' => 'NZD',

View file

@ -296,9 +296,8 @@ class MouserProvider implements InfoProviderInterface
null => null,
"New Product" => ManufacturingStatus::ANNOUNCED,
"Not Recommended for New Designs" => ManufacturingStatus::NRFND,
"Factory Special Order" => ManufacturingStatus::DISCONTINUED,
"Factory Special Order", "Obsolete" => ManufacturingStatus::DISCONTINUED,
"End of Life" => ManufacturingStatus::EOL,
"Obsolete" => ManufacturingStatus::DISCONTINUED,
default => ManufacturingStatus::ACTIVE,
};
}

View file

@ -36,6 +36,7 @@ class ConsoleInfoHelper
/**
* Returns the username of the user who started the current script if possible.
* @return string|null the username of the user who started the current script if possible, null otherwise
* @noinspection PhpUndefinedFunctionInspection
*/
public function getCLIUser(): ?string
{

View file

@ -69,6 +69,7 @@ final class TwigCoreExtension extends AbstractExtension
throw new \InvalidArgumentException(sprintf('The given class "%s" is not an enum!', $enum_class));
}
/** @noinspection PhpUndefinedMethodInspection */
return ($enum_class)::cases();
}

View file

@ -44,7 +44,7 @@ class NoLockoutValidator extends ConstraintValidator
* @param mixed $value The value that should be validated
* @param Constraint $constraint The constraint for the validation
*/
public function validate($value, Constraint $constraint): void
public function validate(mixed $value, Constraint $constraint): void
{
if (!$constraint instanceof NoLockout) {
throw new UnexpectedTypeException($constraint, NoLockout::class);

View file

@ -39,7 +39,7 @@ class NoneOfItsChildrenValidator extends ConstraintValidator
* @param mixed $value The value that should be validated
* @param Constraint $constraint The constraint for the validation
*/
public function validate($value, Constraint $constraint): void
public function validate(mixed $value, Constraint $constraint): void
{
if (!$constraint instanceof NoneOfItsChildren) {
throw new UnexpectedTypeException($constraint, NoneOfItsChildren::class);

View file

@ -31,5 +31,5 @@ use Symfony\Component\Validator\Constraint;
#[\Attribute(\Attribute::TARGET_PROPERTY)]
class Selectable extends Constraint
{
public $message = 'validator.isSelectable';
public string $message = 'validator.isSelectable';
}

View file

@ -39,7 +39,7 @@ class SelectableValidator extends ConstraintValidator
* @param mixed $value The value that should be validated
* @param Constraint $constraint The constraint for the validation
*/
public function validate($value, Constraint $constraint): void
public function validate(mixed $value, Constraint $constraint): void
{
if (!$constraint instanceof Selectable) {
throw new UnexpectedTypeException($constraint, Selectable::class);

View file

@ -42,7 +42,7 @@ class ValidFileFilterValidator extends ConstraintValidator
* @param mixed $value The value that should be validated
* @param Constraint $constraint The constraint for the validation
*/
public function validate($value, Constraint $constraint): void
public function validate(mixed $value, Constraint $constraint): void
{
if (!$constraint instanceof ValidFileFilter) {
throw new UnexpectedTypeException($constraint, ValidFileFilter::class);

View file

@ -42,7 +42,7 @@ class ValidPartLotValidator extends ConstraintValidator
* @param mixed $value The value that should be validated
* @param Constraint $constraint The constraint for the validation
*/
public function validate($value, Constraint $constraint): void
public function validate(mixed $value, Constraint $constraint): void
{
if (!$constraint instanceof ValidPartLot) {
throw new UnexpectedTypeException($constraint, ValidPartLot::class);

View file

@ -46,7 +46,7 @@ class ValidPermissionValidator extends ConstraintValidator
* @param mixed $value The value that should be validated
* @param Constraint $constraint The constraint for the validation
*/
public function validate($value, Constraint $constraint): void
public function validate(mixed $value, Constraint $constraint): void
{
if (!$constraint instanceof ValidPermission) {
throw new UnexpectedTypeException($constraint, ValidPermission::class);