Skip to content

Commit

Permalink
Fix PhanUnreferencedUseNormal from phan
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
driusan authored and ircmaxell committed Apr 18, 2019
1 parent ffa1b39 commit f7a651f
Show file tree
Hide file tree
Showing 20 changed files with 18 additions and 56 deletions.
2 changes: 0 additions & 2 deletions .phan/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@
'suppress_issue_types' => [
'PhanTypeInvalidBitwiseBinaryOperator',
'PhanTypeObjectUnsetDeclaredProperty',
'PhanUnreferencedUseNormal',
'PhanUndeclaredClassMethod',
'PhanTypeMismatchProperty',
'PhanTypeExpectedObjectPropAccessButGotNull',
'PhanUnreferencedUseNormal',
'PhanTypeMismatchDimFetchNullable',
'PhanUndeclaredMethod',
'PhanTypeMismatchArgument',
Expand Down
3 changes: 2 additions & 1 deletion lib/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@

namespace PHPCompiler;

// used as a property type.
// @phan-suppress-next-line PhanUnreferencedUseNormal
use PHPCfg\Func;
use PHPCfg\Block as CfgBlock;
use PHPCfg\Op\Expr;
use PHPCfg\Operand;
use PHPCompiler\VM\Context;
use PHPCompiler\VM\Variable;
Expand Down
5 changes: 3 additions & 2 deletions lib/Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

namespace PHPCompiler;

// This is used as a property type, phan is confused.
// @phan-suppress-next-line PhanUnreferencedUseNormal
use SplObjectStorage;
use PHPCfg\Func as CfgFunc;
use PHPCfg\Op;
Expand All @@ -17,7 +19,6 @@
use PHPCfg\Script;
use PHPTypes\Type;
use PHPCompiler\VM\Variable;
use PHPCompiler\NativeType\NativeArray;

class Compiler {

Expand Down Expand Up @@ -553,4 +554,4 @@ protected function compileTerminal(Op\Terminal $terminal, Block $block): OpCode
}
}

}
}
3 changes: 1 addition & 2 deletions lib/Func.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
namespace PHPCompiler;

use PHPCompiler\VM\Context;
use PHPCompiler\VM\Variable;

abstract class Func {

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

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

}
}
3 changes: 1 addition & 2 deletions lib/Func/PHP.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use PHPCompiler\Frame;
use PHPCompiler\Block;
use PHPCompiler\VM\Context;
use PHPCompiler\VM\Variable;

final class PHP extends Func {

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

}
}
4 changes: 0 additions & 4 deletions lib/JIT.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,11 @@

use PHPCfg\Operand;
use PHPCfg\Op;
use PHPCfg\Block as CfgBlock;
use PHPTypes\Type;
use PHPCompiler\JIT\Analyzer;
use PHPCompiler\JIT\Context;
use PHPCompiler\JIT\Variable;

use PHPCompiler\Func as CoreFunc;
use PHPCompiler\JIT\Func as JITFunc;
use PHPCompiler\NativeType\NativeArray as NativeArray;

use PHPLLVM;

Expand Down
4 changes: 0 additions & 4 deletions lib/JIT.pre
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,11 @@ namespace PHPCompiler;

use PHPCfg\Operand;
use PHPCfg\Op;
use PHPCfg\Block as CfgBlock;
use PHPTypes\Type;
use PHPCompiler\JIT\Analyzer;
use PHPCompiler\JIT\Context;
use PHPCompiler\JIT\Variable;

use PHPCompiler\Func as CoreFunc;
use PHPCompiler\JIT\Func as JITFunc;
use PHPCompiler\NativeType\NativeArray as NativeArray;

use PHPLLVM;

Expand Down
4 changes: 1 addition & 3 deletions lib/JIT/Builtin/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

use PHPCompiler\JIT\Builtin;

use PHPLLVM;

class Type extends Builtin {

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


}
}
4 changes: 1 addition & 3 deletions lib/JIT/Builtin/Type/HashTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
namespace PHPCompiler\JIT\Builtin\Type;

use PHPCompiler\JIT\Builtin\Type;
use PHPCompiler\JIT\Builtin\Refcount;
use PHPCompiler\JIT\Variable;

class HashTable extends Type {
private \gcc_jit_struct_ptr $struct;
Expand Down Expand Up @@ -84,4 +82,4 @@ public function implement(): void {
\gcc_jit_field_ptr_ptr::fromArray(...array_values($this->bucketFields))
);
}
}
}
6 changes: 1 addition & 5 deletions lib/JIT/Builtin/Type/MaskedArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@

namespace PHPCompiler\JIT\Builtin\Type;

use PHPCfg\Operand;
use PHPCfg\Operand\Literal;
use PHPCompiler\JIT\Builtin\Type;
use PHPCompiler\JIT\Builtin\Refcount;
use PHPCompiler\JIT\Variable;
use PHPCompiler\JIT\Func;

class MaskedArray extends Type {
private \gcc_jit_struct_ptr $struct;
Expand Down Expand Up @@ -256,4 +252,4 @@ public function size(\gcc_jit_rvalue_ptr $ptr): \gcc_jit_rvalue_ptr {
}


}
}
3 changes: 0 additions & 3 deletions lib/JIT/Builtin/Type/Value.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@
namespace PHPCompiler\JIT\Builtin\Type;

use PHPCompiler\JIT\Builtin\Type;
use PHPCompiler\JIT\Builtin\Refcount;
use PHPCompiler\JIT\Variable;

use PHPLLVM;

class Value extends Type {

public function register(): void {
Expand Down
3 changes: 0 additions & 3 deletions lib/JIT/Builtin/Type/Value.pre
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@
namespace PHPCompiler\JIT\Builtin\Type;

use PHPCompiler\JIT\Builtin\Type;
use PHPCompiler\JIT\Builtin\Refcount;
use PHPCompiler\JIT\Variable;

use PHPLLVM;

class Value extends Type {

public function register(): void {
Expand Down
2 changes: 0 additions & 2 deletions lib/JIT/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@

use PHPCfg\Operand;
use PHPCompiler\Runtime;
use PHPCompiler\Handler;
use PHPCompiler\Block;
use PHPCompiler\VM\Variable as VMVariable;
use PHPCompiler\Handler\Builtins;
use PHPTypes\Type;

use PHPLLVM;
Expand Down
6 changes: 1 addition & 5 deletions lib/JIT/Scope.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@

namespace PHPCompiler\JIT;

use PHPCfg\Operand;

use PHPLLVM;

class Scope {
public int $classId = 0;
public \SplObjectStorage $blockStorage;
Expand All @@ -24,4 +20,4 @@ public function __construct() {
$this->blockStorage = new \SplObjectStorage;
$this->variables = new \SplObjectStorage;
}
}
}
1 change: 0 additions & 1 deletion lib/Runtime.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use PHPCfg\Traverser;
use PHPCfg\LivenessDetector;
use PHPCfg\Visitor;
use PHPCfg\Printer as CfgPrinter;
use PHPCfg\Script;
use PHPTypes\TypeReconstructor;
use PhpParser\NodeTraverser;
Expand Down
1 change: 0 additions & 1 deletion lib/VM.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

namespace PHPCompiler;

use PHPTypes\Type;
use PHPCompiler\VM\Context;
use PHPCompiler\VM\ClassEntry;
use PHPCompiler\VM\ObjectEntry;
Expand Down
4 changes: 3 additions & 1 deletion lib/VM/ClassEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

namespace PHPCompiler\VM;

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

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

}
}
4 changes: 1 addition & 3 deletions lib/VM/ClassProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

namespace PHPCompiler\VM;

use PHPCompiler\Block;

class ClassProperty {

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


}
}
2 changes: 0 additions & 2 deletions lib/VM/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
use PHPCompiler\Frame;
use PHPCompiler\Func;
use PHPCompiler\Runtime;
use PHPCompiler\Handler\Builtins;
use PHPTypes\Type;

class Context {
public array $functions = [];
Expand Down
10 changes: 3 additions & 7 deletions lib/VM/ObjectEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@

namespace PHPCompiler\VM;

use PHPCfg\Func;
use PHPCfg\Op;
use PHPCfg\Block as CfgBlock;
use PHPCfg\Operand;
use PHPCfg\Script;
use PHPTypes\Type;
// Bug in phan: https://github.com/phan/phan/issues/2661
// @phan-suppress-next-line PhanUnreferencedUseNormal
use PHPCompiler\Block;

class ObjectEntry {
Expand Down Expand Up @@ -44,4 +40,4 @@ public function getProperties(int $purpose): array {
return $this->class->getProperties($this->properties, $purpose);
}

}
}

0 comments on commit f7a651f

Please sign in to comment.