Skip to content
This repository has been archived by the owner on Sep 9, 2018. It is now read-only.

Commit

Permalink
Update this plugin to use latest plugin capability
Browse files Browse the repository at this point in the history
  • Loading branch information
TysonAndre committed Mar 2, 2018
1 parent 9220812 commit 373915d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
}
],
"require-dev": {
"phan/phan": "master"
"phan/phan": "^0.12.2"
}
}
14 changes: 7 additions & 7 deletions src/UnusedVariablePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
use Phan\Language\Element\FunctionInterface;
use Phan\Language\Element\Variable;
use Phan\PluginV2;
use Phan\PluginV2\AnalyzeNodeCapability;
use Phan\PluginV2\PluginAwareAnalysisVisitor;
use Phan\PluginV2\PluginAwarePostAnalysisVisitor;
use Phan\PluginV2\PostAnalyzeNodeCapability;
use ast\Node;

// By default, don't warn about parameters beginning with "$unused"
Expand All @@ -45,7 +45,7 @@
*
* It hooks into one event:
*
* - getAnalyzeNodeVisitorClassName
* - getPostAnalyzeNodeVisitorClassName
* This method returns a class that is called on every AST node from every
* file being analyzed
*
Expand All @@ -62,13 +62,13 @@
* add them to the corresponding section of README.md
*/
final class UnusedVariablePlugin extends PluginV2
implements AnalyzeNodeCapability {
implements PostAnalyzeNodeCapability {

/**
* @return string - The name of the visitor that will be called (formerly analyzeNode)
* @override
*/
public static function getAnalyzeNodeVisitorClassName() : string
public static function getPostAnalyzeNodeVisitorClassName() : string
{
return UnusedVariableReferenceAnnotatorVisitor::class;
}
Expand All @@ -81,7 +81,7 @@ public static function getAnalyzeNodeVisitorClassName() : string
* Visitors such as this are useful for defining lots of different
* checks on a node based on its kind.
*/
final class UnusedVariableReferenceAnnotatorVisitor extends PluginAwareAnalysisVisitor {
final class UnusedVariableReferenceAnnotatorVisitor extends PluginAwarePostAnalysisVisitor {
// A plugin's visitors should NOT implement visit(), unless they need to.

// AST node types that would both can be references, and would affect analysis.
Expand Down Expand Up @@ -333,7 +333,7 @@ private function analyzeCallToMethodForReferences(
}
}

class UnusedVariableVisitor extends PluginAwareAnalysisVisitor {
class UnusedVariableVisitor extends PluginAwarePostAnalysisVisitor {
const RECORD_ASSIGNS = false;
const DONT_RECORD_ASSIGNS = true;

Expand Down
2 changes: 2 additions & 0 deletions tests/expected/all_output.expected
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ src/000_all.php:468 PhanPluginUnusedVariable Variable is never used: $validate
src/000_all.php:475 PhanPluginUnusedVariable Variable is never used: $a
src/001_func.php:7 PhanPluginUnusedVariable Variable is never used: $one
src/001_func.php:8 PhanPluginUnusedVariable Variable is never used: $two
src/001_func.php:9 PhanNoopBinaryOperator Unused result of a binary '+' operator
src/001_func.php:25 PhanPluginUnusedPublicMethodArgument Parameter is never used: $three
src/002_closure.php:7 PhanPluginUnusedVariable Variable is never used: $one
src/002_closure.php:8 PhanPluginUnusedVariable Variable is never used: $two
src/002_closure.php:9 PhanNoopBinaryOperator Unused result of a binary '+' operator
src/002_closure.php:24 PhanPluginUnusedPublicMethodArgument Parameter is never used: $three
src/005_static_variables.php:24 PhanPluginUnusedVariable Variable is never used: $initialized
src/006_references.php:14 PhanPluginUnusedPublicMethodArgument Parameter is never used: $fifteen
Expand Down

0 comments on commit 373915d

Please sign in to comment.