Skip to content

Commit

Permalink
add phpstan static analysis tool (#200)
Browse files Browse the repository at this point in the history
* add phpstan

* fix review issues

* fix phpstan error with final constructor
  • Loading branch information
prondubuisi authored Oct 23, 2020
1 parent 40cb301 commit 89856e5
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ jobs:

- name: Run Psalm
run: vendor/bin/psalm

- name: Run Phpstan
run: vendor/bin/phpstan analyse

- name: Run PHPUnit
run: vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover
Expand Down
2 changes: 1 addition & 1 deletion Context/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Context
* @param mixed|null $value
* @param Context|null $parent Reference to the parent object
*/
public function __construct(?ContextKey $key=null, $value=null, $parent=null)
public final function __construct(?ContextKey $key=null, $value=null, $parent=null)
{
$this->key = $key;
$this->value = $value;
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ psalm:
$(DC_RUN_PHP) php ./vendor/bin/psalm
psalm-info:
$(DC_RUN_PHP) php ./vendor/bin/psalm --show-info=true
phpstan:
$(DC_RUN_PHP) php ./vendor/bin/phpstan analyse
trace examples: FORCE
docker-compose up -d
$(DC_RUN_PHP) php ./examples/AlwaysOnZipkinExample.php
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"composer/xdebug-handler": "^1.3",
"phan/phan": "^3.0",
"friendsofphp/php-cs-fixer": "^2.16",
"vimeo/psalm": "^4.0"
"vimeo/psalm": "^4.0",
"phpstan/phpstan": "^0.12.50"
}
}
7 changes: 7 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
parameters:
level: 4
paths:
- Context
- api
- contrib
- sdk

0 comments on commit 89856e5

Please sign in to comment.