phpstan fixes (partial level 3) (#1091)

This commit is contained in:
Thomas Rupprecht 2023-04-01 14:39:25 +02:00 committed by GitHub
parent 131c6af6a2
commit d4104850be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 11 additions and 52 deletions

View File

@ -60,7 +60,7 @@ class MetricsEngine implements EngineInterface
} }
/** /**
* @return array[] * @return string[]
*/ */
protected function formatHistogram(array $row, string $name): array protected function formatHistogram(array $row, string $name): array
{ {

View File

@ -174,9 +174,6 @@ class Stats
->get(); ->get();
} }
/**
* @param string|null $vehicle
*/
public function licenses(string $vehicle): int public function licenses(string $vehicle): int
{ {
$mapping = [ $mapping = [

View File

@ -5,7 +5,6 @@ declare(strict_types=1);
namespace Engelsystem\Exceptions\Handlers; namespace Engelsystem\Exceptions\Handlers;
use Engelsystem\Application; use Engelsystem\Application;
use Engelsystem\Container\Container;
use Engelsystem\Helpers\Authenticator; use Engelsystem\Helpers\Authenticator;
use Engelsystem\Http\Request; use Engelsystem\Http\Request;
use Throwable; use Throwable;
@ -15,14 +14,11 @@ use Whoops\Run as WhoopsRunner;
class Whoops extends Legacy implements HandlerInterface class Whoops extends Legacy implements HandlerInterface
{ {
protected Application $app;
/** /**
* Whoops constructor. * Whoops constructor.
*/ */
public function __construct(Container $app) public function __construct(protected Application $app)
{ {
$this->app = $app;
} }
public function render(Request $request, Throwable $e): void public function render(Request $request, Throwable $e): void

View File

@ -89,7 +89,7 @@ class BarChart
/** /**
* @param int $max Max Y value * @param int $max Max Y value
* @return array<array{label: string, bottom: string}> * @return array<int, array{label: string, bottom: string}>
*/ */
private static function calculateYLabels(int $max): array private static function calculateYLabels(int $max): array
{ {
@ -98,7 +98,7 @@ class BarChart
for ($y = 0; $y <= $max; $y += $step) { for ($y = 0; $y <= $max; $y += $step) {
$yLabels[] = [ $yLabels[] = [
'label' => $y, 'label' => (string) $y,
'bottom' => $max === 0 ? '0%' : ($y / $max * 100) . '%', 'bottom' => $max === 0 ? '0%' : ($y / $max * 100) . '%',
]; ];
} }
@ -148,7 +148,7 @@ class BarChart
'count' => $step, 'count' => $step,
'sum' => $step * $count, 'sum' => $step * $count,
]; ];
$current = $current->addDay(1); $current = $current->addDay();
$count++; $count++;
} }

View File

@ -12,7 +12,7 @@ trait CalculatesTime
$duration = explode(':', $time); $duration = explode(':', $time);
foreach (array_slice($duration, 0, 2) as $key => $times) { foreach (array_slice($duration, 0, 2) as $key => $times) {
$seconds += [60 * 60, 60][$key] * $times; $seconds += [60 * 60, 60][$key] * (int) $times;
} }
return $seconds; return $seconds;

View File

@ -42,7 +42,7 @@ class Event
protected array $persons = [], protected array $persons = [],
protected ?string $language = null, protected ?string $language = null,
protected ?string $description = null, protected ?string $description = null,
protected string $recording = '', protected ?string $recording = '',
protected array $links = [], protected array $links = [],
protected array $attachments = [], protected array $attachments = [],
protected ?string $url = null, protected ?string $url = null,

View File

@ -116,7 +116,7 @@ class OAuthControllerTest extends TestCase
); );
$this->setExpects($provider, 'getResourceOwner', [$accessToken], $resourceOwner, $this->atLeastOnce()); $this->setExpects($provider, 'getResourceOwner', [$accessToken], $resourceOwner, $this->atLeastOnce());
/** @var EventDispatcher|MockObject $event */ /** @var EventDispatcher|MockObject $dispatcher */
$dispatcher = $this->createMock(EventDispatcher::class); $dispatcher = $this->createMock(EventDispatcher::class);
$this->app->instance('events.dispatcher', $dispatcher); $this->app->instance('events.dispatcher', $dispatcher);
$this->setExpects($dispatcher, 'dispatch', ['oauth2.login'], $dispatcher, 4); $this->setExpects($dispatcher, 'dispatch', ['oauth2.login'], $dispatcher, 4);

View File

@ -375,8 +375,6 @@ class SettingsControllerTest extends ControllerTest
/** /**
* @covers \Engelsystem\Controllers\SettingsController::savePassword * @covers \Engelsystem\Controllers\SettingsController::savePassword
* @dataProvider savePasswordValidationProvider * @dataProvider savePasswordValidationProvider
* @param string $new_password
* @param string $new_password2
*/ */
public function testSavePasswordValidation( public function testSavePasswordValidation(
?string $password, ?string $password,

View File

@ -8,7 +8,7 @@ use Engelsystem\Controllers\BaseController;
class ControllerImplementation extends BaseController class ControllerImplementation extends BaseController
{ {
/** @var array */ /** @var string[]|string[][] */
protected array $permissions = [ protected array $permissions = [
'foo', 'foo',
'lorem' => [ 'lorem' => [

View File

@ -32,7 +32,7 @@ class ShiftsTest extends TestCase
} }
/** /**
* @return array[][] * @return array{0: Carbon, 1: Carbon, 2: boolean}[]
*/ */
public function nightShiftData(): array public function nightShiftData(): array
{ {

View File

@ -1,32 +0,0 @@
<?php
declare(strict_types=1);
namespace Engelsystem\Test\Unit\Models\Stub;
use Engelsystem\Models\BaseModel;
use Illuminate\Database\Eloquent\Builder as QueryBuilder;
/**
* @property string foo
*/
class BaseModelImplementation extends BaseModel
{
/** @var array<string> */
protected $fillable = ['foo']; // phpcs:ignore
public int $saveCount = 0;
public static ?QueryBuilder $queryBuilder = null;
public function save(array $options = []): bool
{
$this->saveCount++;
return true;
}
public static function query(): QueryBuilder
{
return self::$queryBuilder;
}
}

View File

@ -111,7 +111,7 @@ class TwigServiceProviderTest extends ServiceProviderTest
*/ */
public function testRegisterTwigEngine(): void public function testRegisterTwigEngine(): void
{ {
/** @var TwigEngine|MockObject $htmlEngine */ /** @var TwigEngine|MockObject $twigEngine */
$twigEngine = $this->createMock(TwigEngine::class); $twigEngine = $this->createMock(TwigEngine::class);
/** @var TwigLoader|MockObject $twigLoader */ /** @var TwigLoader|MockObject $twigLoader */
$twigLoader = $this->createMock(TwigLoader::class); $twigLoader = $this->createMock(TwigLoader::class);