Skip to content

Commit ffbce28

Browse files
committed
Scope - support for getting native types for function/method parameters (with no regard to phpDocs)
1 parent 82773e5 commit ffbce28

9 files changed

Lines changed: 333 additions & 28 deletions

File tree

src/Analyser/DirectScopeFactory.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use PHPStan\Reflection\ParametersAcceptor;
99
use PHPStan\Reflection\ReflectionProvider;
1010
use PHPStan\Rules\Properties\PropertyReflectionFinder;
11+
use PHPStan\Type\Type;
1112

1213
/**
1314
* @internal
@@ -71,6 +72,7 @@ public function __construct(
7172
* @param \PHPStan\Reflection\ParametersAcceptor|null $anonymousFunctionReflection
7273
* @param bool $inFirstLevelStatement
7374
* @param array<string, true> $currentlyAssignedExpressions
75+
* @param array<string, Type> $nativeExpressionTypes
7476
*
7577
* @return MutatingScope
7678
*/
@@ -84,7 +86,8 @@ public function create(
8486
?string $inClosureBindScopeClass = null,
8587
?ParametersAcceptor $anonymousFunctionReflection = null,
8688
bool $inFirstLevelStatement = true,
87-
array $currentlyAssignedExpressions = []
89+
array $currentlyAssignedExpressions = [],
90+
array $nativeExpressionTypes = []
8891
): MutatingScope
8992
{
9093
$scopeClass = $this->scopeClass;
@@ -110,6 +113,7 @@ public function create(
110113
$anonymousFunctionReflection,
111114
$inFirstLevelStatement,
112115
$currentlyAssignedExpressions,
116+
$nativeExpressionTypes,
113117
$this->dynamicConstantNames
114118
);
115119
}

src/Analyser/LazyScopeFactory.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use PHPStan\Reflection\ParametersAcceptor;
1010
use PHPStan\Reflection\ReflectionProvider;
1111
use PHPStan\Rules\Properties\PropertyReflectionFinder;
12+
use PHPStan\Type\Type;
1213

1314
class LazyScopeFactory implements ScopeFactory
1415
{
@@ -43,6 +44,7 @@ public function __construct(
4344
* @param \PHPStan\Reflection\ParametersAcceptor|null $anonymousFunctionReflection
4445
* @param bool $inFirstLevelStatement
4546
* @param array<string, true> $currentlyAssignedExpressions
47+
* @param array<string, Type> $nativeExpressionTypes
4648
*
4749
* @return MutatingScope
4850
*/
@@ -56,7 +58,8 @@ public function create(
5658
?string $inClosureBindScopeClass = null,
5759
?ParametersAcceptor $anonymousFunctionReflection = null,
5860
bool $inFirstLevelStatement = true,
59-
array $currentlyAssignedExpressions = []
61+
array $currentlyAssignedExpressions = [],
62+
array $nativeExpressionTypes = []
6063
): MutatingScope
6164
{
6265
$scopeClass = $this->scopeClass;
@@ -82,6 +85,7 @@ public function create(
8285
$anonymousFunctionReflection,
8386
$inFirstLevelStatement,
8487
$currentlyAssignedExpressions,
88+
$nativeExpressionTypes,
8589
$this->dynamicConstantNames
8690
);
8791
}

0 commit comments

Comments
 (0)