Skip to content

Commit 5ddca42

Browse files
committed
All FunctionReflection implementations have getFileName()
1 parent c836a42 commit 5ddca42

5 files changed

Lines changed: 20 additions & 0 deletions

File tree

src/Analyser/MutatingScope.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2831,6 +2831,7 @@ public function enterClassMethod(
28312831
new PhpMethodFromParserNodeReflection(
28322832
$this->getClassReflection(),
28332833
$classMethod,
2834+
$this->getFile(),
28342835
$templateTypeMap,
28352836
$this->getRealParameterTypes($classMethod),
28362837
array_map(static function (Type $type): Type {
@@ -2940,6 +2941,7 @@ public function enterFunction(
29402941
return $this->enterFunctionLike(
29412942
new PhpFunctionFromParserNodeReflection(
29422943
$function,
2944+
$this->getFile(),
29432945
$templateTypeMap,
29442946
$this->getRealParameterTypes($function),
29452947
array_map(static function (Type $type): Type {

src/Reflection/FunctionReflection.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ interface FunctionReflection
1111

1212
public function getName(): string;
1313

14+
public function getFileName(): ?string;
15+
1416
/**
1517
* @return \PHPStan\Reflection\ParametersAcceptor[]
1618
*/

src/Reflection/Native/NativeFunctionReflection.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ public function getName(): string
4646
return $this->name;
4747
}
4848

49+
public function getFileName(): ?string
50+
{
51+
return null;
52+
}
53+
4954
/**
5055
* @return \PHPStan\Reflection\ParametersAcceptor[]
5156
*/

src/Reflection/Php/PhpFunctionFromParserNodeReflection.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class PhpFunctionFromParserNodeReflection implements \PHPStan\Reflection\Functio
1919

2020
private \PhpParser\Node\FunctionLike $functionLike;
2121

22+
private string $fileName;
23+
2224
private \PHPStan\Type\Generic\TemplateTypeMap $templateTypeMap;
2325

2426
/** @var \PHPStan\Type\Type[] */
@@ -66,6 +68,7 @@ class PhpFunctionFromParserNodeReflection implements \PHPStan\Reflection\Functio
6668
*/
6769
public function __construct(
6870
FunctionLike $functionLike,
71+
string $fileName,
6972
TemplateTypeMap $templateTypeMap,
7073
array $realParameterTypes,
7174
array $phpDocParameterTypes,
@@ -81,6 +84,7 @@ public function __construct(
8184
)
8285
{
8386
$this->functionLike = $functionLike;
87+
$this->fileName = $fileName;
8488
$this->templateTypeMap = $templateTypeMap;
8589
$this->realParameterTypes = $realParameterTypes;
8690
$this->phpDocParameterTypes = $phpDocParameterTypes;
@@ -100,6 +104,11 @@ protected function getFunctionLike(): FunctionLike
100104
return $this->functionLike;
101105
}
102106

107+
public function getFileName(): string
108+
{
109+
return $this->fileName;
110+
}
111+
103112
public function getName(): string
104113
{
105114
if ($this->functionLike instanceof ClassMethod) {

src/Reflection/Php/PhpMethodFromParserNodeReflection.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class PhpMethodFromParserNodeReflection extends PhpFunctionFromParserNodeReflect
4040
public function __construct(
4141
ClassReflection $declaringClass,
4242
ClassMethod $classMethod,
43+
string $fileName,
4344
TemplateTypeMap $templateTypeMap,
4445
array $realParameterTypes,
4546
array $phpDocParameterTypes,
@@ -79,6 +80,7 @@ public function __construct(
7980

8081
parent::__construct(
8182
$classMethod,
83+
$fileName,
8284
$templateTypeMap,
8385
$realParameterTypes,
8486
$phpDocParameterTypes,

0 commit comments

Comments
 (0)