Skip to content

Commit

Permalink
- Fixed #182: Clone is a valid function, method and type name in older
Browse files Browse the repository at this point in the history
  php versions.
  • Loading branch information
manuelpichler committed Nov 22, 2010
1 parent 6ec5f71 commit b18bf37
Show file tree
Hide file tree
Showing 8 changed files with 147 additions and 2 deletions.
2 changes: 2 additions & 0 deletions PHP/Depend/Parser/VersionAllParser.php
Expand Up @@ -82,6 +82,7 @@ protected function parseClassName()
case self::T_USE:
case self::T_NULL:
case self::T_TRUE:
case self::T_CLONE:
case self::T_FALSE:
case self::T_STRING:
case self::T_NAMESPACE:
Expand Down Expand Up @@ -113,6 +114,7 @@ public function parseFunctionName()
$type = $this->tokenizer->peek();
switch ($type) {

case PHP_Depend_TokenizerI::T_CLONE:
case PHP_Depend_TokenizerI::T_STRING:
case PHP_Depend_TokenizerI::T_USE:
case PHP_Depend_TokenizerI::T_GOTO:
Expand Down
2 changes: 2 additions & 0 deletions tests/PHP/Depend/Bugs/AllTests.php
Expand Up @@ -89,6 +89,7 @@
require_once dirname(__FILE__) . '/AlternativeSyntaxClosingTagBug163Test.php';
require_once dirname(__FILE__) . '/ClassAndInterfaceNamesBug169Test.php';
require_once dirname(__FILE__) . '/UnexpectedTokenAsciiChar39Bug181Test.php';
require_once dirname(__FILE__) . '/CloneIsValidNameInOlderPhpVersionsBug182Test.php';

/**
* Test suite for bugs meta package.
Expand Down Expand Up @@ -159,6 +160,7 @@ public static function suite()
$suite->addTestSuite('PHP_Depend_Bug_AlternativeSyntaxClosingTagBug163Test');
$suite->addTestSuite('PHP_Depend_Bugs_ClassAndInterfaceNamesBug169Test');
$suite->addTestSuite('PHP_Depend_Bugs_UnexpectedTokenAsciiChar39Bug181Test');
$suite->addTestSuite('PHP_Depend_Bugs_CloneIsValidNameInOlderPhpVersionsBug182Test');

return $suite;
}
Expand Down
119 changes: 119 additions & 0 deletions tests/PHP/Depend/Bugs/CloneIsValidNameInOlderPhpVersionsBug182Test.php
@@ -0,0 +1,119 @@
<?php
/**
* This file is part of PHP_Depend.
*
* PHP Version 5
*
* Copyright (c) 2008-2010, Manuel Pichler <mapi@pdepend.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_Depend
* @subpackage Bugs
* @author Manuel Pichler <mapi@pdepend.org>
* @copyright 2008-2010 Manuel Pichler. All rights reserved.
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @version SVN: $Id$
* @link http://tracker.pdepend.org/pdepend/issue_tracker/issue/182
*/

require_once dirname(__FILE__) . '/AbstractTest.php';

/**
* Test case for ticket #182.
*
* @category PHP
* @package PHP_Depend
* @subpackage Bugs
* @author Manuel Pichler <mapi@pdepend.org>
* @copyright 2008-2010 Manuel Pichler. All rights reserved.
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @version Release: @package_version@
* @link http://tracker.pdepend.org/pdepend/issue_tracker/issue/182
*
* @covers stdClass
*/
class PHP_Depend_Bugs_CloneIsValidNameInOlderPhpVersionsBug182Test
extends PHP_Depend_Bugs_AbstractTest
{
/**
* testParserAcceptsCloneAsFunctionName
*
* @return void
* @group pdepend
* @group pdepend::bugs
* @group regressiontest
*/
public function testParserAcceptsCloneAsFunctionName()
{
self::parseCodeResourceForTest();
}

/**
* testParserAcceptsCloneAsMethodName
*
* @return void
* @group pdepend
* @group pdepend::bugs
* @group regressiontest
*/
public function testParserAcceptsCloneAsMethodName()
{
self::parseCodeResourceForTest();
}

/**
* testParserAcceptsCloneAsClassName
*
* @return void
* @group pdepend
* @group pdepend::bugs
* @group regressiontest
*/
public function testParserAcceptsCloneAsClassName()
{
self::parseCodeResourceForTest();
}

/**
* testParserAcceptsCloneAsInterfaceName
*
* @return void
* @group pdepend
* @group pdepend::bugs
* @group regressiontest
*/
public function testParserAcceptsCloneAsInterfaceName()
{
self::parseCodeResourceForTest();
}
}
Expand Up @@ -43,7 +43,7 @@
* @copyright 2008-2010 Manuel Pichler. All rights reserved.
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @version SVN: $Id$
* @link http://www.pdepend.org/
* @link http://tracker.pdepend.org/pdepend/issue_tracker/issue/181
* @since 0.10.0
*/

Expand All @@ -62,7 +62,7 @@
* @copyright 2008-2010 Manuel Pichler. All rights reserved.
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @version Release: @package_version@
* @link http://www.pdepend.org/
* @link http://tracker.pdepend.org/pdepend/issue_tracker/issue/181
* @since 0.10.0
*
* @covers stdClass
Expand Down
@@ -0,0 +1,4 @@
<?php
class Clone
{
}
@@ -0,0 +1,5 @@
<?php
function clone($object)
{

}
@@ -0,0 +1,5 @@
<?php
interface Clone
{

}
@@ -0,0 +1,8 @@
<?php
class testParserAcceptsCloneAsMethodName
{
function clone($object)
{
return $object;
}
}

0 comments on commit b18bf37

Please sign in to comment.