Skip to content

Commit

Permalink
Upgrade PHPStan
Browse files Browse the repository at this point in the history
  • Loading branch information
natanfelles committed Apr 7, 2022
1 parent a7c9a3a commit ddbf8b8
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"ergebnis/composer-normalize": "^2.23",
"jetbrains/phpstorm-attributes": "^1.0",
"phpmd/phpmd": "^2.11",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan": "^1.5",
"phpunit/phpunit": "^9.5"
},
"suggest": {
Expand Down
3 changes: 2 additions & 1 deletion src/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
class App
{
/**
* @var array<string,array>
* @var array<string,array<string,mixed>>
*/
protected static array $services = [];
protected static bool $isRunning = false;
Expand Down Expand Up @@ -929,6 +929,7 @@ protected static function setSession(string $instance) : Session
$logger
);
}
// @phpstan-ignore-next-line
$service = new Session($config['options'] ?? [], $saveHandler ?? null);
if (isset($config['auto_start']) && $config['auto_start'] === true) {
$service->start();
Expand Down
4 changes: 2 additions & 2 deletions src/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function __construct(Request $request, Response $response)
$this->request = $request;
$this->response = $response;
if (isset($this->modelClass)) {
$this->model = new $this->modelClass();
$this->model = new $this->modelClass(); // @phpstan-ignore-line
}
}

Expand All @@ -88,7 +88,7 @@ protected function render(
* Validate data.
*
* @param array<string,mixed> $data The data to be validated
* @param array<string,array|string> $rules An associative array with field
* @param array<string,array<string>|string> $rules An associative array with field
* as keys and values as rules
* @param array<string,string> $labels An associative array with fields as
* keys and label as values
Expand Down
2 changes: 1 addition & 1 deletion src/Debug/ViewCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function getActivities() : array
$activities[] = [
'collector' => $this->getName(),
'class' => static::class,
'description' => 'Render view ' . $index + 1,
'description' => 'Render view ' . ($index + 1),
'start' => $data['start'],
'end' => $data['end'],
];
Expand Down
8 changes: 4 additions & 4 deletions src/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ abstract class Model implements ModelInterface
*
* @see Validation::setRules
*
* @var array<string,array|string>
* @var array<string,array<string>|string>
*/
protected array $validationRules;
/**
Expand Down Expand Up @@ -335,7 +335,7 @@ protected function makePageLimitAndOffset(int $page, int $perPage = 10) : array
* @param int $page The current page
* @param int $perPage Items per page
*
* @return array<int,array|Entity|stdClass>
* @return array<int,array<mixed>|Entity|stdClass>
*/
public function paginate(int $page, int $perPage = 10) : array
{
Expand Down Expand Up @@ -442,7 +442,7 @@ protected function makeEntity(array $data) : array | Entity | stdClass
if ($returnType === 'object' || $returnType === 'stdClass') {
return (object) $data;
}
return new $returnType($data);
return new $returnType($data); // @phpstan-ignore-line
}

/**
Expand Down Expand Up @@ -669,7 +669,7 @@ public function getValidationMessages() : array
}

/**
* @return array<string,array|string>
* @return array<string,array<string>|string>
*/
protected function getValidationRules() : array
{
Expand Down
4 changes: 2 additions & 2 deletions src/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ public function renderBlock(string $name) : ?string
$trace = \debug_backtrace()[0];
\trigger_error(
'Trying to render block "' . $name . '" that is not set in '
. $trace['file'] . ' on line ' . $trace['line'],
. $trace['file'] . ' on line ' . $trace['line'], // @phpstan-ignore-line
\E_USER_WARNING
);
}
Expand All @@ -300,7 +300,7 @@ public function removeBlock(string $name) : static
$trace = \debug_backtrace()[0];
\trigger_error(
'Trying to remove block "' . $name . '" that is not set in '
. $trace['file'] . ' on line ' . $trace['line'],
. $trace['file'] . ' on line ' . $trace['line'], // @phpstan-ignore-line
\E_USER_WARNING
);
}
Expand Down
3 changes: 2 additions & 1 deletion tests/LanguagesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ final class LanguagesTest extends TestCase
*/
protected function getCodes() : array
{
// @phpstan-ignore-next-line
$codes = \array_filter((array) \glob($this->langDir . '*'), 'is_dir');
$length = \strlen($this->langDir);
$result = [];
Expand Down Expand Up @@ -53,7 +54,7 @@ public function testKeys(array $rules, string $file) : void
}

/**
* @return array<string,array>
* @return array<string,array<mixed>>
*/
public function languageProvider() : array
{
Expand Down

0 comments on commit ddbf8b8

Please sign in to comment.