Skip to content

Commit 73f1360

Browse files
authored
Merge pull request #13 from samsonasik/chore-enable-phpstan-level-9
chore: enable PHPStan level 9
2 parents 7e74fd7 + 9f04730 commit 73f1360

File tree

5 files changed

+28
-4
lines changed

5 files changed

+28
-4
lines changed

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ parameters:
22
paths:
33
- src
44
- tests
5-
level: 6
5+
level: 9
66
bootstrapFiles:
77
- vendor/codeigniter4/framework/system/Test/bootstrap.php
88

src/Commands/PageCreateCommand.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ private function createFileFromTemplate(string $templateFile, string $targetFile
8989
return;
9090
}
9191

92-
// Read template content
92+
/**
93+
* Read template content
94+
*
95+
* @var string $content
96+
*/
9397
$content = file_get_contents($templateFile . '.tpl');
9498

9599
// Replace placeholders

src/Config/Services.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,21 @@ class Services extends BaseService
2525
public static function router(?RouteCollectionInterface $routes = null, ?Request $request = null, bool $getShared = true)
2626
{
2727
if ($getShared) {
28-
return static::getSharedInstance('router', $routes, $request);
28+
/**
29+
* @var PageRouter $pageRouter
30+
*/
31+
$pageRouter = static::getSharedInstance('router', $routes, $request);
32+
33+
return $pageRouter;
2934
}
3035

3136
$routes ??= AppServices::get('routes');
3237
$request ??= AppServices::get('request');
3338

39+
/**
40+
* @var RouteCollectionInterface $routes
41+
* @var Request $request
42+
*/
3443
return new PageRouter($routes, $request);
3544
}
3645
}

src/Helpers/pageview_helper.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
* the LICENSE file that was distributed with this source code.
1010
*/
1111

12+
use CodeIgniter\Autoloader\FileLocatorInterface;
1213
use Config\Services as AppServices;
1314
use Config\View;
15+
use Psr\Log\LoggerInterface;
1416

1517
if (! function_exists('pageView')) {
1618
/**
@@ -24,7 +26,12 @@ function pageView(string $name, array $data = [], array $options = []): string
2426
$pageViewPath = APPPATH . 'Pages/';
2527

2628
// Create new view instance with custom view path
27-
$renderer = new CodeIgniter\View\View($config, $pageViewPath, AppServices::get('locator'), CI_DEBUG, AppServices::get('logger'));
29+
/** @var FileLocatorInterface $locator */
30+
$locator = AppServices::get('locator');
31+
/** @var LoggerInterface $logger */
32+
$logger = AppServices::get('logger');
33+
34+
$renderer = new CodeIgniter\View\View($config, $pageViewPath, $locator, CI_DEBUG, $logger);
2835

2936
if (array_key_exists('saveData', $options)) {
3037
$saveData = (bool) $options['saveData'];

src/PageRouter.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ public function handle(?string $uri = null)
4343
try {
4444
$handle = parent::handle($uri);
4545
} catch (PageNotFoundException $e) {
46+
if ($uri === null) {
47+
throw $e;
48+
}
49+
4650
// HACK: Check for page based routes
4751
if ($this->pageBasedRoute($uri)) {
4852
return $this->controllerName();

0 commit comments

Comments
 (0)