Skip to content

Commit 76fefc6

Browse files
ondrejmirtesclaude
andcommitted
Rename DependencyEmitter to DependencyTracker
The methods are trackValueDependency() and trackFileDependency() now. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GdwtgiEHwkF5BTz73jgHQQ
1 parent 261a431 commit 76fefc6

30 files changed

Lines changed: 88 additions & 88 deletions

‎e2e/result-cache-file-dependency/extension/ConfigRule.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use PhpParser\Node;
66
use PhpParser\Node\Expr\FuncCall;
77
use PhpParser\Node\Name;
8-
use PHPStan\Analyser\DependencyEmitter;
8+
use PHPStan\Analyser\DependencyTracker;
99
use PHPStan\Analyser\Scope;
1010
use PHPStan\Rules\Rule;
1111
use PHPStan\Rules\RuleErrorBuilder;
@@ -25,7 +25,7 @@ public function getNodeType(): string
2525
}
2626

2727
/**
28-
* @param Scope&DependencyEmitter $scope
28+
* @param Scope&DependencyTracker $scope
2929
*/
3030
public function processNode(Node $node, Scope $scope): array
3131
{
@@ -34,7 +34,7 @@ public function processNode(Node $node, Scope $scope): array
3434
}
3535

3636
$configFile = dirname(__DIR__) . '/src/Config.php';
37-
$scope->fileDependency($configFile);
37+
$scope->trackFileDependency($configFile);
3838

