Skip to content

Commit 832e9ef

Browse files
committed
phpstan added and fixes follows
1 parent 47cddd4 commit 832e9ef

File tree

6 files changed

+35
-5
lines changed

6 files changed

+35
-5
lines changed

composer.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
},
2121
"require-dev": {
2222
"squizlabs/php_codesniffer": "^3.4",
23-
"phpunit/phpunit": "^8"
23+
"phpunit/phpunit": "^8",
24+
"phpstan/phpstan": "^0.11.8"
2425
},
2526

2627
"autoload": {
@@ -41,6 +42,9 @@
4142
],
4243
"test": [
4344
"vendor/bin/phpunit --coverage-text --bootstrap ./tests/bootstrap.php --testdox --color -v tests/"
45+
],
46+
"phpstan": [
47+
"phpstan analyse --error-format=table --no-progress -lmax -c phpstan.neon src/ tests/"
4448
]
4549
}
4650
}

phpstan.neon

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
parameters:
2+
#bootstrap: %currentWorkingDirectory%/../../../phpstan-bootstrap.php
3+
ignoreErrors:
4+
# Implementation feature
5+
- '#Lipid\\BasePDO::__construct\(\) does not call parent constructor from PDO#'
6+
7+
# https://github.com/phpstan/phpstan#ignore-error-messages-with-regular-expressions
8+
-
9+
message: '#Access to an undefined property Lipid\\Response::\$headers#'
10+
path: %currentWorkingDirectory%/tests/ActRedirectTest.php
11+
-
12+
message: "#Offset 'path' does not exist on array()#"
13+
path: %currentWorkingDirectory%/src/Action/ActRouted.php
14+
15+
16+
autoload_files:
17+
- %currentWorkingDirectory%/vendor/autoload.php
18+
autoload_directories:
19+
- %currentWorkingDirectory%/src
20+
- %currentWorkingDirectory%/tests

src/Action/ActRouted.php

+6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Lipid\Response;
77
use Lipid\Request;
88
use Lipid\NotFoundException;
9+
use Lipid\Request\RqSERVER;
910
use Exception;
1011

1112
/**
@@ -54,6 +55,11 @@ public function handle(Response $resp): Response
5455
}
5556

5657
$path = parse_url($requestUri)['path'];
58+
if (! (is_string($path) && strlen($path) > 0) ) {
59+
throw new Exception("Unrecognized path in REQUEST_URI");
60+
}
61+
62+
5763
$path = '/' . rtrim(substr($path, 1), '/');
5864

5965
if (! array_key_exists($path, $this->actionMap)) {

src/App/ApplicationStd.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ final class ApplicationStd implements App
2323
*
2424
* @param Action|array $action action to start (see ActRouted)
2525
* @param Response $response HTTP Response
26-
* @param Request $request HTTP Request
26+
* @param Request $SERVER \$_SERVER (RqSERVER)
2727
*/
2828
public function __construct($action, Response $response = null, Request $SERVER = null)
2929
{

src/Config/Cfg.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ final class Cfg implements Config
3939
/**
4040
* By default we get config from current work directory
4141
*
42-
* @param string $cfgPath path to config php file
43-
* @param Config $cfg
42+
* @param Config $creds creds.php
43+
* @param Config $config config.php file
4444
*/
4545
public function __construct(Config $creds = null, Config $config = null)
4646
{

src/Tpl/Twig.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ final class Twig implements Tpl
1414
* Constructor.
1515
*
1616
* @param string $tplName template file name
17-
* @param string|\Twig\Tenvironment $tplPath directory with templates
17+
* @param string|\Twig\Environment $tplPath directory with templates
1818
*/
1919
public function __construct(string $tplName, $tplPath)
2020
{

0 commit comments

Comments
 (0)