File tree 3 files changed +44
-1
lines changed
3 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -346,11 +346,18 @@ private static function resolvePhpDocBlockFromClass(
346
346
}
347
347
$ methodVariants = $ parentReflection ->getVariants ();
348
348
$ positionalMethodParameterNames = [];
349
- if (count ($ methodVariants ) === 1 ) {
349
+ $ lowercaseMethodName = strtolower ($ parentReflection ->getName ());
350
+ if (
351
+ count ($ methodVariants ) === 1
352
+ && $ lowercaseMethodName !== '__construct '
353
+ && $ lowercaseMethodName !== strtolower ($ parentReflection ->getDeclaringClass ()->getName ())
354
+ ) {
350
355
$ methodParameters = $ methodVariants [0 ]->getParameters ();
351
356
foreach ($ methodParameters as $ methodParameter ) {
352
357
$ positionalMethodParameterNames [] = $ methodParameter ->getName ();
353
358
}
359
+ } else {
360
+ $ positionalMethodParameterNames = $ positionalParameterNames ;
354
361
}
355
362
} else {
356
363
$ traitReflection = null ;
Original file line number Diff line number Diff line change @@ -9742,6 +9742,11 @@ public function dataPhpDocInheritanceParameterRemapping(): array
9742
9742
return $ this ->gatherAssertTypes (__DIR__ . '/data/inheritdoc-parameter-remapping.php ' );
9743
9743
}
9744
9744
9745
+ public function dataPhpDocInheritanceConstructors (): array
9746
+ {
9747
+ return $ this ->gatherAssertTypes (__DIR__ . '/data/inheritdoc-constructors.php ' );
9748
+ }
9749
+
9745
9750
public function dataListType (): array
9746
9751
{
9747
9752
return $ this ->gatherAssertTypes (__DIR__ . '/data/list-type.php ' );
@@ -9767,6 +9772,7 @@ public function dataListType(): array
9767
9772
* @dataProvider dataBug2648
9768
9773
* @dataProvider dataBug2740
9769
9774
* @dataProvider dataPhpDocInheritanceParameterRemapping
9775
+ * @dataProvider dataPhpDocInheritanceConstructors
9770
9776
* @dataProvider dataListType
9771
9777
* @dataProvider dataBug2822
9772
9778
* @param ConstantStringType $expectedType
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace InheritDocConstructors ;
4
+
5
+ use function PHPStan \Analyser \assertType ;
6
+
7
+ class Foo
8
+ {
9
+
10
+ /**
11
+ * @param string[] $data
12
+ */
13
+ public function __construct ($ data )
14
+ {
15
+ assertType ('array<string> ' , $ data );
16
+ }
17
+
18
+ }
19
+
20
+ class Bar extends Foo
21
+ {
22
+
23
+ public function __construct ($ name , $ data )
24
+ {
25
+ parent ::__construct ($ data );
26
+ assertType ('mixed ' , $ name );
27
+ assertType ('array<string> ' , $ data );
28
+ }
29
+
30
+ }
You can’t perform that action at this time.
0 commit comments