3939
if (!is_file($configFile)) {
4040
return [];

‎e2e/result-cache-file-dependency/extension/DataFile.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace ResultCacheE2EFileDependency;
44

5-
use PHPStan\Analyser\DependencyEmitter;
5+
use PHPStan\Analyser\DependencyTracker;
66
use PHPStan\Analyser\Scope;
77
use PHPStan\Type\Constant\ConstantStringType;
88
use PHPStan\Type\IntegerType;
@@ -15,12 +15,12 @@ final class DataFile
1515
* The return type comes from a data file the extension reads on its own: int when it says so,
1616
* otherwise the string it contains, 'missing' when there is no such file.
1717
*
18-
* @param Scope&DependencyEmitter $scope
18+
* @param Scope&DependencyTracker $scope
1919
*/
2020
public static function type(string $name, Scope $scope): Type
2121
{
2222
$file = dirname(__DIR__) . '/data/' . $name . '.txt';
23-
$scope->fileDependency($file);
23+
$scope->trackFileDependency($file);
2424

2525
if (!is_file($file)) {
2626
return new ConstantStringType('missing');

‎e2e/result-cache-file-dependency/extension/DataFunctionReturnTypeExtension.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace ResultCacheE2EFileDependency;
44

55
use PhpParser\Node\Expr\FuncCall;
6-
use PHPStan\Analyser\DependencyEmitter;
6+
use PHPStan\Analyser\DependencyTracker;
77
use PHPStan\Analyser\Scope;
88
use PHPStan\Reflection\FunctionReflection;
99
use PHPStan\Type\DynamicFunctionReturnTypeExtension;
@@ -18,7 +18,7 @@ public function isFunctionSupported(FunctionReflection $functionReflection): boo
1818
}
1919

2020
/**
21-
* @param Scope&DependencyEmitter $scope
21+
* @param Scope&DependencyTracker $scope
2222
*/
2323
public function getTypeFromFunctionCall(FunctionReflection $functionReflection, FuncCall $functionCall, Scope $scope): Type
2424
{

‎e2e/result-cache-file-dependency/extension/DataMethodReturnTypeExtension.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace ResultCacheE2EFileDependency;
44

55
use PhpParser\Node\Expr\MethodCall;
6-
use PHPStan\Analyser\DependencyEmitter;
6+
use PHPStan\Analyser\DependencyTracker;
77
use PHPStan\Analyser\Scope;
88
use PHPStan\Reflection\MethodReflection;
99
use PHPStan\Type\DynamicMethodReturnTypeExtension;
@@ -23,7 +23,7 @@ public function isMethodSupported(MethodReflection $methodReflection): bool
2323
}
2424

2525
/**
26-
* @param Scope&DependencyEmitter $scope
26+
* @param Scope&DependencyTracker $scope
2727
*/
2828
public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): Type
2929
{

‎e2e/result-cache-file-dependency/extension/DataStaticMethodReturnTypeExtension.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace ResultCacheE2EFileDependency;
44

55
use PhpParser\Node\Expr\StaticCall;
6-
use PHPStan\Analyser\DependencyEmitter;
6+
use PHPStan\Analyser\DependencyTracker;
77
use PHPStan\Analyser\Scope;
88
use PHPStan\Reflection\MethodReflection;
99
use PHPStan\Type\DynamicStaticMethodReturnTypeExtension;
@@ -23,7 +23,7 @@ public function isStaticMethodSupported(MethodReflection $methodReflection): boo
2323
}
2424

2525
/**
26-
* @param Scope&DependencyEmitter $scope
26+
* @param Scope&DependencyTracker $scope
2727
*/
2828
public function getTypeFromStaticMethodCall(MethodReflection $methodReflection, StaticCall $methodCall, Scope $scope): Type
2929
{

‎e2e/result-cache-value-dependency/extension/ParameterReturnTypeExtension.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use PhpParser\Node\Expr\FuncCall;
66
use PhpParser\Node\Scalar\String_;
7-
use PHPStan\Analyser\DependencyEmitter;
7+
use PHPStan\Analyser\DependencyTracker;
88
use PHPStan\Analyser\Scope;
99
use PHPStan\Reflection\FunctionReflection;
1010
use PHPStan\Type\Constant\ConstantIntegerType;
@@ -21,7 +21,7 @@ public function isFunctionSupported(FunctionReflection $functionReflection): boo
2121
}
2222

2323
/**
24-
* @param Scope&DependencyEmitter $scope
24+
* @param Scope&DependencyTracker $scope
2525
*/
2626
public function getTypeFromFunctionCall(FunctionReflection $functionReflection, FuncCall $functionCall, Scope $scope): ?Type
2727
{
@@ -30,7 +30,7 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
3030
return null;
3131
}
3232

33-
$scope->valueDependency(ParameterValueExtension::class, $arg->value);
33+
$scope->trackValueDependency(ParameterValueExtension::class, $arg->value);
3434
$value = Container::getParameter($arg->value);
3535
if ($value === null) {
3636
return null;

‎e2e/result-cache-value-dependency/extension/ServiceReturnTypeExtension.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use PhpParser\Node\Expr\FuncCall;
66
use PhpParser\Node\Scalar\String_;
7-
use PHPStan\Analyser\DependencyEmitter;
7+
use PHPStan\Analyser\DependencyTracker;
88
use PHPStan\Analyser\Scope;
99
use PHPStan\Reflection\FunctionReflection;
1010
use PHPStan\Type\DynamicFunctionReturnTypeExtension;
@@ -20,7 +20,7 @@ public function isFunctionSupported(FunctionReflection $functionReflection): boo
2020
}
2121

2222
/**
23-
* @param Scope&DependencyEmitter $scope
23+
* @param Scope&DependencyTracker $scope
2424
*/
2525
public function getTypeFromFunctionCall(FunctionReflection $functionReflection, FuncCall $functionCall, Scope $scope): ?Type
2626
{
@@ -30,7 +30,7 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
3030
}
3131

3232
// the same value ServiceRule declares - recorded once
33-
$scope->valueDependency(HasServiceValueExtension::class, $arg->value);
33+
$scope->trackValueDependency(HasServiceValueExtension::class, $arg->value);
3434
$class = Container::getService($arg->value);
3535

3636
return $class !== null ? new ObjectType($class) : null;

‎e2e/result-cache-value-dependency/extension/ServiceRule.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use PhpParser\Node\Expr\FuncCall;
77
use PhpParser\Node\Name;
88
use PhpParser\Node\Scalar\String_;
9-
use PHPStan\Analyser\DependencyEmitter;
9+
use PHPStan\Analyser\DependencyTracker;
1010
use PHPStan\Analyser\Scope;
1111
use PHPStan\Rules\Rule;
1212
use PHPStan\Rules\RuleErrorBuilder;
@@ -23,7 +23,7 @@ public function getNodeType(): string
2323
}
2424

