Skip to content

Commit 2188671

Browse files
committed
Add psalm
1 parent 3bb910a commit 2188671

4 files changed

Lines changed: 58 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ jobs:
6464
- name: Run tests
6565
run: vendor/bin/phpunit ${{ matrix.phpunit-flags }}
6666

67+
- name: Run static analysis
68+
run: vendor/bin/psalm.phar
69+
6770
- name: Run style fixer
6871
env:
6972
PHP_CS_FIXER_IGNORE_ENV: 1

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
},
2020
"require-dev": {
2121
"phpunit/phpunit": "^9",
22-
"amphp/php-cs-fixer-config": "^2-dev"
22+
"amphp/php-cs-fixer-config": "^2-dev",
23+
"psalm/phar": "^4.24"
2324
},
2425
"autoload": {
2526
"psr-4": {

psalm.xml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?xml version="1.0"?>
2+
<psalm
3+
errorLevel="2"
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="examples"/>
11+
<directory name="src"/>
12+
<ignoreFiles>
13+
<directory name="vendor"/>
14+
</ignoreFiles>
15+
</projectFiles>
16+
17+
<issueHandlers>
18+
<StringIncrement>
19+
<errorLevel type="suppress">
20+
<directory name="examples"/>
21+
<directory name="src"/>
22+
</errorLevel>
23+
</StringIncrement>
24+
25+
<RedundantConditionGivenDocblockType>
26+
<errorLevel type="suppress">
27+
<directory name="src"/>
28+
</errorLevel>
29+
</RedundantConditionGivenDocblockType>
30+
31+
<DocblockTypeContradiction>
32+
<errorLevel type="suppress">
33+
<directory name="src"/>
34+
</errorLevel>
35+
</DocblockTypeContradiction>
36+
37+
<MissingClosureParamType>
38+
<errorLevel type="suppress">
39+
<directory name="examples"/>
40+
<directory name="src"/>
41+
</errorLevel>
42+
</MissingClosureParamType>
43+
44+
<MissingClosureReturnType>
45+
<errorLevel type="suppress">
46+
<directory name="examples"/>
47+
<directory name="src"/>
48+
</errorLevel>
49+
</MissingClosureReturnType>
50+
</issueHandlers>
51+
</psalm>

src/ReactAdapter.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class ReactAdapter implements LoopInterface
2020

2121
public static function get(): LoopInterface
2222
{
23+
/** @psalm-suppress RedundantPropertyInitializationCheck */
2324
self::$instances ??= new \WeakMap();
2425

2526
$driver = EventLoop::getDriver();
@@ -31,6 +32,7 @@ public function __construct(?Driver $driver = null)
3132
{
3233
$this->driver = $driver ?? EventLoop::getDriver();
3334

35+
/** @psalm-suppress RedundantPropertyInitializationCheck */
3436
self::$instances ??= new \WeakMap();
3537
self::$instances[$this->driver] = $this;
3638
}

0 commit comments

Comments
 (0)