Skip to content

Commit

Permalink
Merge pull request #51 from bahulneel/master
Browse files Browse the repository at this point in the history
Fixed handling of traits
  • Loading branch information
manuelpichler committed Sep 7, 2012
2 parents 458d566 + 09aae2c commit 22b523c
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/php/PHP/PMD/Node/Method.php
Expand Up @@ -131,6 +131,10 @@ public function getParentType()
if ($parentNode instanceof PHP_Depend_Code_Class) {
return new PHP_PMD_Node_Class($parentNode);
}

if ($parentNode instanceof PHP_Depend_Code_Trait) {
return new PHP_PMD_Node_Trait($parentNode);
}
return new PHP_PMD_Node_Interface($parentNode);
}

Expand Down
79 changes: 79 additions & 0 deletions src/main/php/PHP/PMD/Node/Trait.php
@@ -0,0 +1,79 @@
<?php
/**
* This file is part of PHP_PMD.
*
* PHP Version 5
*
* Copyright (c) 2008-2012, Manuel Pichler <mapi@phpmd.org>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* * Neither the name of Manuel Pichler nor the names of his
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @category PHP
* @package PHP_PMD
* @subpackage Node
* @author Manuel Pichler <mapi@phpmd.org>
* @copyright 2008-2012 Manuel Pichler. All rights reserved.
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @version SVN: $Id$
* @link http://phpmd.org
*/

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

/**
* Wrapper around PHP_Depend's interface objects.
*
* @category PHP
* @package PHP_PMD
* @subpackage Node
* @author Manuel Pichler <mapi@phpmd.org>
* @copyright 2008-2012 Manuel Pichler. All rights reserved.
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @version Release: 1.3.3
* @link http://phpmd.org
*/
class PHP_PMD_Node_Trait extends PHP_PMD_Node_AbstractType
{
/**
* The type of this class.
*/
const CLAZZ = __CLASS__;

/**
* Constructs a new interface wrapper instance.
*
* @param PHP_Depend_Code_Trait $node The wrapped interface object.
*/
public function __construct(PHP_Depend_Code_Trait $node)
{
parent::__construct($node);
}
}
1 change: 1 addition & 0 deletions src/main/php/PHP/PMD/Parser.php
Expand Up @@ -49,6 +49,7 @@
require_once 'PHP/PMD/Node/Class.php';
require_once 'PHP/PMD/Node/Function.php';
require_once 'PHP/PMD/Node/Interface.php';
require_once 'PHP/PMD/Node/Trait.php';
require_once 'PHP/PMD/Node/Method.php';

/**
Expand Down

0 comments on commit 22b523c

Please sign in to comment.