Skip to content

Commit 26d3b6e

Browse files
authored
Add Psalm (#408)
1 parent 213d839 commit 26d3b6e

File tree

7 files changed

+51
-1
lines changed

7 files changed

+51
-1
lines changed

.github/workflows/static-analysis.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,19 @@ jobs:
4141

4242
- name: Run script
4343
run: composer phpstan
44+
45+
psalm:
46+
name: Psalm
47+
runs-on: ubuntu-latest
48+
steps:
49+
- name: Checkout
50+
uses: actions/checkout@v2
51+
52+
- name: Setup PHP
53+
uses: shivammathur/setup-php@v2
54+
55+
- name: Install dependencies
56+
run: composer update --no-progress --no-interaction --prefer-dist
57+
58+
- name: Run script
59+
run: composer psalm

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ cs-dry-run:
1717
phpstan:
1818
vendor/bin/phpstan analyze
1919

20+
psalm:
21+
vendor/bin/psalm
22+
2023
test:
2124
vendor/bin/phpunit
2225

composer.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
"symfony/monolog-bundle": "^3.4",
4848
"symfony/phpunit-bridge": "^5.0",
4949
"symfony/polyfill-php80": "^1.22",
50-
"symfony/yaml": "^3.4.43||^4.4.11||^5.0.11"
50+
"symfony/yaml": "^3.4.43||^4.4.11||^5.0.11",
51+
"vimeo/psalm": "^4.3"
5152
},
5253
"suggest": {
5354
"monolog/monolog": "Allow sending log messages to Sentry by using the included Monolog handler."
@@ -74,6 +75,9 @@
7475
],
7576
"phpstan": [
7677
"vendor/bin/phpstan analyse"
78+
],
79+
"psalm": [
80+
"vendor/bin/psalm"
7781
]
7882
},
7983
"extra": {

psalm.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0"?>
2+
<psalm
3+
errorLevel="4"
4+
resolveFromConfigFile="true"
5+
memoizeMethodCallResults="true"
6+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
7+
xmlns="https://getpsalm.org/schema/config"
8+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
9+
>
10+
<projectFiles>
11+
<directory name="src" />
12+
<ignoreFiles>
13+
<directory name="vendor" />
14+
</ignoreFiles>
15+
</projectFiles>
16+
</psalm>

src/DependencyInjection/SentryExtension.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ public function getNamespace()
4646

4747
/**
4848
* @param array<string, mixed> $mergedConfig
49+
*
50+
* @psalm-suppress MoreSpecificImplementedParamType
4951
*/
5052
protected function loadInternal(array $mergedConfig, ContainerBuilder $container): void
5153
{

src/EventListener/ErrorListener.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public function __construct(HubInterface $hub)
3434
*/
3535
public function handleExceptionEvent(ErrorListenerExceptionEvent $event): void
3636
{
37+
/** @psalm-suppress RedundantCondition */
3738
if ($event instanceof ExceptionEvent) {
3839
$this->hub->captureException($event->getThrowable());
3940
} else {

src/aliases.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,34 +16,42 @@
1616

1717
if (version_compare(Kernel::VERSION, '4.3.0', '>=')) {
1818
if (!class_exists(ErrorListenerExceptionEvent::class, false)) {
19+
/** @psalm-suppress UndefinedClass */
1920
class_alias(ExceptionEvent::class, ErrorListenerExceptionEvent::class);
2021
}
2122

2223
if (!class_exists(RequestListenerRequestEvent::class, false)) {
24+
/** @psalm-suppress UndefinedClass */
2325
class_alias(RequestEvent::class, RequestListenerRequestEvent::class);
2426
}
2527

2628
if (!class_exists(RequestListenerControllerEvent::class, false)) {
29+
/** @psalm-suppress UndefinedClass */
2730
class_alias(ControllerEvent::class, RequestListenerControllerEvent::class);
2831
}
2932

3033
if (!class_exists(SubRequestListenerRequestEvent::class, false)) {
34+
/** @psalm-suppress UndefinedClass */
3135
class_alias(RequestEvent::class, SubRequestListenerRequestEvent::class);
3236
}
3337
} else {
3438
if (!class_exists(ErrorListenerExceptionEvent::class, false)) {
39+
/** @psalm-suppress UndefinedClass */
3540
class_alias(GetResponseForExceptionEvent::class, ErrorListenerExceptionEvent::class);
3641
}
3742

3843
if (!class_exists(RequestListenerRequestEvent::class, false)) {
44+
/** @psalm-suppress UndefinedClass */
3945
class_alias(GetResponseEvent::class, RequestListenerRequestEvent::class);
4046
}
4147

4248
if (!class_exists(RequestListenerControllerEvent::class, false)) {
49+
/** @psalm-suppress UndefinedClass */
4350
class_alias(FilterControllerEvent::class, RequestListenerControllerEvent::class);
4451
}
4552

4653
if (!class_exists(SubRequestListenerRequestEvent::class, false)) {
54+
/** @psalm-suppress UndefinedClass */
4755
class_alias(GetResponseEvent::class, SubRequestListenerRequestEvent::class);
4856
}
4957
}

0 commit comments

Comments
 (0)