Fixed PHPstan issues for level 5.

This commit is contained in:
Jan Böhmer 2020-02-01 19:42:28 +01:00
parent a9293b7ceb
commit da72f5b3ec
24 changed files with 87 additions and 49 deletions

View file

@ -79,7 +79,7 @@ abstract class Attachment extends NamedDBElement
public const ALLOWED_ELEMENT_CLASS = '';
/**
* @var string the original filename the file had, when the user uploaded it
* @var string|null the original filename the file had, when the user uploaded it
* @ORM\Column(type="string", nullable=true)
*/
protected $original_filename;

View file

@ -43,7 +43,7 @@ abstract class AttachmentContainingDBElement extends NamedDBElement
*
* Mapping is done in sub classes like part
*/
protected $attachments = [];
protected $attachments;
public function __construct()
{

View file

@ -58,7 +58,8 @@ use Symfony\Component\Serializer\Annotation\Groups;
*/
abstract class DBElement
{
/** @var int The Identification number for this part. This value is unique for the element in this table.
/** @var int|null The Identification number for this part. This value is unique for the element in this table.
* Null if the element is not saved to DB yet.
* @ORM\Column(type="integer")
* @ORM\Id()
* @ORM\GeneratedValue()

View file

@ -81,10 +81,11 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement
* We can not define the mapping here or we will get an exception. Unfortunately we have to do the mapping in the
* subclasses.
*
* @var StructuralDBElement[]
* @var StructuralDBElement[]|Collection
* @Groups({"include_children"})
*/
protected $children = [];
protected $children;
/**
* @var StructuralDBElement
* @NoneOfItsChildren()
@ -249,7 +250,7 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement
/**
* Get all sub elements of this element.
*
* @return Collection<static> all subelements as an array of objects (sorted by their full path)
* @return Collection<static>|iterable all subelements as an array of objects (sorted by their full path)
*/
public function getSubelements(): iterable
{
@ -257,7 +258,7 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement
}
/**
* @return Collection<static>
* @return Collection<static>|iterable
*/
public function getChildren(): iterable
{
@ -311,9 +312,17 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement
return $this;
}
public function setChildren(array $element): self
/**
* @param static[]|Collection $elements
* @return $this
*/
public function setChildren($elements): self
{
$this->children = $element;
if (!is_array($elements) && !$elements instanceof Collection) {
throw new InvalidArgumentException('$elements must be an array or Collection!');
}
$this->children = $elements;
return $this;
}

View file

@ -93,7 +93,7 @@ class Supplier extends Company
protected $default_currency;
/**
* @var float|null the shipping costs that have to be paid, when ordering via this supplier
* @var string|null the shipping costs that have to be paid, when ordering via this supplier
* @ORM\Column(name="shipping_costs", nullable=true, type="decimal", precision=11, scale=5)
* @Assert\PositiveOrZero()
*/

View file

@ -109,7 +109,7 @@ class Pricedetail extends DBElement
protected $manual_input = true;
/**
* @var Orderdetail
* @var Orderdetail|null
* @ORM\ManyToOne(targetEntity="Orderdetail", inversedBy="pricedetails")
* @ORM\JoinColumn(name="orderdetails_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
* @Assert\NotNull()

View file

@ -103,9 +103,10 @@ class U2FKey implements TwoFactorKeyInterface
return $this->keyHandle;
}
public function setKeyHandle($keyHandle): void
public function setKeyHandle($keyHandle): self
{
$this->keyHandle = $keyHandle;
return $this;
}
public function getPublicKey()
@ -113,9 +114,10 @@ class U2FKey implements TwoFactorKeyInterface
return $this->publicKey;
}
public function setPublicKey($publicKey): void
public function setPublicKey($publicKey): self
{
$this->publicKey = $publicKey;
return $this;
}
public function getCertificate()
@ -123,9 +125,10 @@ class U2FKey implements TwoFactorKeyInterface
return $this->certificate;
}
public function setCertificate($certificate): void
public function setCertificate($certificate): self
{
$this->certificate = $certificate;
return $this;
}
public function getCounter()
@ -133,9 +136,10 @@ class U2FKey implements TwoFactorKeyInterface
return $this->counter;
}
public function setCounter($counter): void
public function setCounter($counter): self
{
$this->counter = $counter;
return $this;
}
public function getName()
@ -143,9 +147,10 @@ class U2FKey implements TwoFactorKeyInterface
return $this->name;
}
public function setName($name): void
public function setName($name): self
{
$this->name = $name;
return $this;
}
/**
@ -173,7 +178,7 @@ class U2FKey implements TwoFactorKeyInterface
*
* @return $this
*/
public function setUser(TwoFactorInterface $new_user): self
public function setUser(User $new_user): self
{
$this->user = $new_user;

View file

@ -234,7 +234,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
*/
protected $attachments;
/** @var DateTime The time when the backup codes were generated
/** @var DateTime|null The time when the backup codes were generated
* @ORM\Column(type="datetime", nullable=true)
*/
protected $backupCodesGenerationDate;
@ -351,9 +351,9 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
/**
* @see UserInterface
*/
public function getSalt(): void
public function getSalt(): ?string
{
// not needed when using the "bcrypt" algorithm in security.yaml
return null;
}
/**