Skip to content

Commit

Permalink
Add psalm
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin de Graaf committed Mar 11, 2021
1 parent 2b0cea6 commit ce016e0
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ jobs:

- name: Run test suite
run: vendor/bin/phpunit tests

- name: Run static analysis
run: vendor/bin/psalm
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.DS_Store
.idea
composer.lock
vendor
coverage
coverage
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# Parable Http

## 0.5.2

_Changes_
- Added static analysis through psalm.

## 0.5.1

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

## 0.5.0

Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ dependencies:
--no-plugins \
--no-scripts

psalm:
vendor/bin/psalm --clear-cache
vendor/bin/psalm

tests: dependencies
vendor/bin/phpunit --verbose tests

Expand All @@ -13,3 +17,7 @@ coverage: dependencies

tests-clean:
vendor/bin/phpunit --verbose tests

coverage-clean:
rm -rf ./coverage
XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-html ./coverage tests
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"ralouphie/getallheaders": "^3.0"
},
"require-dev": {
"phpunit/phpunit": "^9.0"
"phpunit/phpunit": "^9.0",
"vimeo/psalm": "^4.6"
},
"autoload": {
"psr-4": {
Expand Down
19 changes: 19 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0"?>
<psalm
errorLevel="4"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>

<issueHandlers>
<UnresolvableInclude errorLevel="suppress" />
</issueHandlers>
</psalm>
2 changes: 1 addition & 1 deletion src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function getRequestUri(): ?string

public function getProtocol(): string
{
return $this->protocol ?? 'HTTP/1.1';
return $this->protocol;
}

public function getProtocolVersion(): string
Expand Down
4 changes: 2 additions & 2 deletions src/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function appendBody(string $content): void

public function getContentType(): string
{
return $this->getHeader('Content-Type');
return $this->getHeader('Content-Type') ?? 'text/html';
}

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

public function getProtocol(): string
{
return $this->protocol ?? 'HTTP/1.1';
return $this->protocol;
}

public function getProtocolVersion(): string
Expand Down

0 comments on commit ce016e0

Please sign in to comment.