Skip to content

Commit f75d1fc

Browse files
Update dependency tomasvotruba/type-coverage to ^2.2.1
1 parent da5619f commit f75d1fc

11 files changed

Lines changed: 105 additions & 36 deletions

tools/.phpstan/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"phpstan/phpstan": "^2.1.56",
44
"phpstan/extension-installer": "^1.4.3",
55
"phpstan/phpstan-strict-rules": "^2.0.11",
6-
"tomasvotruba/type-coverage": "^2.1.0",
6+
"tomasvotruba/type-coverage": "^2.2.1",
77
"ergebnis/phpstan-rules": "^2.13.1"
88
},
99
"config": {

tools/.phpstan/composer.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tools/.phpstan/vendor/composer/installed.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -333,25 +333,25 @@
333333
},
334334
{
335335
"name": "tomasvotruba/type-coverage",
336-
"version": "2.1.0",
337-
"version_normalized": "2.1.0.0",
336+
"version": "2.2.1",
337+
"version_normalized": "2.2.1.0",
338338
"source": {
339339
"type": "git",
340340
"url": "https://github.com/TomasVotruba/type-coverage.git",
341-
"reference": "468354b3964120806a69890cbeb3fcf005876391"
341+
"reference": "4087caa4639bdd4c646f2984bc333efeddf69e4b"
342342
},
343343
"dist": {
344344
"type": "zip",
345-
"url": "https://api.github.com/repos/TomasVotruba/type-coverage/zipball/468354b3964120806a69890cbeb3fcf005876391",
346-
"reference": "468354b3964120806a69890cbeb3fcf005876391",
345+
"url": "https://api.github.com/repos/TomasVotruba/type-coverage/zipball/4087caa4639bdd4c646f2984bc333efeddf69e4b",
346+
"reference": "4087caa4639bdd4c646f2984bc333efeddf69e4b",
347347
"shasum": ""
348348
},
349349
"require": {
350350
"nette/utils": "^3.2 || ^4.0",
351351
"php": "^7.4 || ^8.0",
352-
"phpstan/phpstan": "^2.0"
352+
"phpstan/phpstan": "^2.1.33"
353353
},
354-
"time": "2025-12-05T16:38:02+00:00",
354+
"time": "2026-05-26T08:14:01+00:00",
355355
"type": "phpstan-extension",
356356
"extra": {
357357
"phpstan": {
@@ -377,7 +377,7 @@
377377
],
378378
"support": {
379379
"issues": "https://github.com/TomasVotruba/type-coverage/issues",
380-
"source": "https://github.com/TomasVotruba/type-coverage/tree/2.1.0"
380+
"source": "https://github.com/TomasVotruba/type-coverage/tree/2.2.1"
381381
},
382382
"funding": [
383383
{

tools/.phpstan/vendor/composer/installed.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
'name' => '__root__',
44
'pretty_version' => 'dev-main',
55
'version' => 'dev-main',
6-
'reference' => '43f9a7bbe1381dbf0da98d1589ab7c0aa099599c',
6+
'reference' => 'da5619f95e814171fc214125e98f7335a59cf55e',
77
'type' => 'library',
88
'install_path' => __DIR__ . '/../../',
99
'aliases' => array(),
@@ -13,7 +13,7 @@
1313
'__root__' => array(
1414
'pretty_version' => 'dev-main',
1515
'version' => 'dev-main',
16-
'reference' => '43f9a7bbe1381dbf0da98d1589ab7c0aa099599c',
16+
'reference' => 'da5619f95e814171fc214125e98f7335a59cf55e',
1717
'type' => 'library',
1818
'install_path' => __DIR__ . '/../../',
1919
'aliases' => array(),
@@ -65,9 +65,9 @@
6565
'dev_requirement' => true,
6666
),
6767
'tomasvotruba/type-coverage' => array(
68-
'pretty_version' => '2.1.0',
69-
'version' => '2.1.0.0',
70-
'reference' => '468354b3964120806a69890cbeb3fcf005876391',
68+
'pretty_version' => '2.2.1',
69+
'version' => '2.2.1.0',
70+
'reference' => '4087caa4639bdd4c646f2984bc333efeddf69e4b',
7171
'type' => 'phpstan-extension',
7272
'install_path' => __DIR__ . '/../tomasvotruba/type-coverage',
7373
'aliases' => array(),

tools/.phpstan/vendor/tomasvotruba/type-coverage/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"keywords": ["static analysis", "phpstan-extension"],
77
"require": {
88
"php": "^7.4 || ^8.0",
9-
"phpstan/phpstan": "^2.0",
9+
"phpstan/phpstan": "^2.1.33",
1010
"nette/utils": "^3.2 || ^4.0"
1111
},
1212
"autoload": {

tools/.phpstan/vendor/tomasvotruba/type-coverage/src/CollectorDataNormalizer.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
final class CollectorDataNormalizer
1010
{
1111
/**
12-
* @param array<string, array<array{0: int, 1: array<string, int>}>> $collectorDataByPath
12+
* @param array<string, array<array{0: int, 1: array<int, int>, 2?: string|null}>> $collectorDataByPath
1313
*/
1414
public function normalize(array $collectorDataByPath): TypeCountAndMissingTypes
1515
{
@@ -24,8 +24,12 @@ public function normalize(array $collectorDataByPath): TypeCountAndMissingTypes
2424

2525
$missingCount += count($nestedData[1]);
2626

27-
$missingTypeLinesByFilePath[$filePath] = array_merge(
28-
$missingTypeLinesByFilePath[$filePath] ?? [],
27+
// if the node is from a trait, route the error to the trait file
28+
// instead of the using-class file, so lines match the actual source
29+
$effectiveFilePath = $nestedData[2] ?? $filePath;
30+
31+
$missingTypeLinesByFilePath[$effectiveFilePath] = array_merge(
32+
$missingTypeLinesByFilePath[$effectiveFilePath] ?? [],
2933
$nestedData[1]
3034
);
3135
}

tools/.phpstan/vendor/tomasvotruba/type-coverage/src/Collectors/ConstantTypeDeclarationCollector.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ public function getNodeType(): string
2626

2727
/**
2828
* @param ClassConstantsNode $node
29-
* @return array<int, int|list<(int | int<1, max>)>>
29+
* @return array{int, list<int>, string|null}
3030
*/
3131
public function processNode(Node $node, Scope $scope): array
3232
{
3333
// enable only on PHP 8.3+
3434
if (PHP_VERSION_ID < 80300) {
35-
return [0, []];
35+
return [0, [], null];
3636
}
3737

3838
$constantCount = count($node->getConstants());
@@ -54,7 +54,13 @@ public function processNode(Node $node, Scope $scope): array
5454
$missingTypeLines[] = $classConst->getLine();
5555
}
5656

57-
return [$constantCount, $missingTypeLines];
57+
$traitFilePath = null;
58+
if ($scope->isInTrait()) {
59+
$traitFilePath = $scope->getTraitReflection()
60+
->getFileName();
61+
}
62+
63+
return [$constantCount, $missingTypeLines, $traitFilePath];
5864
}
5965

6066
private function isGuardedByParentClassConstant(Scope $scope, ClassConst $classConst): bool

tools/.phpstan/vendor/tomasvotruba/type-coverage/src/Collectors/ParamTypeDeclarationCollector.php

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
use PhpParser\Comment\Doc;
88
use PhpParser\Node;
99
use PhpParser\Node\FunctionLike;
10+
use PhpParser\Node\Stmt\ClassMethod;
1011
use PHPStan\Analyser\Scope;
1112
use PHPStan\Collectors\Collector;
13+
use PHPStan\Reflection\ClassReflection;
1214

1315
/**
1416
* @see \TomasVotruba\TypeCoverage\Rules\ParamTypeCoverageRule
@@ -22,14 +24,19 @@ public function getNodeType(): string
2224

2325
/**
2426
* @param FunctionLike $node
25-
* @return mixed[]|null
27+
* @return array{int, list<int>, string|null}|null
2628
*/
2729
public function processNode(Node $node, Scope $scope): ?array
2830
{
2931
if ($this->shouldSkipFunctionLike($node)) {
3032
return null;
3133
}
3234

35+
// skip methods inherited from a parent class or interface, as types are locked by LSP
36+
if ($node instanceof ClassMethod && $this->isGuardedByParentMethod($scope, $node)) {
37+
return null;
38+
}
39+
3340
$missingTypeLines = [];
3441
$paramCount = count($node->getParams());
3542

@@ -45,7 +52,17 @@ public function processNode(Node $node, Scope $scope): ?array
4552
}
4653
}
4754

48-
return [$paramCount, $missingTypeLines];
55+
return [$paramCount, $missingTypeLines, $this->resolveTraitFilePath($scope)];
56+
}
57+
58+
private function resolveTraitFilePath(Scope $scope): ?string
59+
{
60+
if (! $scope->isInTrait()) {
61+
return null;
62+
}
63+
64+
return $scope->getTraitReflection()
65+
->getFileName();
4966
}
5067

5168
private function shouldSkipFunctionLike(FunctionLike $functionLike): bool
@@ -58,6 +75,30 @@ private function shouldSkipFunctionLike(FunctionLike $functionLike): bool
5875
return $this->hasFunctionLikeCallableParam($functionLike);
5976
}
6077

78+
private function isGuardedByParentMethod(Scope $scope, ClassMethod $classMethod): bool
79+
{
80+
$classReflection = $scope->getClassReflection();
81+
if (! $classReflection instanceof ClassReflection) {
82+
return false;
83+
}
84+
85+
$methodName = $classMethod->name->toString();
86+
87+
foreach ($classReflection->getParents() as $parentClassReflection) {
88+
if ($parentClassReflection->hasMethod($methodName)) {
89+
return true;
90+
}
91+
}
92+
93+
foreach ($classReflection->getInterfaces() as $interfaceReflection) {
94+
if ($interfaceReflection->hasMethod($methodName)) {
95+
return true;
96+
}
97+
}
98+
99+
return false;
100+
}
101+
61102
private function hasFunctionLikeCallableParam(FunctionLike $functionLike): bool
62103
{
63104
// skip callable, can be anythings

tools/.phpstan/vendor/tomasvotruba/type-coverage/src/Collectors/PropertyTypeDeclarationCollector.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function getNodeType(): string
2727

2828
/**
2929
* @param InClassNode $node
30-
* @return array<int, int|list<(int | int<1, max>)>>
30+
* @return array{int, list<int>, string|null}
3131
*/
3232
public function processNode(Node $node, Scope $scope): array
3333
{
@@ -57,7 +57,13 @@ public function processNode(Node $node, Scope $scope): array
5757
$missingTypeLines[] = $property->getLine();
5858
}
5959

60-
return [$propertyCount, $missingTypeLines];
60+
$traitFilePath = null;
61+
if ($scope->isInTrait()) {
62+
$traitFilePath = $scope->getTraitReflection()
63+
->getFileName();
64+
}
65+
66+
return [$propertyCount, $missingTypeLines, $traitFilePath];
6167
}
6268

6369
private function isPropertyDocTyped(Property $property): bool

tools/.phpstan/vendor/tomasvotruba/type-coverage/src/Collectors/ReturnTypeDeclarationCollector.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function getNodeType(): string
2121

2222
/**
2323
* @param ClassMethod $node
24-
* @return mixed[]|null
24+
* @return array{int, list<int>, string|null}|null
2525
*/
2626
public function processNode(Node $node, Scope $scope): ?array
2727
{
@@ -30,11 +30,15 @@ public function processNode(Node $node, Scope $scope): ?array
3030
return null;
3131
}
3232

33+
$traitFilePath = null;
3334
if ($scope->isInTrait()) {
3435
$originalMethodName = $node->getAttribute('originalTraitMethodName');
3536
if ($originalMethodName === '__construct') {
3637
return null;
3738
}
39+
40+
$traitFilePath = $scope->getTraitReflection()
41+
->getFileName();
3842
}
3943

4044
$missingTypeLines = [];
@@ -43,6 +47,6 @@ public function processNode(Node $node, Scope $scope): ?array
4347
$missingTypeLines[] = $node->getLine();
4448
}
4549

46-
return [1, $missingTypeLines];
50+
return [1, $missingTypeLines, $traitFilePath];
4751
}
4852
}

0 commit comments

Comments
 (0)