Skip to content

Commit ce016e0

Browse files
author
Robin de Graaf
committed
Add psalm
1 parent 2b0cea6 commit ce016e0

File tree

8 files changed

+43
-6
lines changed

8 files changed

+43
-6
lines changed

.github/workflows/tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@ jobs:
3232

3333
- name: Run test suite
3434
run: vendor/bin/phpunit tests
35+
36+
- name: Run static analysis
37+
run: vendor/bin/psalm

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1+
.DS_Store
12
.idea
23
composer.lock
34
vendor
4-
coverage
5+
coverage

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
# Parable Http
22

3+
## 0.5.2
4+
5+
_Changes_
6+
- Added static analysis through psalm.
7+
38
## 0.5.1
49

510
_Changes_
6-
- `Request` can now be instantiated without passing all values, in which cases it will set itself up by using `RequestFactory::getValuesFromServer`.
11+
- `Request` can now be instantiated without passing all values, in which cases it will set itself up by using `RequestFactory::getValuesFromServer`.
712

813
## 0.5.0
914

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ dependencies:
44
--no-plugins \
55
--no-scripts
66

7+
psalm:
8+
vendor/bin/psalm --clear-cache
9+
vendor/bin/psalm
10+
711
tests: dependencies
812
vendor/bin/phpunit --verbose tests
913

@@ -13,3 +17,7 @@ coverage: dependencies
1317

1418
tests-clean:
1519
vendor/bin/phpunit --verbose tests
20+
21+
coverage-clean:
22+
rm -rf ./coverage
23+
XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-html ./coverage tests

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"ralouphie/getallheaders": "^3.0"
1919
},
2020
"require-dev": {
21-
"phpunit/phpunit": "^9.0"
21+
"phpunit/phpunit": "^9.0",
22+
"vimeo/psalm": "^4.6"
2223
},
2324
"autoload": {
2425
"psr-4": {

psalm.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0"?>
2+
<psalm
3+
errorLevel="4"
4+
resolveFromConfigFile="true"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xmlns="https://getpsalm.org/schema/config"
7+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
8+
>
9+
<projectFiles>
10+
<directory name="src" />
11+
<ignoreFiles>
12+
<directory name="vendor" />
13+
</ignoreFiles>
14+
</projectFiles>
15+
16+
<issueHandlers>
17+
<UnresolvableInclude errorLevel="suppress" />
18+
</issueHandlers>
19+
</psalm>

src/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function getRequestUri(): ?string
5353

5454
public function getProtocol(): string
5555
{
56-
return $this->protocol ?? 'HTTP/1.1';
56+
return $this->protocol;
5757
}
5858

5959
public function getProtocolVersion(): string

src/Response.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function appendBody(string $content): void
5151

5252
public function getContentType(): string
5353
{
54-
return $this->getHeader('Content-Type');
54+
return $this->getHeader('Content-Type') ?? 'text/html';
5555
}
5656

5757
public function setContentType(string $contentType): void
@@ -61,7 +61,7 @@ public function setContentType(string $contentType): void
6161

6262
public function getProtocol(): string
6363
{
64-
return $this->protocol ?? 'HTTP/1.1';
64+
return $this->protocol;
6565
}
6666

6767
public function getProtocolVersion(): string

0 commit comments

Comments
 (0)