Skip to content

Commit f7a651f

Browse files
driusanircmaxell
authored andcommitted
Fix PhanUnreferencedUseNormal from phan
This removes references to "use" statements that aren't referenced anywhere in the file and fixes the PhanUnreferencedUseNormal "errors" that are flagged. For each "use" that was removed, I first checked the file to verify that there weren't, in fact, any references to them. There's a bug in phan where it doesn't understand typed property references as uses, so lines that were only referenced in that way are simply ignored for now.
1 parent ffa1b39 commit f7a651f

20 files changed

+18
-56
lines changed

.phan/config.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212
'suppress_issue_types' => [
1313
'PhanTypeInvalidBitwiseBinaryOperator',
1414
'PhanTypeObjectUnsetDeclaredProperty',
15-
'PhanUnreferencedUseNormal',
1615
'PhanUndeclaredClassMethod',
1716
'PhanTypeMismatchProperty',
1817
'PhanTypeExpectedObjectPropAccessButGotNull',
19-
'PhanUnreferencedUseNormal',
2018
'PhanTypeMismatchDimFetchNullable',
2119
'PhanUndeclaredMethod',
2220
'PhanTypeMismatchArgument',

lib/Block.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99

1010
namespace PHPCompiler;
1111

12+
// used as a property type.
13+
// @phan-suppress-next-line PhanUnreferencedUseNormal
1214
use PHPCfg\Func;
1315
use PHPCfg\Block as CfgBlock;
14-
use PHPCfg\Op\Expr;
1516
use PHPCfg\Operand;
1617
use PHPCompiler\VM\Context;
1718
use PHPCompiler\VM\Variable;

lib/Compiler.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
namespace PHPCompiler;
1111

12+
// This is used as a property type, phan is confused.
13+
// @phan-suppress-next-line PhanUnreferencedUseNormal
1214
use SplObjectStorage;
1315
use PHPCfg\Func as CfgFunc;
1416
use PHPCfg\Op;
@@ -17,7 +19,6 @@
1719
use PHPCfg\Script;
1820
use PHPTypes\Type;
1921
use PHPCompiler\VM\Variable;
20-
use PHPCompiler\NativeType\NativeArray;
2122

2223
class Compiler {
2324

@@ -553,4 +554,4 @@ protected function compileTerminal(Op\Terminal $terminal, Block $block): OpCode
553554
}
554555
}
555556

556-
}
557+
}

lib/Func.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
namespace PHPCompiler;
1111

1212
use PHPCompiler\VM\Context;
13-
use PHPCompiler\VM\Variable;
1413

1514
abstract class Func {
1615

@@ -26,4 +25,4 @@ public function getName(): string {
2625

2726
abstract public function getFrame(Context $context, ?Frame $frame = null): Frame;
2827

29-
}
28+
}

lib/Func/PHP.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use PHPCompiler\Frame;
1414
use PHPCompiler\Block;
1515
use PHPCompiler\VM\Context;
16-
use PHPCompiler\VM\Variable;
1716

1817
final class PHP extends Func {
1918

@@ -28,4 +27,4 @@ public function getFrame(Context $context, ?Frame $frame = null): Frame {
2827
return $this->block->getFrame($context, $frame);
2928
}
3029

31-
}
30+
}

lib/JIT.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,11 @@
1414

1515
use PHPCfg\Operand;
1616
use PHPCfg\Op;
17-
use PHPCfg\Block as CfgBlock;
1817
use PHPTypes\Type;
19-
use PHPCompiler\JIT\Analyzer;
2018
use PHPCompiler\JIT\Context;
2119
use PHPCompiler\JIT\Variable;
2220

2321
use PHPCompiler\Func as CoreFunc;
24-
use PHPCompiler\JIT\Func as JITFunc;
25-
use PHPCompiler\NativeType\NativeArray as NativeArray;
2622

2723
use PHPLLVM;
2824

lib/JIT.pre

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,11 @@ namespace PHPCompiler;
1111

1212
use PHPCfg\Operand;
1313
use PHPCfg\Op;
14-
use PHPCfg\Block as CfgBlock;
1514
use PHPTypes\Type;
16-
use PHPCompiler\JIT\Analyzer;
1715
use PHPCompiler\JIT\Context;
1816
use PHPCompiler\JIT\Variable;
1917

2018
use PHPCompiler\Func as CoreFunc;
21-
use PHPCompiler\JIT\Func as JITFunc;
22-
use PHPCompiler\NativeType\NativeArray as NativeArray;
2319

2420
use PHPLLVM;
2521

lib/JIT/Builtin/Type.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
use PHPCompiler\JIT\Builtin;
1313

14-
use PHPLLVM;
15-
1614
class Type extends Builtin {
1715

1816
public Type\String_ $string;
@@ -34,4 +32,4 @@ public function register(): void {
3432
}
3533

3634

37-
}
35+
}

lib/JIT/Builtin/Type/HashTable.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
namespace PHPCompiler\JIT\Builtin\Type;
1111

1212
use PHPCompiler\JIT\Builtin\Type;
13-
use PHPCompiler\JIT\Builtin\Refcount;
14-
use PHPCompiler\JIT\Variable;
1513

