mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-08-30 22:59:52 +02:00
Fixed some issues detected by PHPstan.
This commit is contained in:
parent
f2ff77a8b3
commit
dd1f806c4e
30 changed files with 310 additions and 45 deletions
|
@ -65,7 +65,7 @@ class CleanAttachmentsCommand extends Command
|
|||
' These files are not needed and can eventually deleted.');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): void
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
|
||||
|
@ -107,7 +107,7 @@ class CleanAttachmentsCommand extends Command
|
|||
|
||||
if (! $continue) {
|
||||
//We are finished here, when no files should be deleted
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//Delete the files
|
||||
|
@ -119,6 +119,8 @@ class CleanAttachmentsCommand extends Command
|
|||
} else {
|
||||
$io->success('No abandoned files found.');
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -105,7 +105,7 @@ class ConvertBBCodeCommand extends Command
|
|||
];
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): void
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
$targets = $this->getTargetsLists();
|
||||
|
@ -168,5 +168,7 @@ class ConvertBBCodeCommand extends Command
|
|||
$this->em->flush();
|
||||
$io->success('Changes saved to DB successfully!');
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,19 +57,19 @@ class SetPasswordCommand extends Command
|
|||
;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): void
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
$user_name = $input->getArgument('user');
|
||||
|
||||
/** @var User */
|
||||
/** @var User[] $users */
|
||||
$users = $this->entityManager->getRepository(User::class)->findBy(['name' => $user_name]);
|
||||
$user = $users[0];
|
||||
|
||||
if (null === $user) {
|
||||
$io->error(sprintf('No user with the given username %s found in the database!', $user_name));
|
||||
|
||||
return;
|
||||
return 1;
|
||||
}
|
||||
|
||||
$io->note('User found!');
|
||||
|
@ -79,7 +79,7 @@ class SetPasswordCommand extends Command
|
|||
$user->getFullName(true), $user->getID()));
|
||||
|
||||
if (! $proceed) {
|
||||
return;
|
||||
return 1;
|
||||
}
|
||||
|
||||
$success = false;
|
||||
|
@ -106,5 +106,6 @@ class SetPasswordCommand extends Command
|
|||
$this->entityManager->flush();
|
||||
|
||||
$io->success('Password was set successful! You can now log in using the new password.');
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,13 +64,13 @@ class ShowEventLogCommand extends Command
|
|||
|
||||
$onePage = $input->getOption('onePage');
|
||||
|
||||
$desc = $input->getOption('oldest_first');
|
||||
$limit = $input->getOption('count');
|
||||
$page = $input->getOption('page');
|
||||
$desc = (bool) $input->getOption('oldest_first');
|
||||
$limit = (int) $input->getOption('count');
|
||||
$page = (int) $input->getOption('page');
|
||||
$showExtra = $input->getOption('showExtra');
|
||||
|
||||
$total_count = $this->repo->count([]);
|
||||
$max_page = ceil($total_count / $limit);
|
||||
$max_page = (int) ceil($total_count / $limit);
|
||||
|
||||
if ($page > $max_page) {
|
||||
$io->error("There is no page ${page}! The maximum page is ${max_page}.");
|
||||
|
|
|
@ -68,7 +68,7 @@ class UpdateExchangeRatesCommand extends Command
|
|||
null);
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): void
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
|
||||
|
@ -76,7 +76,7 @@ class UpdateExchangeRatesCommand extends Command
|
|||
if (3 !== strlen($this->base_current)) {
|
||||
$io->error('Choosen Base current is not valid. Check your settings!');
|
||||
|
||||
return;
|
||||
return 1;
|
||||
}
|
||||
|
||||
$io->note('Update currency exchange rates with base currency: '.$this->base_current);
|
||||
|
@ -121,5 +121,6 @@ class UpdateExchangeRatesCommand extends Command
|
|||
$this->em->flush();
|
||||
|
||||
$io->success(sprintf('%d (of %d) currency exchange rates were updated.', $success_counter, count($candidates)));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ class ManufacturerController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/{id}/export", name="manufacturer_export")
|
||||
*
|
||||
* @param Supplier $entity
|
||||
* @param Manufacturer $entity
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
|
|
|
@ -87,7 +87,7 @@ class StorelocationController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/{id}/export", name="store_location_export")
|
||||
*
|
||||
* @param AttachmentType $entity
|
||||
* @param Storelocation $entity
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
|
|
|
@ -119,7 +119,7 @@ class UserController extends AdminPages\BaseAdminController
|
|||
/**
|
||||
* @Route("/{id}/export", name="user_export")
|
||||
*
|
||||
* @param AttachmentType $entity
|
||||
* @param User $entity
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
|
@ -167,7 +167,7 @@ class UserController extends AdminPages\BaseAdminController
|
|||
* Get either a Gravatar URL or complete image tag for a specified email address.
|
||||
*
|
||||
* @param string $email The email address
|
||||
* @param string $s Size in pixels, defaults to 80px [ 1 - 2048 ]
|
||||
* @param int $s Size in pixels, defaults to 80px [ 1 - 2048 ]
|
||||
* @param string $d Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ]
|
||||
* @param string $r Maximum rating (inclusive) [ g | pg | r | x ]
|
||||
* @param bool $img True to return a complete IMG tag False for just the URL
|
||||
|
|
|
@ -70,7 +70,7 @@ class FetchJoinORMAdapter extends ORMAdapter
|
|||
|
||||
$query = $builder->getQuery();
|
||||
$event = new ORMAdapterQueryEvent($query);
|
||||
$state->getDataTable()->getEventDispatcher()->dispatch($event, ORMAdapterEvents::PRE_QUERY);
|
||||
$state->getDataTable()->getEventDispatcher()->dispatch($event);
|
||||
|
||||
//Use Doctrine paginator for result iteration
|
||||
$paginator = new Paginator($query);
|
||||
|
|
|
@ -22,6 +22,7 @@ use Omines\DataTablesBundle\Adapter\Doctrine\Event\ORMAdapterQueryEvent;
|
|||
use Omines\DataTablesBundle\Adapter\Doctrine\ORM\AutomaticQueryBuilder;
|
||||
use Omines\DataTablesBundle\Adapter\Doctrine\ORM\QueryBuilderProcessorInterface;
|
||||
use Omines\DataTablesBundle\Adapter\Doctrine\ORM\SearchCriteriaProvider;
|
||||
use Omines\DataTablesBundle\Adapter\Doctrine\ORMAdapterEvents;
|
||||
use Omines\DataTablesBundle\Column\AbstractColumn;
|
||||
use Omines\DataTablesBundle\DataTableState;
|
||||
use Omines\DataTablesBundle\Exception\InvalidConfigurationException;
|
||||
|
|
|
@ -37,7 +37,7 @@ abstract class AttachmentContainingDBElement extends NamedDBElement
|
|||
use MasterAttachmentTrait;
|
||||
|
||||
/**
|
||||
* @var Attachment[]
|
||||
* @var Attachment[]|Collection
|
||||
* //TODO
|
||||
* //@ORM\OneToMany(targetEntity="Attachment", mappedBy="element")
|
||||
*
|
||||
|
|
|
@ -54,7 +54,7 @@ class DatabaseUpdatedLogEntry extends AbstractLogEntry
|
|||
/**
|
||||
* Gets the database version before update.
|
||||
*
|
||||
* @return int
|
||||
* @return string
|
||||
*/
|
||||
public function getOldVersion(): string
|
||||
{
|
||||
|
@ -64,7 +64,7 @@ class DatabaseUpdatedLogEntry extends AbstractLogEntry
|
|||
/**
|
||||
* Gets the (target) database version after update.
|
||||
*
|
||||
* @return int
|
||||
* @return string
|
||||
*/
|
||||
public function getNewVersion(): string
|
||||
{
|
||||
|
|
|
@ -233,7 +233,7 @@ class PartLot extends DBElement
|
|||
/**
|
||||
* Sets the part that is stored in this part lot.
|
||||
*
|
||||
* @param Part|InstockTrait $part
|
||||
* @param Part $part
|
||||
*
|
||||
* @return PartLot
|
||||
*/
|
||||
|
|
|
@ -126,6 +126,7 @@ trait OrderTrait
|
|||
* The orderdetail is assigned to this part.
|
||||
*
|
||||
* @param Orderdetail $orderdetail the orderdetail that should be added
|
||||
* @return $this
|
||||
*/
|
||||
public function addOrderdetail(Orderdetail $orderdetail): self
|
||||
{
|
||||
|
@ -137,8 +138,8 @@ trait OrderTrait
|
|||
|
||||
/**
|
||||
* Removes the given orderdetail from the list of orderdetails.
|
||||
*
|
||||
* @return OrderTrait
|
||||
* @param Orderdetail $orderdetail
|
||||
* @return $this
|
||||
*/
|
||||
public function removeOrderdetail(Orderdetail $orderdetail): self
|
||||
{
|
||||
|
@ -158,6 +159,7 @@ trait OrderTrait
|
|||
* (if the part has exactly one orderdetails,
|
||||
* set this orderdetails as order orderdetails.
|
||||
* Otherwise, set "no order orderdetails")
|
||||
* @return $this
|
||||
*/
|
||||
public function setManualOrder(bool $new_manual_order, int $new_order_quantity = 1, ?Orderdetail $new_order_orderdetail = null): self
|
||||
{
|
||||
|
|
|
@ -245,7 +245,7 @@ class Orderdetail extends DBElement
|
|||
*
|
||||
* @return Pricedetail|null: the price as a bcmath string. Null if there are no orderdetails for the given quantity
|
||||
*/
|
||||
public function findPriceForQty(float $quantity = 1): ?Pricedetail
|
||||
public function findPriceForQty(float $quantity = 1.0): ?Pricedetail
|
||||
{
|
||||
if ($quantity <= 0) {
|
||||
return null;
|
||||
|
|
|
@ -69,6 +69,10 @@ class CurrencyEntityType extends StructuralEntityType
|
|||
{
|
||||
//Similar to StructuralEntityType, but we use the currency symbol instead if available
|
||||
|
||||
if (!$choice instanceof Currency) {
|
||||
throw new \InvalidArgumentException('$choice must be an currency object!');
|
||||
}
|
||||
|
||||
/** @var StructuralDBElement|null $parent */
|
||||
$parent = $this->options['subentities_of'];
|
||||
|
||||
|
|
|
@ -38,7 +38,6 @@ use Doctrine\ORM\Mapping\PreUpdate;
|
|||
use function get_class;
|
||||
use InvalidArgumentException;
|
||||
use ReflectionClass;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
/**
|
||||
|
@ -59,7 +58,7 @@ class ElementPermissionListener
|
|||
|
||||
protected $perm_cache;
|
||||
|
||||
public function __construct(Security $security, Reader $reader, EntityManagerInterface $em, KernelInterface $kernel)
|
||||
public function __construct(Security $security, Reader $reader, EntityManagerInterface $em)
|
||||
{
|
||||
$this->security = $security;
|
||||
$this->reader = $reader;
|
||||
|
|
|
@ -34,14 +34,17 @@ class AttachmentVoter extends ExtendedVoter
|
|||
* Similar to voteOnAttribute, but checking for the anonymous user is already done.
|
||||
* The current user (or the anonymous user) is passed by $user.
|
||||
*
|
||||
* @param $attribute
|
||||
* @param $subject
|
||||
* @param string $attribute
|
||||
* @param mixed $subject
|
||||
* @return bool
|
||||
*/
|
||||
protected function voteOnUser($attribute, $subject, User $user): bool
|
||||
{
|
||||
if ($subject instanceof Attachment) {
|
||||
return $this->resolver->inherit($user, 'parts_attachments', $attribute) ?? false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -72,8 +72,9 @@ abstract class ExtendedVoter extends Voter
|
|||
* Similar to voteOnAttribute, but checking for the anonymous user is already done.
|
||||
* The current user (or the anonymous user) is passed by $user.
|
||||
*
|
||||
* @param $attribute
|
||||
* @param $subject
|
||||
* @param string $attribute
|
||||
* @param mixed $subject
|
||||
* @return bool
|
||||
*/
|
||||
abstract protected function voteOnUser($attribute, $subject, User $user): bool;
|
||||
}
|
||||
|
|
|
@ -33,8 +33,9 @@ class GroupVoter extends ExtendedVoter
|
|||
* Similar to voteOnAttribute, but checking for the anonymous user is already done.
|
||||
* The current user (or the anonymous user) is passed by $user.
|
||||
*
|
||||
* @param $attribute
|
||||
* @param $subject
|
||||
* @param string $attribute
|
||||
* @param mixed $subject
|
||||
* @return bool
|
||||
*/
|
||||
protected function voteOnUser($attribute, $subject, User $user): bool
|
||||
{
|
||||
|
|
|
@ -37,8 +37,8 @@ class PermissionVoter extends ExtendedVoter
|
|||
* Similar to voteOnAttribute, but checking for the anonymous user is already done.
|
||||
* The current user (or the anonymous user) is passed by $user.
|
||||
*
|
||||
* @param $attribute
|
||||
* @param $subject
|
||||
* @param string $attribute
|
||||
* @param mixed $subject
|
||||
*/
|
||||
protected function voteOnUser($attribute, $subject, User $user): bool
|
||||
{
|
||||
|
|
|
@ -54,6 +54,7 @@ class StructureVoter extends ExtendedVoter
|
|||
//If permission name is null, then the subject is not supported
|
||||
return (null !== $permission_name) && $this->resolver->isValidOperation($permission_name, $attribute);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,8 +95,9 @@ class StructureVoter extends ExtendedVoter
|
|||
* Similar to voteOnAttribute, but checking for the anonymous user is already done.
|
||||
* The current user (or the anonymous user) is passed by $user.
|
||||
*
|
||||
* @param $attribute
|
||||
* @param $subject
|
||||
* @param string $attribute
|
||||
* @param mixed $subject
|
||||
* @return bool
|
||||
*/
|
||||
protected function voteOnUser($attribute, $subject, User $user): bool
|
||||
{
|
||||
|
|
|
@ -54,8 +54,9 @@ class UserVoter extends ExtendedVoter
|
|||
* Similar to voteOnAttribute, but checking for the anonymous user is already done.
|
||||
* The current user (or the anonymous user) is passed by $user.
|
||||
*
|
||||
* @param $attribute
|
||||
* @param $subject
|
||||
* @param string $attribute
|
||||
* @param mixed $subject
|
||||
* @return bool
|
||||
*/
|
||||
protected function voteOnUser($attribute, $subject, User $user): bool
|
||||
{
|
||||
|
|
|
@ -36,6 +36,7 @@ use App\Entity\Parts\MeasurementUnit;
|
|||
use App\Entity\Parts\Part;
|
||||
use App\Entity\Parts\PartLot;
|
||||
use App\Entity\Parts\Storelocation;
|
||||
use App\Entity\Parts\Supplier;
|
||||
use App\Entity\PriceInformations\Currency;
|
||||
use App\Entity\PriceInformations\Orderdetail;
|
||||
use App\Entity\PriceInformations\Pricedetail;
|
||||
|
@ -43,7 +44,6 @@ use App\Entity\UserSystem\Group;
|
|||
use App\Entity\UserSystem\User;
|
||||
use App\Exceptions\EntityNotSupportedException;
|
||||
use function get_class;
|
||||
use Proxies\__CG__\App\Entity\Parts\Supplier;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
class ElementTypeNameGenerator
|
||||
|
|
|
@ -133,7 +133,7 @@ class EntityURLGenerator
|
|||
/**
|
||||
* Generates an URL to a page, where info about this entity can be viewed.
|
||||
*
|
||||
* @param mixed $entity The entity for which the info should be generated
|
||||
* @param DBElement $entity The entity for which the info should be generated
|
||||
*
|
||||
* @return string The URL to the info page
|
||||
*
|
||||
|
@ -223,7 +223,7 @@ class EntityURLGenerator
|
|||
* Generates an URL to a page, where a new entity can be created, that has the same informations as the
|
||||
* given entity (element cloning).
|
||||
*
|
||||
* @param mixed $entity The entity for which the link should be generated
|
||||
* @param DBElement $entity The entity for which the link should be generated
|
||||
*
|
||||
* @return string the URL to the page
|
||||
*
|
||||
|
@ -241,7 +241,7 @@ class EntityURLGenerator
|
|||
/**
|
||||
* Generates an URL to a page, where all parts are listed, which are contained in the given element.
|
||||
*
|
||||
* @param mixed $entity The entity for which the link should be generated
|
||||
* @param DBElement $entity The entity for which the link should be generated
|
||||
*
|
||||
* @return string the URL to the page
|
||||
*
|
||||
|
|
|
@ -44,7 +44,7 @@ class PermissionResolver
|
|||
/**
|
||||
* PermissionResolver constructor.
|
||||
*/
|
||||
public function __construct(ParameterBagInterface $params, ContainerInterface $container)
|
||||
public function __construct(ContainerInterface $container)
|
||||
{
|
||||
$cache_dir = $container->getParameter('kernel.cache_dir');
|
||||
//Here the cached structure will be saved.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue