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+
}

0 commit comments

Comments
 (0)