1614
class HashTable extends Type {
1715
private \gcc_jit_struct_ptr $struct;
@@ -84,4 +82,4 @@ public function implement(): void {
8482
\gcc_jit_field_ptr_ptr::fromArray(...array_values($this->bucketFields))
8583
);
8684
}
87-
}
85+
}

lib/JIT/Builtin/Type/MaskedArray.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,8 @@
99

1010
namespace PHPCompiler\JIT\Builtin\Type;
1111

12-
use PHPCfg\Operand;
13-
use PHPCfg\Operand\Literal;
1412
use PHPCompiler\JIT\Builtin\Type;
1513
use PHPCompiler\JIT\Builtin\Refcount;
16-
use PHPCompiler\JIT\Variable;
17-
use PHPCompiler\JIT\Func;
1814

1915
class MaskedArray extends Type {
2016
private \gcc_jit_struct_ptr $struct;
@@ -256,4 +252,4 @@ public function size(\gcc_jit_rvalue_ptr $ptr): \gcc_jit_rvalue_ptr {
256252
}
257253

258254

259-
}
255+
}

lib/JIT/Builtin/Type/Value.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,8 @@
1313
namespace PHPCompiler\JIT\Builtin\Type;
1414

1515
use PHPCompiler\JIT\Builtin\Type;
16-
use PHPCompiler\JIT\Builtin\Refcount;
1716
use PHPCompiler\JIT\Variable;
1817

19-
use PHPLLVM;
20-
2118
class Value extends Type {
2219

2320
public function register(): void {

lib/JIT/Builtin/Type/Value.pre

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,8 @@
1010
namespace PHPCompiler\JIT\Builtin\Type;
1111

1212
use PHPCompiler\JIT\Builtin\Type;
13-
use PHPCompiler\JIT\Builtin\Refcount;
1413
use PHPCompiler\JIT\Variable;
1514

16-
use PHPLLVM;
17-
1815
class Value extends Type {
1916

2017
public function register(): void {

lib/JIT/Context.php

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

1212
use PHPCfg\Operand;
1313
use PHPCompiler\Runtime;
14-
use PHPCompiler\Handler;
1514
use PHPCompiler\Block;
1615
use PHPCompiler\VM\Variable as VMVariable;
17-
use PHPCompiler\Handler\Builtins;
1816
use PHPTypes\Type;
1917

2018
use PHPLLVM;

lib/JIT/Scope.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99

1010
namespace PHPCompiler\JIT;
1111

12-
use PHPCfg\Operand;
13-
14-
use PHPLLVM;
15-
1612
class Scope {
1713
public int $classId = 0;
1814
public \SplObjectStorage $blockStorage;
@@ -24,4 +20,4 @@ public function __construct() {
2420
$this->blockStorage = new \SplObjectStorage;
2521
$this->variables = new \SplObjectStorage;
2622
}
27-
}
23+
}

lib/Runtime.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use PHPCfg\Traverser;
1515
use PHPCfg\LivenessDetector;
1616
use PHPCfg\Visitor;
17-
use PHPCfg\Printer as CfgPrinter;
1817
use PHPCfg\Script;
1918
use PHPTypes\TypeReconstructor;
2019
use PhpParser\NodeTraverser;

lib/VM.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
namespace PHPCompiler;
1111

12-
use PHPTypes\Type;
1312
use PHPCompiler\VM\Context;
1413
use PHPCompiler\VM\ClassEntry;
1514
use PHPCompiler\VM\ObjectEntry;

lib/VM/ClassEntry.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
namespace PHPCompiler\VM;
1111

12+
// bug in phan: https://github.com/phan/phan/issues/2661
13+
// @phan-suppress-next-line PhanUnreferencedUseNormal
1214
use PHPCompiler\Block;
1315

1416
class ClassEntry {
@@ -28,4 +30,4 @@ public function getProperties(array $properties, int $reason): array {
2830
return $properties;
2931
}
3032

31-
}
33+
}

lib/VM/ClassProperty.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
namespace PHPCompiler\VM;
1111

12-
use PHPCompiler\Block;
13-
1412
class ClassProperty {
1513

1614
public string $name;
@@ -33,4 +31,4 @@ public function getVariable(): Variable {
3331
}
3432

3533

36-
}
34+
}

lib/VM/Context.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
use PHPCompiler\Frame;
1313
use PHPCompiler\Func;
1414
use PHPCompiler\Runtime;
15-
use PHPCompiler\Handler\Builtins;
16-
use PHPTypes\Type;
1715

1816
class Context {
1917
public array $functions = [];

lib/VM/ObjectEntry.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,8 @@
99

1010
namespace PHPCompiler\VM;
1111

12-
use PHPCfg\Func;
13-
use PHPCfg\Op;
14-
use PHPCfg\Block as CfgBlock;
15-
use PHPCfg\Operand;
16-
use PHPCfg\Script;
17-
use PHPTypes\Type;
12+
// Bug in phan: https://github.com/phan/phan/issues/2661
13+
// @phan-suppress-next-line PhanUnreferencedUseNormal
1814
use PHPCompiler\Block;
1915

2016
class ObjectEntry {
@@ -44,4 +40,4 @@ public function getProperties(int $purpose): array {
4440
return $this->class->getProperties($this->properties, $purpose);
4541
}
4642

47-
}
43+
}

0 commit comments

Comments
 (0)