Skip to content

Commit 449ca0a

Browse files
authored
Merge branch refs/heads/1.12.x into 2.1.x
2 parents 9d1239b + 2f74584 commit 449ca0a

File tree

3 files changed

+59
-2
lines changed

3 files changed

+59
-2
lines changed

Diff for: src/Reflection/Php/PhpClassReflectionExtension.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -728,8 +728,8 @@ public function createUserlandMethodReflection(ClassReflection $fileDeclaringCla
728728

729729
$resolvedPhpDoc = $this->phpDocInheritanceResolver->resolvePhpDocForMethod(
730730
$docComment,
731-
$fileDeclaringClass->getFileName(),
732-
$fileDeclaringClass,
731+
$actualDeclaringClass->getFileName(),
732+
$actualDeclaringClass,
733733
$declaringTraitName,
734734
$methodReflection->getName(),
735735
$positionalParameterNames,

Diff for: tests/PHPStan/Rules/Methods/MethodSignatureRuleTest.php

+11
Original file line numberDiff line numberDiff line change
@@ -530,4 +530,15 @@ public function testBug3580(): void
530530
$this->analyse([__DIR__ . '/data/bug-3580.php'], []);
531531
}
532532

533+
public function testOverridenAbstractTraitMethodPhpDoc(): void
534+
{
535+
if (PHP_VERSION_ID < 80000) {
536+
$this->markTestSkipped('Test requires PHP 8.0.');
537+
}
538+
539+
$this->reportMaybes = true;
540+
$this->reportStatic = true;
541+
$this->analyse([__DIR__ . '/data/overriden-abstract-trait-method-phpdoc.php'], []);
542+
}
543+
533544
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
namespace OverridenAbstractTraitMethodPhpDoc;
4+
5+
/**
6+
* @template DataArray of array<string, mixed>
7+
*/
8+
trait FooTrait
9+
{
10+
/**
11+
* Offset checker
12+
*
13+
* @phpstan-param Offset $offset
14+
* @return bool
15+
* @template Offset of key-of<DataArray>
16+
*/
17+
abstract public function offsetExists(mixed $offset): bool;
18+
}
19+
20+
/**
21+
* @template DataArray of array<string, mixed>
22+
* @phpstan-type DataKey key-of<DataArray>
23+
* @phpstan-type DataValue DataArray[DataKey]
24+
*/
25+
class FooClass
26+
{
27+
28+
/** @phpstan-use FooTrait<DataArray> */
29+
use FooTrait;
30+
31+
/** @phpstan-var DataArray|array{} */
32+
public array $data = [];
33+
34+
35+
/**
36+
* Data checker
37+
*
38+
* @phpstan-param Offset $offset
39+
* @return bool
40+
* @template Offset of key-of<DataArray>
41+
*/
42+
public function offsetExists(mixed $offset): bool
43+
{
44+
return array_key_exists($offset, $this->data);
45+
}
46+
}

0 commit comments

Comments
 (0)