Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4138875
DollarDollarPlugin.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
DollarDollarPlugin.php
View Options
<?php
declare
(
strict_types
=
1
);
use
ast\Node
;
use
Phan\PluginV3
;
use
Phan\PluginV3\PluginAwarePostAnalysisVisitor
;
use
Phan\PluginV3\PostAnalyzeNodeCapability
;
/**
* This plugin checks for occurrences of `$$x`,
* which may be a typo, or behave differently in php 5 vs 7, or be hard to analyze code.
*
* This file demonstrates plugins for Phan. Plugins hook into various events.
* DollarDollarPlugin hooks into one event:
*
* - getPostAnalyzeNodeVisitorClassName
* This method returns a visitor that is called on every AST node from every
* file being analyzed
*
* A plugin file must
*
* - Contain a class that inherits from \Phan\PluginV3
*
* - End by returning an instance of that class.
*
* It is assumed without being checked that plugins aren't
* mangling state within the passed code base or context.
*
* Note: When adding new plugins,
* add them to the corresponding section of README.md
*/
class
DollarDollarPlugin
extends
PluginV3
implements
PostAnalyzeNodeCapability
{
/**
* @return string - name of PluginAwarePostAnalysisVisitor subclass
*/
public
static
function
getPostAnalyzeNodeVisitorClassName
():
string
{
return
DollarDollarVisitor
::
class
;
}
}
/**
* When __invoke on this class is called with a node, a method
* will be dispatched based on the `kind` of the given node.
*
* Visitors such as this are useful for defining lots of different
* checks on a node based on its kind.
*/
class
DollarDollarVisitor
extends
PluginAwarePostAnalysisVisitor
{
// A plugin's visitors should not override visit() unless they need to.
/**
* @param Node $node
* A node to analyze
* @override
*/
public
function
visitVar
(
Node
$node
):
void
{
if
(
$node
->
children
[
'name'
]
instanceof
Node
)
{
$this
->
emitPluginIssue
(
$this
->
code_base
,
$this
->
context
,
'PhanPluginDollarDollar'
,
"$$ Variables are not allowed."
,
[]
);
}
}
}
// Every plugin needs to return an instance of itself at the
// end of the file in which it's defined.
return
new
DollarDollarPlugin
();
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Wed, Aug 19, 14:50 (3 w, 5 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
fb/22/0761eef66b50414ba79c5e0d5ec5
Default Alt Text
DollarDollarPlugin.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment