Navigation Menu

Skip to content

Commit

Permalink
Merge branch 'release-0.10.x'
Browse files Browse the repository at this point in the history
Conflicts:
	src/site/docx/changes.xml
	src/test/php/PHP/Depend/Code/ASTConstantDeclaratorTest.php
  • Loading branch information
manuelpichler committed Jan 25, 2012
2 parents 41bdc44 + a7fbd62 commit 373c478
Show file tree
Hide file tree
Showing 10 changed files with 187 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/main/php/PHP/Depend/Parser.php
Expand Up @@ -5849,11 +5849,6 @@ private function _parseStaticValue()
$defaultValue->setValue($this->_parseStringSequence($tokenType));
break;

case self::T_START_HEREDOC:
$defaultValue->setValue(null);
$this->parseHeredoc();
break;

case self::T_DIR:
case self::T_FILE:
case self::T_LINE:
Expand All @@ -5871,6 +5866,12 @@ private function _parseStaticValue()
$defaultValue->setValue(null);
$this->consumeToken($tokenType);
break;

case self::T_START_HEREDOC:
$defaultValue->setValue(
$this->parseHeredoc()->getChild(0)->getImage()
);
break;

default:
throw new PHP_Depend_Parser_UnexpectedTokenException(
Expand Down
8 changes: 8 additions & 0 deletions src/site/docx/changes.xml
Expand Up @@ -44,6 +44,14 @@
</action>
</release>

<release version="0.10.9"
date="2012/01/25"
description="">
<action date="" dev="mapi" issue="23951621" system="pivotaltracker" due-to="Brian Kendig" type="fix">
PHP_Depend fails on Heredocs and Nowdocs in property declaration.
</action>
</release>

<release version="0.10.8"
date="2012/01/24"
description="This release closes an issue in PHP_Depend's parser
Expand Down
105 changes: 105 additions & 0 deletions src/test/php/PHP/Depend/Bugs/ParserBug23951621Test.php
@@ -0,0 +1,105 @@
<?php
/**
* This file is part of PHP_Depend.
*
* PHP Version 5
*
* Copyright (c) 2008-2011, 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-2011 Manuel Pichler. All rights reserved.
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @version SVN: $Id$
* @link https://www.pivotaltracker.com/story/show/23951621
* @since 0.10.9
*/

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

/**
* Test case for bug #23951621.
*
* @category PHP
* @package PHP_Depend
* @subpackage Bugs
* @author Manuel Pichler <mapi@pdepend.org>
* @copyright 2008-2011 Manuel Pichler. All rights reserved.
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @version Release: @package_version@
* @link https://www.pivotaltracker.com/story/show/23951621
* @since 0.10.9
*
* @ticket 23951621
* @covers stdClass
* @group pdepend
* @group pdepend::bugs
* @group regressiontest
*/
class PHP_Depend_Bugs_ParserBug23951621Test extends PHP_Depend_Bugs_AbstractTest
{
/**
* testParserHandlesHeredocAsPropertyDefaultValue
*
* @return void
*/
public function testParserHandlesHeredocAsPropertyDefaultValue()
{
$class = $this->getFirstClassForTestCase();
$this->assertInstanceOf('PHP_Depend_Code_Class', $class);
}

/**
* testParserHandlesHeredocAsParameterDefaultValue
*
* @return void
*/
public function testParserHandlesHeredocAsParameterDefaultValue()
{
$class = $this->getFirstClassForTestCase();
$this->assertInstanceOf('PHP_Depend_Code_Class', $class);
}

/**
* testParserHandlesHeredocAsClassConstantValue
*
* @return void
*/
public function testParserHandlesHeredocAsClassConstantValue()
{
$interface = $this->getFirstInterfaceForTestCase();
$this->assertInstanceOf('PHP_Depend_Code_Interface', $interface);
}
}
12 changes: 12 additions & 0 deletions src/test/php/PHP/Depend/Code/ASTConstantDeclaratorTest.php
Expand Up @@ -109,6 +109,18 @@ public function testParserInjectsExpectedScalarValueIntoConstantDeclarator()
self::assertEquals(42, $declarator->getValue()->getValue());
}

/**
* testParserInjectsExpectedHeredocValueIntoConstantDeclarator
*
* @return void
* @since 0.10.9
*/
public function testParserInjectsExpectedHeredocValueIntoConstantDeclarator()
{
$declarator = $this->_getFirstConstantDeclaratorInClass(__METHOD__);
self::assertEquals('Testing!', $declarator->getValue()->getValue());
}

/**
* testConstantDeclaratorHasExpectedStartLine
*
Expand Down
12 changes: 12 additions & 0 deletions src/test/php/PHP/Depend/Code/PropertyTest.php
Expand Up @@ -351,6 +351,18 @@ public function testIsPrimitiveReturnsExpectedValueFalseForVarAnnotationWithClas
self::assertFalse($property->isPrimitive());
}

/**
* testGetDefaultValueReturnsExpectedStringFromHeredoc
*
* @return void
* @since 0.10.9
*/
public function testGetDefaultValueReturnsExpectedStringFromHeredoc()
{
$property = $this->_getFirstPropertyInClass();
$this->assertEquals('Testing!', $property->getDefaultValue());
}

/**
* Tests that the {@link PHP_Depend_Code_Property::isPrimitive()} method
* returns <b>false</b> for an property without var annotation.
Expand Down
@@ -0,0 +1,8 @@
<?php
class testParserInjectsExpectedHeredocValueIntoConstantDeclarator
{
const TEST = <<<TEST
Testing!
TEST;

}
@@ -0,0 +1,8 @@
<?php
class testGetDefaultValueReturnsExpectedStringFromHeredoc
{
protected $test = <<<TEST
Testing!
TEST;

}
@@ -0,0 +1,8 @@
<?php
interface testParserHandlesHeredocAsClassConstantValue
{
const FOO = <<<TEST
Testing!
TEST;

}
@@ -0,0 +1,12 @@
<?php
class testParserHandlesHeredocAsParameterDefaultValue
{
static function foo($test = <<<TEST
Testing
TEST
) {
echo $test;
}
}

testParserHandlesHeredocAsParameterDefaultValue::foo();
@@ -0,0 +1,8 @@
<?php
class testParserHandlesHeredocAsPropertyDefaultValue
{
public $test = <<<TEST
Testing!
TEST;

}

0 comments on commit 373c478

Please sign in to comment.