Bump PHPStan to level 9
This commit is contained in:
parent
9abfb29af7
commit
f21bb125c5
6 changed files with 24 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
||||||
parameters:
|
parameters:
|
||||||
level: 5
|
level: 9
|
||||||
paths:
|
paths:
|
||||||
- src
|
- src
|
||||||
- tests
|
- tests
|
||||||
|
|
|
@ -8,7 +8,7 @@ use Twig\TwigFunction;
|
||||||
|
|
||||||
class ExperienceTwigExtension extends AbstractExtension
|
class ExperienceTwigExtension extends AbstractExtension
|
||||||
{
|
{
|
||||||
private static $startYear = 2007;
|
private static int $startYear = 2007;
|
||||||
|
|
||||||
public function getFunctions(): array
|
public function getFunctions(): array
|
||||||
{
|
{
|
||||||
|
@ -24,6 +24,6 @@ class ExperienceTwigExtension extends AbstractExtension
|
||||||
|
|
||||||
public function getYearsOfExperience(): int
|
public function getYearsOfExperience(): int
|
||||||
{
|
{
|
||||||
return (new \DateTimeImmutable())->format('Y') - self::$startYear;
|
return (int) (new \DateTimeImmutable())->format('Y') - self::$startYear;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ use Iterator;
|
||||||
use IteratorAggregate;
|
use IteratorAggregate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @implements IteratorAggregate<TItem>
|
||||||
* @template TItem
|
* @template TItem
|
||||||
*/
|
*/
|
||||||
class Collection implements Countable, IteratorAggregate
|
class Collection implements Countable, IteratorAggregate
|
||||||
|
@ -26,6 +27,9 @@ class Collection implements Countable, IteratorAggregate
|
||||||
return count($this->items);
|
return count($this->items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return self<TItem>
|
||||||
|
*/
|
||||||
public function filter(callable $callback): self
|
public function filter(callable $callback): self
|
||||||
{
|
{
|
||||||
return new static(
|
return new static(
|
||||||
|
|
|
@ -7,8 +7,14 @@ namespace App\Presentation\Collection;
|
||||||
use DateTimeImmutable;
|
use DateTimeImmutable;
|
||||||
use Sculpin\Contrib\ProxySourceCollection\ProxySourceItem;
|
use Sculpin\Contrib\ProxySourceCollection\ProxySourceItem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends Collection<ProxySourceItem>
|
||||||
|
*/
|
||||||
final class PresentationCollection extends Collection
|
final class PresentationCollection extends Collection
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @return Collection<ProxySourceItem>
|
||||||
|
*/
|
||||||
public function getAllEvents(): Collection
|
public function getAllEvents(): Collection
|
||||||
{
|
{
|
||||||
$events = array_reduce(
|
$events = array_reduce(
|
||||||
|
@ -24,6 +30,9 @@ final class PresentationCollection extends Collection
|
||||||
return new Collection(array_merge(...$events));
|
return new Collection(array_merge(...$events));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Collection<ProxySourceItem>
|
||||||
|
*/
|
||||||
public function getPastEvents(): Collection
|
public function getPastEvents(): Collection
|
||||||
{
|
{
|
||||||
$today = new DateTimeImmutable('today');
|
$today = new DateTimeImmutable('today');
|
||||||
|
|
|
@ -21,6 +21,10 @@ class PresentationTwigExtension extends AbstractExtension
|
||||||
return 'presentations';
|
return 'presentations';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ProxySourceItem[] $presentations
|
||||||
|
*/
|
||||||
public function getPresentationCount(array $presentations): int
|
public function getPresentationCount(array $presentations): int
|
||||||
{
|
{
|
||||||
$presentationCollection = new PresentationCollection($presentations);
|
$presentationCollection = new PresentationCollection($presentations);
|
||||||
|
|
|
@ -116,6 +116,8 @@ class PresentationTwigExtensionTest extends TestCase
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assert the extension uses the correct number of presentations.
|
* Assert the extension uses the correct number of presentations.
|
||||||
|
*
|
||||||
|
* @param ProxySourceItem[] $presentations
|
||||||
*/
|
*/
|
||||||
private function assertPresentationCount(int $expectedCount, array $presentations): void
|
private function assertPresentationCount(int $expectedCount, array $presentations): void
|
||||||
{
|
{
|
||||||
|
@ -127,6 +129,8 @@ class PresentationTwigExtensionTest extends TestCase
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a mock presentation with a list of events.
|
* Create a mock presentation with a list of events.
|
||||||
|
*
|
||||||
|
* @param array{date: int}[] $events
|
||||||
*/
|
*/
|
||||||
private function createPresentation(array $events): ProxySourceItem
|
private function createPresentation(array $events): ProxySourceItem
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue