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:
|
||||
level: 5
|
||||
level: 9
|
||||
paths:
|
||||
- src
|
||||
- tests
|
||||
|
|
|
@ -8,7 +8,7 @@ use Twig\TwigFunction;
|
|||
|
||||
class ExperienceTwigExtension extends AbstractExtension
|
||||
{
|
||||
private static $startYear = 2007;
|
||||
private static int $startYear = 2007;
|
||||
|
||||
public function getFunctions(): array
|
||||
{
|
||||
|
@ -24,6 +24,6 @@ class ExperienceTwigExtension extends AbstractExtension
|
|||
|
||||
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;
|
||||
|
||||
/**
|
||||
* @implements IteratorAggregate<TItem>
|
||||
* @template TItem
|
||||
*/
|
||||
class Collection implements Countable, IteratorAggregate
|
||||
|
@ -26,6 +27,9 @@ class Collection implements Countable, IteratorAggregate
|
|||
return count($this->items);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return self<TItem>
|
||||
*/
|
||||
public function filter(callable $callback): self
|
||||
{
|
||||
return new static(
|
||||
|
|
|
@ -7,8 +7,14 @@ namespace App\Presentation\Collection;
|
|||
use DateTimeImmutable;
|
||||
use Sculpin\Contrib\ProxySourceCollection\ProxySourceItem;
|
||||
|
||||
/**
|
||||
* @extends Collection<ProxySourceItem>
|
||||
*/
|
||||
final class PresentationCollection extends Collection
|
||||
{
|
||||
/**
|
||||
* @return Collection<ProxySourceItem>
|
||||
*/
|
||||
public function getAllEvents(): Collection
|
||||
{
|
||||
$events = array_reduce(
|
||||
|
@ -24,6 +30,9 @@ final class PresentationCollection extends Collection
|
|||
return new Collection(array_merge(...$events));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<ProxySourceItem>
|
||||
*/
|
||||
public function getPastEvents(): Collection
|
||||
{
|
||||
$today = new DateTimeImmutable('today');
|
||||
|
|
|
@ -21,6 +21,10 @@ class PresentationTwigExtension extends AbstractExtension
|
|||
return 'presentations';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ProxySourceItem[] $presentations
|
||||
*/
|
||||
public function getPresentationCount(array $presentations): int
|
||||
{
|
||||
$presentationCollection = new PresentationCollection($presentations);
|
||||
|
|
|
@ -116,6 +116,8 @@ class PresentationTwigExtensionTest extends TestCase
|
|||
|
||||
/**
|
||||
* Assert the extension uses the correct number of presentations.
|
||||
*
|
||||
* @param ProxySourceItem[] $presentations
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @param array{date: int}[] $events
|
||||
*/
|
||||
private function createPresentation(array $events): ProxySourceItem
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue