Fixed some more phpstan issues

This commit is contained in:
Jan Böhmer 2023-06-18 00:00:58 +02:00
parent 2f46fbfc7a
commit e8771ea118
77 changed files with 192 additions and 109 deletions

View file

@ -50,6 +50,8 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
* The class properties are split over various traits in directory PartTraits.
* Otherwise, this class would be too big, to be maintained.
* @see \App\Tests\Entity\Parts\PartTest
* @extends AttachmentContainingDBElement<PartAttachment>
* @template-use ParametersTrait<PartParameter>
*/
#[UniqueEntity(fields: ['ipn'], message: 'part.ipn.must_be_unique')]
#[ORM\Entity(repositoryClass: PartRepository::class)]

View file

@ -107,12 +107,12 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
protected bool $needs_refill = false;
/**
* @var Part The part that is stored in this lot
* @var Part|null The part that is stored in this lot
*/
#[Assert\NotNull]
#[ORM\ManyToOne(targetEntity: Part::class, inversedBy: 'partLots')]
#[ORM\JoinColumn(name: 'id_part', nullable: false, onDelete: 'CASCADE')]
protected Part $part;
protected ?Part $part = null;
/**
* @var User|null The owner of this part lot
@ -226,7 +226,7 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
/**
* Return the part that is stored in this part lot.
*/
public function getPart(): Part
public function getPart(): ?Part
{
return $this->part;
}

View file

@ -188,7 +188,7 @@ trait InstockTrait
$sum = 0;
foreach ($this->getPartLots() as $lot) {
//Don't use the in stock value, if it is unknown
if ($lot->isInstockUnknown() || $lot->isExpired() ?? false) {
if ($lot->isInstockUnknown() || ($lot->isExpired() ?? false)) {
continue;
}