Skip to content

Commit

Permalink
chore: fix PHPStan
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas committed Oct 8, 2021
1 parent da8b941 commit f417e08
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 22 deletions.
3 changes: 0 additions & 3 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ parameters:
path: tests/GraphQl/Type/TypesContainerTest.php

# Expected, due to PHP 8 attributes
- '#ReflectionProperty::getAttributes\(\)#'
- '#ReflectionMethod::getAttributes\(\)#'
- '#ReflectionClass<object>::getAttributes\(\)#'
- '#Constructor of class ApiPlatform\\Core\\Annotation\\ApiResource has an unused parameter#'
- '#Constructor of class ApiPlatform\\Core\\Annotation\\ApiProperty has an unused parameter#'

Expand Down
5 changes: 4 additions & 1 deletion src/Filter/Validator/ArrayItems.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,12 @@ private function getValue(string $name, array $filterDescription, array $queryPa

$collectionFormat = $filterDescription['swagger']['collectionFormat'] ?? 'csv';

return explode(self::getSeparator($collectionFormat), $value) ?: [];
return explode(self::getSeparator($collectionFormat), $value) ?: []; // @phpstan-ignore-line
}

/**
* @return non-empty-string
*/
private static function getSeparator(string $collectionFormat): string
{
switch ($collectionFormat) {
Expand Down
26 changes: 13 additions & 13 deletions tests/Fixtures/TestBundle/Document/EmbeddedDummy.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,22 @@
class EmbeddedDummy
{
/**
* @var int The id
* @var int|null The id
*
* @ODM\Id(strategy="INCREMENT", type="int")
*/
private $id;

/**
* @var string The dummy name
* @var string|null The dummy name
*
* @ODM\Field(type="string")
* @Groups({"embed"})
*/
private $name;

/**
* @var \DateTime A dummy date
* @var \DateTime|null A dummy date
*
* @ODM\Field(type="date")
* @Assert\DateTime
Expand All @@ -64,13 +64,13 @@ class EmbeddedDummy
public $embeddedDummy;

/**
* @var RelatedDummy A related dummy
* @var RelatedDummy|null A related dummy
*
* @ODM\ReferenceOne(targetDocument=RelatedDummy::class, storeAs="id")
*/
public $relatedDummy;

public static function staticMethod()
public static function staticMethod(): void
{
}

Expand All @@ -79,17 +79,17 @@ public function __construct()
$this->embeddedDummy = new EmbeddableDummy();
}

public function getId()
public function getId(): ?int
{
return $this->id;
}

public function getName(): string
public function getName(): ?string
{
return $this->name;
}

public function setName(string $name)
public function setName(string $name): void
{
$this->name = $name;
}
Expand All @@ -99,27 +99,27 @@ public function getEmbeddedDummy(): EmbeddableDummy
return $this->embeddedDummy;
}

public function setEmbeddedDummy(EmbeddableDummy $embeddedDummy)
public function setEmbeddedDummy(EmbeddableDummy $embeddedDummy): void
{
$this->embeddedDummy = $embeddedDummy;
}

public function getDummyDate(): \DateTime
public function getDummyDate(): ?\DateTime
{
return $this->dummyDate;
}

public function setDummyDate(\DateTime $dummyDate)
public function setDummyDate(\DateTime $dummyDate): void
{
$this->dummyDate = $dummyDate;
}

public function getRelatedDummy(): RelatedDummy
public function getRelatedDummy(): ?RelatedDummy
{
return $this->relatedDummy;
}

public function setRelatedDummy(RelatedDummy $relatedDummy)
public function setRelatedDummy(RelatedDummy $relatedDummy): void
{
$this->relatedDummy = $relatedDummy;
}
Expand Down
6 changes: 2 additions & 4 deletions tests/Fixtures/TestBundle/Document/Question.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,13 @@ public function getContent(): string
/**
* Get id.
*/
public function getId(): ?string
public function getId(): ?int
{
return $this->id;
}

/**
* Set answer.
*
* @param Answer $answer
*/
public function setAnswer(Answer $answer = null): self
{
Expand All @@ -82,7 +80,7 @@ public function setAnswer(Answer $answer = null): self
/**
* Get answer.
*/
public function getAnswer(): Answer
public function getAnswer(): ?Answer
{
return $this->answer;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class RelatedNormalizedDummy
private $name;

/**
* @var ArrayCollection Several Normalized dummies
* @var Collection Several Normalized dummies
*
* @ODM\ReferenceMany(targetDocument=CustomNormalizedDummy::class)
* @Groups({"related_output", "related_input"})
Expand Down

0 comments on commit f417e08

Please sign in to comment.