Skip to content

Commit a21a559

Browse files
author
Kirill Nesmeyanov
committed
psalm est mort, vive le phpstan!
1 parent 3e99e29 commit a21a559

4 files changed

Lines changed: 28 additions & 24 deletions

File tree

composer.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@
1919
},
2020
"require-dev": {
2121
"friendsofphp/php-cs-fixer": "^3.53",
22+
"phpstan/extension-installer": "^1.3",
23+
"phpstan/phpstan": "^1.10",
24+
"phpstan/phpstan-strict-rules": "^1.5",
2225
"phpunit/phpunit": "^10.5",
2326
"rector/rector": "^1.0",
24-
"symfony/var-dumper": "^5.6|^6.0|^7.0",
25-
"type-lang/printer": "^1.0",
26-
"vimeo/psalm": "^5.23"
27+
"symfony/var-dumper": "^5.4|^6.0|^7.0",
28+
"type-lang/printer": "^1.0"
2729
},
2830
"autoload-dev": {
2931
"psr-4": {
@@ -43,6 +45,9 @@
4345
"optimize-autoloader": true,
4446
"preferred-install": {
4547
"*": "dist"
48+
},
49+
"allow-plugins": {
50+
"phpstan/extension-installer": true
4651
}
4752
},
4853
"scripts": {
@@ -53,8 +58,8 @@
5358
"test:functional": "phpunit --testsuite=functional",
5459

5560
"linter": "@linter:check",
56-
"linter:check": "psalm --no-cache",
57-
"linter:fix": "psalm --no-cache --alter",
61+
"linter:check": "phpstan analyse --configuration phpstan.neon",
62+
"linter:baseline": "phpstan analyse --configuration phpstan.neon --generate-baseline",
5863

5964
"phpcs": "@phpcs:check",
6065
"phpcs:check": "php-cs-fixer fix --config=.php-cs-fixer.php --allow-risky=yes --dry-run --verbose --diff",

phpstan.neon

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
includes:
2+
- phar://phpstan.phar/conf/bleedingEdge.neon
3+
parameters:
4+
level: 9
5+
strictRules:
6+
allRules: true
7+
fileExtensions:
8+
- php
9+
paths:
10+
- src
11+
tmpDir: vendor/.cache.phpstan
12+
reportUnmatchedIgnoredErrors: false

psalm.xml

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/ReflectionReader.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,10 @@ private function convertNamedType(\ReflectionNamedType $type): TypeStatement
110110

111111
private function convertNonNullNamedType(\ReflectionNamedType $type): TypeStatement
112112
{
113-
$identifier = new Identifier($type->getName());
113+
/** @var non-empty-string $name */
114+
$name = $type->getName();
115+
116+
$identifier = new Identifier($name);
114117

115118
if ($type->isBuiltin() || $identifier->isSpecial() || $identifier->isBuiltin()) {
116119
return new NamedTypeNode(new Name($identifier));
@@ -121,6 +124,7 @@ private function convertNonNullNamedType(\ReflectionNamedType $type): TypeStatem
121124

122125
/**
123126
* @throws ReaderExceptionInterface
127+
* @return UnionTypeNode<TypeStatement>
124128
*/
125129
private function convertUnionType(\ReflectionUnionType $type): UnionTypeNode
126130
{
@@ -135,6 +139,7 @@ private function convertUnionType(\ReflectionUnionType $type): UnionTypeNode
135139

136140
/**
137141
* @throws ReaderExceptionInterface
142+
* @return IntersectionTypeNode<TypeStatement>
138143
*/
139144
private function convertIntersectionType(\ReflectionIntersectionType $type): IntersectionTypeNode
140145
{

0 commit comments

Comments
 (0)