Skip to content

Commit

Permalink
Start migrating to PDepend 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
beberlei committed Nov 14, 2013
1 parent e04fbdf commit 8c3ebe1
Show file tree
Hide file tree
Showing 68 changed files with 184 additions and 262 deletions.
9 changes: 8 additions & 1 deletion composer.json
Expand Up @@ -5,7 +5,14 @@

"require": {
"php": ">=5.3.0",
"pdepend/pdepend": ">=1.1.1"
"pdepend/pdepend": "dev-master"
},

"autoload": {
"psr-0": {
"PHP_PMD": "src/main/php",
"PDepend\\": "vendor/pdepend/pdepend/src/main/php/"
}
},

"include-path": [
Expand Down
47 changes: 35 additions & 12 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion phpunit.xml.dist
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<phpunit>
<phpunit bootstrap="src/main/php/bootstrap.php">
<testsuites>
<testsuite name="PHP_PMD_AllTests">
<directory suffix="Test.php">src/test/php</directory>
Expand Down
4 changes: 0 additions & 4 deletions src/main/php/PHP/PMD.php
Expand Up @@ -45,10 +45,6 @@
* @link http://phpmd.org
*/

require_once 'PHP/PMD/ParserFactory.php';
require_once 'PHP/PMD/Report.php';
require_once 'PHP/PMD/RuleSetFactory.php';
require_once 'PHP/PMD/Writer/Stream.php';

/**
* This is the main facade of the PHP PMD application
Expand Down
26 changes: 12 additions & 14 deletions src/main/php/PHP/PMD/AbstractNode.php
Expand Up @@ -45,12 +45,10 @@
* @link http://phpmd.org
*/

require_once 'PHP/PMD/Node/ASTNode.php';
require_once 'PHP/PMD/Node/Annotations.php';

/**
* This is an abstract base class for PHP_PMD code nodes, it is just a wrapper
* around PHP_Depend's object model.
* around PDepend's object model.
*
* @category PHP
* @package PHP_PMD
Expand All @@ -64,7 +62,7 @@ abstract class PHP_PMD_AbstractNode
{
/**
*
* @var PHP_Depend_Code_AbstractItem|PHP_Depend_Code_ASTNode $node
* @var \PDepend\Source\AST\ASTArtifact|\PDepend\Source\AST\ASTNode $node
*/
private $node = null;

Expand All @@ -78,8 +76,8 @@ abstract class PHP_PMD_AbstractNode
/**
* Constructs a new PHP_PMD node.
*
* @param PHP_Depend_Code_AbstractItem|PHP_Depend_Code_ASTNode $node The wrapped
* PHP_Depend ast node instance or item object.
* @param \PDepend\Source\AST\ASTArtifact|\PDepend\Source\AST\ASTNode $node The wrapped
* PDepend ast node instance or item object.
*/
public function __construct($node)
{
Expand All @@ -88,13 +86,13 @@ public function __construct($node)

/**
* The magic call method is used to pipe requests from rules direct
* to the underlying PHP_Depend ast node.
* to the underlying PDepend ast node.
*
* @param string $name Name of the invoked method.
* @param array $args Optional method arguments.
*
* @return mixed
* @throws BadMethodCallException When the underlying PHP_Depend node
* @throws BadMethodCallException When the underlying PDepend node
* does not contain a method named <b>$name</b>.
*/
public function __call($name, array $args)
Expand Down Expand Up @@ -146,7 +144,7 @@ public function getChild($index)
*/
public function getFirstChildOfType($type)
{
$node = $this->node->getFirstChildOfType('PHP_Depend_Code_AST' . $type);
$node = $this->node->getFirstChildOfType('PDepend\Source\AST\AST' . $type);
if ($node === null) {
return null;
}
Expand All @@ -163,7 +161,7 @@ public function getFirstChildOfType($type)
*/
public function findChildrenOfType($type)
{
$children = $this->node->findChildrenOfType('PHP_Depend_Code_AST' . $type);
$children = $this->node->findChildrenOfType('PDepend\Source\AST\AST' . $type);

$nodes = array();
foreach ($children as $child) {
Expand All @@ -181,7 +179,7 @@ public function findChildrenOfType($type)
*/
public function isInstanceOf($type)
{
$class = 'PHP_Depend_Code_AST' . $type;
$class = 'PDepend\Source\AST\AST' . $type;
return ($this->node instanceof $class);
}

Expand Down Expand Up @@ -233,13 +231,13 @@ public function getEndLine()
*/
public function getFileName()
{
return (string) $this->node->getSourceFile();
return (string) $this->node->getCompilationUnit()->getFileName();
}

/**
* Returns the wrapped PHP_Depend node instance.
* Returns the wrapped PDepend node instance.
*
* @return PHP_Depend_Code_AbstractItem
* @return \PDepend\Source\AST\ASTArtifact
*/
public function getNode()
{
Expand Down
2 changes: 0 additions & 2 deletions src/main/php/PHP/PMD/AbstractRule.php
Expand Up @@ -45,8 +45,6 @@
* @link http://phpmd.org
*/

require_once 'PHP/PMD/Rule.php';
require_once 'PHP/PMD/RuleViolation.php';

/**
* This is the abstract base class for pmd rules.
Expand Down
4 changes: 2 additions & 2 deletions src/main/php/PHP/PMD/Node/ASTNode.php
Expand Up @@ -46,7 +46,7 @@
* @link http://phpmd.org
*/

require_once 'PHP/PMD/AbstractNode.php';
use PDepend\Source\AST\ASTNode;

/**
* Wrapper around a PHP_Depend ast node.
Expand Down Expand Up @@ -75,7 +75,7 @@ class PHP_PMD_Node_ASTNode extends PHP_PMD_AbstractNode
* @param PHP_Depend_Code_ASTNode $node The context ast node.
* @param string $fileName The source file name.
*/
public function __construct(PHP_Depend_Code_ASTNode $node, $fileName)
public function __construct(ASTNode $node, $fileName)
{
parent::__construct($node);

Expand Down
4 changes: 2 additions & 2 deletions src/main/php/PHP/PMD/Node/AbstractCallable.php
Expand Up @@ -46,7 +46,7 @@
* @link http://phpmd.org
*/

require_once 'PHP/PMD/Node/AbstractNode.php';
use PDepend\Source\AST\AbstractASTCallable;

/**
* Abstract base class for PHP_Depend function and method wrappers.
Expand All @@ -67,7 +67,7 @@ abstract class PHP_PMD_Node_AbstractCallable extends PHP_PMD_Node_AbstractNode
*
* @param PHP_Depend_Code_AbstractCallable $node The wrapped callable object.
*/
public function __construct(PHP_Depend_Code_AbstractCallable $node)
public function __construct(AbstractASTCallable $node)
{
parent::__construct($node);
}
Expand Down
1 change: 0 additions & 1 deletion src/main/php/PHP/PMD/Node/AbstractNode.php
Expand Up @@ -46,7 +46,6 @@
* @link http://phpmd.org
*/

require_once 'PHP/PMD/AbstractNode.php';

/**
* Abstract base class for all code nodes.
Expand Down
4 changes: 2 additions & 2 deletions src/main/php/PHP/PMD/Node/AbstractType.php
Expand Up @@ -46,7 +46,7 @@
* @link http://phpmd.org
*/

require_once 'PHP/PMD/Node/AbstractNode.php';
use PDepend\Source\AST\AbstractASTClassOrInterface;

/**
* Abstract base class for classes and interfaces.
Expand All @@ -67,7 +67,7 @@ abstract class PHP_PMD_Node_AbstractType extends PHP_PMD_Node_AbstractNode
*
* @param PHP_Depend_Code_AbstractClassOrInterface $node The wrapped node.
*/
public function __construct(PHP_Depend_Code_AbstractClassOrInterface $node)
public function __construct(AbstractASTClassOrInterface $node)
{
parent::__construct($node);
}
Expand Down
1 change: 0 additions & 1 deletion src/main/php/PHP/PMD/Node/Annotations.php
Expand Up @@ -46,7 +46,6 @@
* @link http://phpmd.org
*/

require_once 'PHP/PMD/Node/Annotation.php';

/**
* Collection of code annotations.
Expand Down
4 changes: 2 additions & 2 deletions src/main/php/PHP/PMD/Node/Class.php
Expand Up @@ -46,7 +46,7 @@
* @link http://phpmd.org
*/

require_once 'PHP/PMD/Node/AbstractType.php';
use PDepend\Source\AST\ASTClass;

/**
* Wrapper around PHP_Depend's class objects.
Expand All @@ -72,7 +72,7 @@ class PHP_PMD_Node_Class extends PHP_PMD_Node_AbstractType
*
* @param PHP_Depend_Code_Class $node The wrapped class object.
*/
public function __construct(PHP_Depend_Code_Class $node)
public function __construct(ASTClass $node)
{
parent::__construct($node);
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/php/PHP/PMD/Node/Function.php
Expand Up @@ -46,10 +46,10 @@
* @link http://phpmd.org
*/

require_once 'PHP/PMD/Node/AbstractCallable.php';
use PDepend\Source\AST\ASTFunction;

/**
* Wrapper around a PHP_Depend function node.
* Wrapper around a PDepend function node.
*
* @category PHP
* @package PHP_PMD
Expand All @@ -65,9 +65,9 @@ class PHP_PMD_Node_Function extends PHP_PMD_Node_AbstractCallable
/**
* Constructs a new function wrapper.
*
* @param PHP_Depend_Code_Function $node The wrapped function object.
* @param PDepend $node The wrapped function object.
*/
public function __construct(PHP_Depend_Code_Function $node)
public function __construct(ASTFunction $node)
{
parent::__construct($node);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/php/PHP/PMD/Node/Interface.php
Expand Up @@ -46,7 +46,7 @@
* @link http://phpmd.org
*/

require_once 'PHP/PMD/Node/AbstractType.php';
use PDepend\Source\AST\ASTInterface;

/**
* Wrapper around PHP_Depend's interface objects.
Expand All @@ -72,7 +72,7 @@ class PHP_PMD_Node_Interface extends PHP_PMD_Node_AbstractType
*
* @param PHP_Depend_Code_Interface $node The wrapped interface object.
*/
public function __construct(PHP_Depend_Code_Interface $node)
public function __construct(ASTInterface $node)
{
parent::__construct($node);
}
Expand Down
10 changes: 6 additions & 4 deletions src/main/php/PHP/PMD/Node/Method.php
Expand Up @@ -46,7 +46,9 @@
* @link http://phpmd.org
*/

require_once 'PHP/PMD/Node/AbstractCallable.php';
use PDepend\Source\AST\ASTMethod;
use PDepend\Source\AST\ASTClass;
use PDepend\Source\AST\ASTTrait;

/**
* Wrapper around a PHP_Depend method node.
Expand All @@ -67,7 +69,7 @@ class PHP_PMD_Node_Method extends PHP_PMD_Node_AbstractCallable
*
* @param PHP_Depend_Code_CodeMethod $node The wrapped method object.
*/
public function __construct(PHP_Depend_Code_Method $node)
public function __construct(ASTMethod $node)
{
parent::__construct($node);
}
Expand Down Expand Up @@ -128,11 +130,11 @@ public function hasSuppressWarningsAnnotationFor(PHP_PMD_Rule $rule)
public function getParentType()
{
$parentNode = $this->getNode()->getParent();
if ($parentNode instanceof PHP_Depend_Code_Class) {
if ($parentNode instanceof ASTClass) {
return new PHP_PMD_Node_Class($parentNode);
}

if ($parentNode instanceof PHP_Depend_Code_Trait) {
if ($parentNode instanceof ASTTrait) {
return new PHP_PMD_Node_Trait($parentNode);
}
return new PHP_PMD_Node_Interface($parentNode);
Expand Down
4 changes: 2 additions & 2 deletions src/main/php/PHP/PMD/Node/Trait.php
Expand Up @@ -46,7 +46,7 @@
* @link http://phpmd.org
*/

require_once 'PHP/PMD/Node/AbstractType.php';
use PDepend\Source\AST\ASTTrait;

/**
* Wrapper around PHP_Depend's interface objects.
Expand All @@ -72,7 +72,7 @@ class PHP_PMD_Node_Trait extends PHP_PMD_Node_AbstractType
*
* @param PHP_Depend_Code_Trait $node The wrapped interface object.
*/
public function __construct(PHP_Depend_Code_Trait $node)
public function __construct(ASTTrait $node)
{
parent::__construct($node);
}
Expand Down

0 comments on commit 8c3ebe1

Please sign in to comment.