forked from pdepend/pdepend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request pdepend#342 from KacerCZ/php71-types
Added support for PHP 7.1 types - iterable and void
- Loading branch information
Showing
12 changed files
with
375 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<?php | ||
/** | ||
* This file is part of PDepend. | ||
* | ||
* PHP Version 5 | ||
* | ||
* Copyright (c) 2008-2017 Manuel Pichler <[email protected]>. | ||
* 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. | ||
* | ||
* @copyright 2008-2017 Manuel Pichler. All rights reserved. | ||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License | ||
* @since 2.5.1 | ||
*/ | ||
|
||
namespace PDepend\Source\AST; | ||
|
||
/** | ||
* This class represents an array type node. | ||
* | ||
* @copyright 2008-2017 Manuel Pichler. All rights reserved. | ||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License | ||
* @since 2.5.1 | ||
*/ | ||
class ASTTypeIterable extends ASTType | ||
{ | ||
/** | ||
* The visual image for this node type. | ||
*/ | ||
const IMAGE = 'iterable'; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getImage() | ||
{ | ||
return self::IMAGE; | ||
} | ||
|
||
/** | ||
* This method will return <b>true</b> when the underlying type is an array. | ||
* For this concrete type implementation the returned value will be always | ||
* <b>true</b>. | ||
* | ||
* @return boolean | ||
*/ | ||
public function isArray() | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* Accept method of the visitor design pattern. This method will be called | ||
* by a visitor during tree traversal. | ||
* | ||
* @param \PDepend\Source\ASTVisitor\ASTVisitor $visitor The calling visitor instance. | ||
* @param mixed $data | ||
* | ||
* @return mixed | ||
* @since 0.9.12 | ||
*/ | ||
public function accept(\PDepend\Source\ASTVisitor\ASTVisitor $visitor, $data = null) | ||
{ | ||
return $visitor->visitTypeIterable($this, $data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
157 changes: 157 additions & 0 deletions
157
src/test/php/PDepend/Source/AST/ASTTypeIterableTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
<?php | ||
/** | ||
* This file is part of PDepend. | ||
* | ||
* PHP Version 5 | ||
* | ||
* Copyright (c) 2008-2017 Manuel Pichler <[email protected]>. | ||
* 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. | ||
* | ||
* @copyright 2008-2017 Manuel Pichler. All rights reserved. | ||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License | ||
*/ | ||
|
||
namespace PDepend\Source\AST; | ||
|
||
/** | ||
* Test case for the {@link \PDepend\Source\AST\ASTTypeIterable} class. | ||
* | ||
* @copyright 2008-2017 Manuel Pichler. All rights reserved. | ||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License | ||
* | ||
* @covers \PDepend\Source\Language\PHP\AbstractPHPParser | ||
* @covers \PDepend\Source\AST\ASTTypeIterable | ||
* @group unittest | ||
*/ | ||
class ASTTypeIterableTest extends ASTNodeTest | ||
{ | ||
/** | ||
* testIterableType | ||
* | ||
* @return \PDepend\Source\AST\ASTTypeIterable | ||
* @since 2.5.1 | ||
*/ | ||
public function testIterableType() | ||
{ | ||
$type = $this->_getFirstArrayTypeInFunction(); | ||
$this->assertInstanceOf('PDepend\\Source\\AST\\ASTTypeIterable', $type); | ||
|
||
return $type; | ||
} | ||
|
||
/** | ||
* testIterableTypeHasExpectedStartLine | ||
* | ||
* @param \PDepend\Source\AST\ASTTypeIterable $type | ||
* | ||
* @return void | ||
* @depends testIterableType | ||
*/ | ||
public function testIterableTypeHasExpectedStartLine($type) | ||
{ | ||
$this->assertEquals(2, $type->getStartLine()); | ||
} | ||
|
||
/** | ||
* testIterableTypeHasExpectedStartColumn | ||
* | ||
* @param \PDepend\Source\AST\ASTTypeIterable $type | ||
* | ||
* @return void | ||
* @depends testIterableType | ||
*/ | ||
public function testIterableTypeHasExpectedStartColumn($type) | ||
{ | ||
$this->assertEquals(24, $type->getStartColumn()); | ||
} | ||
|
||
/** | ||
* testIterableTypeHasExpectedEndLine | ||
* | ||
* @param \PDepend\Source\AST\ASTTypeIterable $type | ||
* | ||
* @return void | ||
* @depends testIterableType | ||
*/ | ||
public function testIterableTypeHasExpectedEndLine($type) | ||
{ | ||
$this->assertEquals(2, $type->getEndLine()); | ||
} | ||
|
||
/** | ||
* testIterableTypeHasExpectedEndColumn | ||
* | ||
* @param \PDepend\Source\AST\ASTTypeIterable $type | ||
* | ||
* @return void | ||
* @depends testIterableType | ||
*/ | ||
public function testIterableTypeHasExpectedEndColumn($type) | ||
{ | ||
$this->assertEquals(31, $type->getEndColumn()); | ||
} | ||
|
||
/** | ||
* testIsArrayReturnsTrue | ||
* | ||
* @return void | ||
*/ | ||
public function testIsArrayReturnsTrue() | ||
{ | ||
$type = new \PDepend\Source\AST\ASTTypeIterable(); | ||
$this->assertTrue($type->isArray()); | ||
} | ||
|
||
/** | ||
* testIsPrimitiveReturnsFalse | ||
* | ||
* @return void | ||
*/ | ||
public function testIsPrimitiveReturnsFalse() | ||
{ | ||
$type = new \PDepend\Source\AST\ASTTypeIterable(); | ||
$this->assertFalse($type->isScalar()); | ||
} | ||
|
||
/** | ||
* Returns a node instance for the currently executed test case. | ||
* | ||
* @return \PDepend\Source\AST\ASTTypeIterable | ||
*/ | ||
private function _getFirstArrayTypeInFunction() | ||
{ | ||
return $this->getFirstNodeOfTypeInFunction( | ||
$this->getCallingTestMethod(), | ||
'PDepend\\Source\\AST\\ASTTypeIterable' | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.