Skip to content

Commit 89856e5

Browse files
authored
add phpstan static analysis tool (#200)
* add phpstan * fix review issues * fix phpstan error with final constructor
1 parent 40cb301 commit 89856e5

File tree

5 files changed

+15
-2
lines changed

5 files changed

+15
-2
lines changed

.github/workflows/php.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ jobs:
5353

5454
- name: Run Psalm
5555
run: vendor/bin/psalm
56+
57+
- name: Run Phpstan
58+
run: vendor/bin/phpstan analyse
5659

5760
- name: Run PHPUnit
5861
run: vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover

Context/Context.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Context
4040
* @param mixed|null $value
4141
* @param Context|null $parent Reference to the parent object
4242
*/
43-
public function __construct(?ContextKey $key=null, $value=null, $parent=null)
43+
public final function __construct(?ContextKey $key=null, $value=null, $parent=null)
4444
{
4545
$this->key = $key;
4646
$this->value = $value;

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ psalm:
1212
$(DC_RUN_PHP) php ./vendor/bin/psalm
1313
psalm-info:
1414
$(DC_RUN_PHP) php ./vendor/bin/psalm --show-info=true
15+
phpstan:
16+
$(DC_RUN_PHP) php ./vendor/bin/phpstan analyse
1517
trace examples: FORCE
1618
docker-compose up -d
1719
$(DC_RUN_PHP) php ./examples/AlwaysOnZipkinExample.php

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"composer/xdebug-handler": "^1.3",
4444
"phan/phan": "^3.0",
4545
"friendsofphp/php-cs-fixer": "^2.16",
46-
"vimeo/psalm": "^4.0"
46+
"vimeo/psalm": "^4.0",
47+
"phpstan/phpstan": "^0.12.50"
4748
}
4849
}

phpstan.neon

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
parameters:
2+
level: 4
3+
paths:
4+
- Context
5+
- api
6+
- contrib
7+
- sdk

0 commit comments

Comments
 (0)