diff --git a/composer.json b/composer.json index b07996a..e95b7f1 100644 --- a/composer.json +++ b/composer.json @@ -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": { diff --git a/src/App.php b/src/App.php index ff7a156..2a48b7b 100644 --- a/src/App.php +++ b/src/App.php @@ -54,7 +54,7 @@ class App { /** - * @var array + * @var array> */ protected static array $services = []; protected static bool $isRunning = false; @@ -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(); diff --git a/src/Controller.php b/src/Controller.php index a6bde62..4b57d62 100644 --- a/src/Controller.php +++ b/src/Controller.php @@ -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 } } @@ -88,7 +88,7 @@ protected function render( * Validate data. * * @param array $data The data to be validated - * @param array $rules An associative array with field + * @param array|string> $rules An associative array with field * as keys and values as rules * @param array $labels An associative array with fields as * keys and label as values diff --git a/src/Debug/ViewCollector.php b/src/Debug/ViewCollector.php index 7b4a56c..b7ea9f1 100644 --- a/src/Debug/ViewCollector.php +++ b/src/Debug/ViewCollector.php @@ -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'], ]; diff --git a/src/Model.php b/src/Model.php index cd898ac..f7469b5 100644 --- a/src/Model.php +++ b/src/Model.php @@ -122,7 +122,7 @@ abstract class Model implements ModelInterface * * @see Validation::setRules * - * @var array + * @var array|string> */ protected array $validationRules; /** @@ -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 + * @return array|Entity|stdClass> */ public function paginate(int $page, int $perPage = 10) : array { @@ -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 } /** @@ -669,7 +669,7 @@ public function getValidationMessages() : array } /** - * @return array + * @return array|string> */ protected function getValidationRules() : array { diff --git a/src/View.php b/src/View.php index 42f8c1f..bdd56a9 100644 --- a/src/View.php +++ b/src/View.php @@ -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 ); } @@ -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 ); } diff --git a/tests/LanguagesTest.php b/tests/LanguagesTest.php index 85a2352..1cdcab5 100644 --- a/tests/LanguagesTest.php +++ b/tests/LanguagesTest.php @@ -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 = []; @@ -53,7 +54,7 @@ public function testKeys(array $rules, string $file) : void } /** - * @return array + * @return array> */ public function languageProvider() : array {