Skip to content

Commit 40cb301

Browse files
authored
Add psalm static analysis tool to codebase (#198)
* Add psalm static analysis tool to codebase * fix psalm errors add psalm to github actions
1 parent 48581e1 commit 40cb301

File tree

5 files changed

+28
-2
lines changed

5 files changed

+28
-2
lines changed

.github/workflows/php.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ jobs:
5050
env:
5151
PHAN_DISABLE_XDEBUG_WARN: 1
5252
run: vendor/bin/phan
53+
54+
- name: Run Psalm
55+
run: vendor/bin/psalm
5356

5457
- name: Run PHPUnit
5558
run: vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ test:
88
$(DC_RUN_PHP) php ./vendor/bin/phpunit --colors=always --coverage-text --testdox --coverage-clover coverage.clover
99
phan:
1010
$(DC_RUN_PHP) env PHAN_DISABLE_XDEBUG_WARN=1 php ./vendor/bin/phan
11+
psalm:
12+
$(DC_RUN_PHP) php ./vendor/bin/psalm
13+
psalm-info:
14+
$(DC_RUN_PHP) php ./vendor/bin/psalm --show-info=true
1115
trace examples: FORCE
1216
docker-compose up -d
1317
$(DC_RUN_PHP) php ./examples/AlwaysOnZipkinExample.php

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"phpunit/phpunit": "^9.3",
4343
"composer/xdebug-handler": "^1.3",
4444
"phan/phan": "^3.0",
45-
"friendsofphp/php-cs-fixer": "^2.16"
45+
"friendsofphp/php-cs-fixer": "^2.16",
46+
"vimeo/psalm": "^4.0"
4647
}
4748
}

psalm.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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="Context" />
11+
<directory name="api" />
12+
<directory name="contrib" />
13+
<directory name="sdk" />
14+
<ignoreFiles>
15+
<directory name="vendor" />
16+
</ignoreFiles>
17+
</projectFiles>
18+
</psalm>

sdk/Metrics/HasLabels.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ trait HasLabels
1212
protected $labels = [];
1313

1414
/**
15-
* {@inheritDoc}
15+
* @return array<string>
1616
*/
1717
public function getLabels(): array
1818
{

0 commit comments

Comments
 (0)