2525
/**
26-
* @param Scope&DependencyEmitter $scope
26+
* @param Scope&DependencyTracker $scope
2727
*/
2828
public function processNode(Node $node, Scope $scope): array
2929
{
@@ -32,7 +32,7 @@ public function processNode(Node $node, Scope $scope): array
3232
}
3333

3434
$id = $node->getArgs()[0]->value->value;
35-
$scope->valueDependency(HasServiceValueExtension::class, $id);
35+
$scope->trackValueDependency(HasServiceValueExtension::class, $id);
3636
if (Container::getService($id) !== null) {
3737
return [];
3838
}
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,34 @@
55
use PHPStan\Analyser\ResultCache\ResultCacheValueExtension;
66

77
/**
8-
* The interface DependencyEmitter can be typehinted in 2nd parameter of Rule::processNode(),
8+
* The interface DependencyTracker can be typehinted in 2nd parameter of Rule::processNode(),
99
* and in the Scope parameter of dynamic return type extensions and expression type resolver
1010
* extensions:
1111
*
1212
* ```php
1313
* /**
14-
* * @param Scope&DependencyEmitter $scope
14+
* * @param Scope&DependencyTracker $scope
1515
* *\/
1616
* public function processNode(Node $node, Scope $scope): array
1717
* ```
1818
*
1919
* The intersection goes to the PHPDoc: the native parameter type stays Scope, which is what the
2020
* interfaces declare once PHPStan is downgraded for older PHP versions.
2121
*
22-
* It declares what the analysis of the current file depends on besides the analysed code, so
23-
* that the result cache re-analyses the file when that changes - see ResultCacheValueExtension.
22+
* It tracks what the analysis of the current file depends on besides the analysed code, so that
23+
* the result cache re-analyses the file when that changes - see ResultCacheValueExtension.
2424
*
2525
* @api
2626
*/
27-
interface DependencyEmitter
27+
interface DependencyTracker
2828
{
2929

3030
/**
3131
* The analysis of the current file depends on the value $extensionClass gives for $key.
3232
*
3333
* @param class-string<ResultCacheValueExtension> $extensionClass
3434
*/
35-
public function valueDependency(string $extensionClass, string $key): void;
35+
public function trackValueDependency(string $extensionClass, string $key): void;
3636

3737
/**
3838
* The analysis of the current file depends on the contents of $file - a data file, a template,
@@ -41,6 +41,6 @@ public function valueDependency(string $extensionClass, string $key): void;
4141
*
4242
* The path should be absolute. The file does not have to exist.
4343
*/
44-
public function fileDependency(string $file): void;
44+
public function trackFileDependency(string $file): void;
4545

4646
}

‎src/Analyser/FileAnalyserCallback.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function __invoke(Node $node, Scope $scope): void
107107

108108
$parserNodes = $this->parserNodes;
109109

110-
/** @var Scope&NodeCallbackInvoker&CollectedDataEmitter&DependencyEmitter $scope */
110+
/** @var Scope&NodeCallbackInvoker&CollectedDataEmitter&DependencyTracker $scope */
111111
if ($node instanceof Node\Stmt\Trait_) {
112112
foreach (array_keys($this->linesToIgnore[$this->file] ?? []) as $lineToIgnore) {
113113
if ($lineToIgnore < $node->getStartLine() || $lineToIgnore > $node->getEndLine()) {
@@ -182,9 +182,9 @@ public function __invoke(Node $node, Scope $scope): void
182182

183183
foreach ($ruleErrors as $ruleError) {
184184
if ($ruleError instanceof FileDependenciesRuleError) {
185-
// the deprecated way of DependencyEmitter::fileDependency()
185+
// the deprecated way of DependencyTracker::trackFileDependency()
186186
foreach ($ruleError->getFileDependencies() as $fileDependency) {
187-
$scope->fileDependency($fileDependency);
187+
$scope->trackFileDependency($fileDependency);
188188
}
189189
}
190190

0 commit comments

Comments
 (0)