Skip to content

Commit 17344c3

Browse files
committedJan 10, 2025
Bump phpstan from 1.x to 2.x and remove unnecessary psalm annotations
1 parent 1e80f4f commit 17344c3

14 files changed

+7
-36
lines changed
 

‎composer.json

+3-6
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
"require-dev": {
2020
"friendsofphp/php-cs-fixer": "^3.53",
2121
"jetbrains/phpstorm-attributes": "^1.0",
22-
"phpstan/extension-installer": "^1.4",
23-
"phpstan/phpstan": "^1.11",
24-
"phpstan/phpstan-strict-rules": "^1.6",
22+
"phpstan/phpstan": "^2.0",
23+
"phpstan/phpstan-deprecation-rules": "^2.0",
24+
"phpstan/phpstan-strict-rules": "^2.0",
2525
"phpunit/phpunit": "^10.5|^11.0",
2626
"rector/rector": "^1.1",
2727
"type-lang/parser": "^1.0"
@@ -44,9 +44,6 @@
4444
"optimize-autoloader": true,
4545
"preferred-install": {
4646
"*": "dist"
47-
},
48-
"allow-plugins": {
49-
"phpstan/extension-installer": true
5047
}
5148
},
5249
"scripts": {

‎phpstan.neon

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
includes:
22
- phar://phpstan.phar/conf/bleedingEdge.neon
3+
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
4+
- vendor/phpstan/phpstan-strict-rules/rules.neon
35
parameters:
4-
level: 9
6+
level: max
57
strictRules:
68
allRules: true
79
fileExtensions:

‎src/Parser.php

+1-6
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,7 @@ public function parse(#[Language('PHP')] string $docblock): DocBlock
4242
$mapper = new SourceMap();
4343

4444
try {
45-
/**
46-
* @var Segment $segment
47-
*
48-
* @psalm-suppress InvalidIterator
49-
*/
45+
/** @var Segment $segment */
5046
foreach ($result = $this->analyze($docblock) as $segment) {
5147
$mapper->add($segment->offset, $segment->text);
5248
}
@@ -72,7 +68,6 @@ public function parse(#[Language('PHP')] string $docblock): DocBlock
7268
*/
7369
private function analyze(string $docblock): \Generator
7470
{
75-
/** @psalm-suppress InvalidIterator */
7671
yield from $blocks = $this->groupByCommentSections($docblock);
7772

7873
$description = null;

‎src/Tag/Content.php

-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ class Content implements \Stringable
2424

2525
/**
2626
* @var int<0, max>
27-
*
28-
* @psalm-readonly-allow-private-mutation
2927
*/
3028
public int $offset = 0;
3129

‎src/Tag/Content/TypeParserApplicator.php

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ public function __invoke(Content $lexer): TypeStatement
3232
try {
3333
$type = $this->parser->parse($lexer->value);
3434
} catch (ParserExceptionInterface $e) {
35-
/** @psalm-suppress InvalidArgument */
3635
throw $lexer->getTagException(
3736
message: \sprintf('Tag @%s contains an incorrect type', $this->tag),
3837
previous: $e,

‎src/Tag/Description/DescriptionInterface.php

-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ interface DescriptionInterface extends \Stringable
1616
* Magic method {@link https://www.php.net/manual/en/language.oop5.magic.php#object.tostring}
1717
* allows a class to decide how it will react when it is treated like
1818
* a string.
19-
*
20-
* @psalm-immutable Each call to the method must return the same value.
2119
*/
2220
public function __toString(): string;
2321
}

‎src/Tag/Description/DescriptionProviderInterface.php

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ interface DescriptionProviderInterface extends OptionalDescriptionProviderInterf
99
/**
1010
* Returns description object which can be represented as a string and
1111
* contains additional information.
12-
*
13-
* @psalm-immutable Each call to the method must return the same value.
1412
*/
1513
public function getDescription(): DescriptionInterface;
1614
}

‎src/Tag/Description/OptionalDescriptionProviderInterface.php

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ interface OptionalDescriptionProviderInterface
99
/**
1010
* Returns description object which can be represented as a string and
1111
* contains additional information.
12-
*
13-
* @psalm-immutable Each call to the method must return the same value.
1412
*/
1513
public function getDescription(): ?DescriptionInterface;
1614
}

‎src/Tag/OptionalTypeProviderInterface.php

-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ interface OptionalTypeProviderInterface
1717
/**
1818
* Returns an AST object of the type or {@see null} in case the
1919
* type is not specified.
20-
*
21-
* @psalm-immutable Each call to the method must return the same value.
2220
*/
2321
public function getType(): ?TypeStatement;
2422
}

‎src/Tag/OptionalVariableNameProviderInterface.php

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ interface OptionalVariableNameProviderInterface
1111
* which this tag is attached or {@see null} in case of the tag does
1212
* not contain a name.
1313
*
14-
* @psalm-immutable Each call to the method must return the same value.
15-
*
1614
* @return non-empty-string|null
1715
*/
1816
public function getVariableName(): ?string;

‎src/Tag/TagInterface.php

-4
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ interface TagInterface extends OptionalDescriptionProviderInterface, \Stringable
1515
* that is, can contain all the characters that can match the PHP FQN, as
1616
* well as the '-' character.
1717
*
18-
* @psalm-immutable Each call to the method must return the same value.
19-
*
2018
* @return non-empty-string
2119
*/
2220
public function getName(): string;
@@ -26,8 +24,6 @@ public function getName(): string;
2624
* allows a class to decide how it will react when it is treated like
2725
* a string.
2826
*
29-
* @psalm-immutable Each call to the method must return the same value.
30-
*
3127
* @return string returns string representation of the object that
3228
* implements this interface (and/or {@see __toString()} magic
3329
* method)

‎src/Tag/TagsProviderInterface.php

-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ interface TagsProviderInterface
1313
/**
1414
* Returns the tags for this object.
1515
*
16-
* @psalm-immutable Each call to the method must return the same value.
17-
*
1816
* @return iterable<array-key, TagInterface>
1917
*/
2018
public function getTags(): iterable;

‎src/Tag/TypeProviderInterface.php

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ interface TypeProviderInterface extends OptionalTypeProviderInterface
1010
{
1111
/**
1212
* Returns an AST object of the type.
13-
*
14-
* @psalm-immutable Each call to the method must return the same value.
1513
*/
1614
public function getType(): TypeStatement;
1715
}

‎src/Tag/VariableNameProviderInterface.php

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ interface VariableNameProviderInterface extends OptionalVariableNameProviderInte
1010
* Returns the name of the variable (parameter, field, etc.) to
1111
* which this tag is attached.
1212
*
13-
* @psalm-immutable Each call to the method must return the same value.
14-
*
1513
* @return non-empty-string
1614
*/
1715
public function getVariableName(): string;

0 commit comments

Comments
 (0)