Skip to content

Add Psalm #408

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/static-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,19 @@ jobs:

- name: Run script
run: composer phpstan

psalm:
name: Psalm
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2

- name: Install dependencies
run: composer update --no-progress --no-interaction --prefer-dist

- name: Run script
run: composer psalm
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ cs-dry-run:
phpstan:
vendor/bin/phpstan analyze

psalm:
vendor/bin/psalm

test:
vendor/bin/phpunit

Expand Down
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
"symfony/monolog-bundle": "^3.4",
"symfony/phpunit-bridge": "^5.0",
"symfony/polyfill-php80": "^1.22",
"symfony/yaml": "^3.4.43||^4.4.11||^5.0.11"
"symfony/yaml": "^3.4.43||^4.4.11||^5.0.11",
"vimeo/psalm": "^4.3"
},
"suggest": {
"monolog/monolog": "Allow sending log messages to Sentry by using the included Monolog handler."
Expand All @@ -74,6 +75,9 @@
],
"phpstan": [
"vendor/bin/phpstan analyse"
],
"psalm": [
"vendor/bin/psalm"
]
},
"extra": {
Expand Down
16 changes: 16 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<psalm
errorLevel="4"
resolveFromConfigFile="true"
memoizeMethodCallResults="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
</psalm>
2 changes: 2 additions & 0 deletions src/DependencyInjection/SentryExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public function getNamespace()

/**
* @param array<string, mixed> $mergedConfig
*
* @psalm-suppress MoreSpecificImplementedParamType
*/
protected function loadInternal(array $mergedConfig, ContainerBuilder $container): void
{
Expand Down
1 change: 1 addition & 0 deletions src/EventListener/ErrorListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public function __construct(HubInterface $hub)
*/
public function handleExceptionEvent(ErrorListenerExceptionEvent $event): void
{
/** @psalm-suppress RedundantCondition */
if ($event instanceof ExceptionEvent) {
$this->hub->captureException($event->getThrowable());
} else {
Expand Down
8 changes: 8 additions & 0 deletions src/aliases.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,42 @@

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

if (!class_exists(RequestListenerRequestEvent::class, false)) {
/** @psalm-suppress UndefinedClass */
class_alias(RequestEvent::class, RequestListenerRequestEvent::class);
}

if (!class_exists(RequestListenerControllerEvent::class, false)) {
/** @psalm-suppress UndefinedClass */
class_alias(ControllerEvent::class, RequestListenerControllerEvent::class);
}

if (!class_exists(SubRequestListenerRequestEvent::class, false)) {
/** @psalm-suppress UndefinedClass */
class_alias(RequestEvent::class, SubRequestListenerRequestEvent::class);
}
} else {
if (!class_exists(ErrorListenerExceptionEvent::class, false)) {
/** @psalm-suppress UndefinedClass */
class_alias(GetResponseForExceptionEvent::class, ErrorListenerExceptionEvent::class);
}

if (!class_exists(RequestListenerRequestEvent::class, false)) {
/** @psalm-suppress UndefinedClass */
class_alias(GetResponseEvent::class, RequestListenerRequestEvent::class);
}

if (!class_exists(RequestListenerControllerEvent::class, false)) {
/** @psalm-suppress UndefinedClass */
class_alias(FilterControllerEvent::class, RequestListenerControllerEvent::class);
}

if (!class_exists(SubRequestListenerRequestEvent::class, false)) {
/** @psalm-suppress UndefinedClass */
class_alias(GetResponseEvent::class, SubRequestListenerRequestEvent::class);
}
}