diff --git a/CHANGELOG b/CHANGELOG index 4a4625fe2..d0119df20 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,8 +1,15 @@ PHP_Depend 0.10.5 ----------------- +This release closes two minor bugs in PHP_Depend. One incompatibility +with PHP 5.2.x versions and one bug related to PHP_Depend's log +behavior when PHP_Depend analyzes unstructured source code. This release +was published on May the 20th 2011. + - Fixed #13255437: PHP 5.2 Compatibility Issues. Fixed with commit #8d4a095. +- Fixed #13405179: PHP Depend report is not generated if all files do + not contain a class nor a function. Fixed with commit #. PHP_Depend 0.10.4 ----------------- diff --git a/src/main/php/PHP/Depend.php b/src/main/php/PHP/Depend.php index 2e6b408b8..f32c24258 100644 --- a/src/main/php/PHP/Depend.php +++ b/src/main/php/PHP/Depend.php @@ -299,10 +299,6 @@ public function analyze() $collection = PHP_Depend_Code_Filter_Collection::getInstance(); $collection->setFilter($this->_codeFilter); - if ($this->_builder->getPackages()->count() === 0) { - return ($this->_packages = $this->_builder->getPackages()); - } - $collection->setFilter(); $this->_performAnalyzeProcess(); @@ -643,7 +639,7 @@ private function _initAnalyseListeners( } } } - + return $analyzerLoader; } diff --git a/src/main/php/PHP/Depend/Log/CodeAwareI.php b/src/main/php/PHP/Depend/Log/CodeAwareI.php index b87562bf9..31ca5e1de 100644 --- a/src/main/php/PHP/Depend/Log/CodeAwareI.php +++ b/src/main/php/PHP/Depend/Log/CodeAwareI.php @@ -1,7 +1,7 @@ . @@ -58,13 +58,13 @@ * @version Release: @package_version@ * @link http://pdepend.org/ */ -interface PHP_Depend_Log_CodeAwareI +interface PHP_Depend_Log_CodeAwareI extends PHP_Depend_Log_LoggerI { /** * Sets the context code nodes. * * @param PHP_Depend_Code_NodeIterator $code The code nodes. - * + * * @return void */ function setCode(PHP_Depend_Code_NodeIterator $code); diff --git a/src/main/php/PHP/Depend/Log/FileAwareI.php b/src/main/php/PHP/Depend/Log/FileAwareI.php index 96ee4104a..f995c535d 100644 --- a/src/main/php/PHP/Depend/Log/FileAwareI.php +++ b/src/main/php/PHP/Depend/Log/FileAwareI.php @@ -1,7 +1,7 @@ . @@ -58,13 +58,13 @@ * @version Release: @package_version@ * @link http://pdepend.org/ */ -interface PHP_Depend_Log_FileAwareI +interface PHP_Depend_Log_FileAwareI extends PHP_Depend_Log_LoggerI { /** * Sets the output log file. * * @param string $logFile The output log file. - * + * * @return void */ function setLogFile($logFile); diff --git a/src/main/php/PHP/Depend/Log/Jdepend/Chart.php b/src/main/php/PHP/Depend/Log/Jdepend/Chart.php index e982c0e2b..19dc4e80d 100644 --- a/src/main/php/PHP/Depend/Log/Jdepend/Chart.php +++ b/src/main/php/PHP/Depend/Log/Jdepend/Chart.php @@ -60,10 +60,14 @@ */ class PHP_Depend_Log_Jdepend_Chart extends PHP_Depend_Visitor_AbstractVisitor - implements PHP_Depend_Log_LoggerI, - PHP_Depend_Log_CodeAwareI, + implements PHP_Depend_Log_CodeAwareI, PHP_Depend_Log_FileAwareI { + /** + * The type of this class. + */ + const CLAZZ = __CLASS__; + /** * The output file name. * diff --git a/src/main/php/PHP/Depend/Log/Jdepend/Xml.php b/src/main/php/PHP/Depend/Log/Jdepend/Xml.php index cb5b07a19..01dce2b6f 100644 --- a/src/main/php/PHP/Depend/Log/Jdepend/Xml.php +++ b/src/main/php/PHP/Depend/Log/Jdepend/Xml.php @@ -61,10 +61,14 @@ */ class PHP_Depend_Log_Jdepend_Xml extends PHP_Depend_Visitor_AbstractVisitor - implements PHP_Depend_Log_LoggerI, - PHP_Depend_Log_CodeAwareI, + implements PHP_Depend_Log_CodeAwareI, PHP_Depend_Log_FileAwareI { + /** + * The type of this class. + */ + const CLAZZ = __CLASS__; + /** * The output log file. * @@ -351,7 +355,7 @@ public function visitPackage(PHP_Depend_Code_Package $package) $type->accept($this); } - if ($this->concreteClasses->firstChild === null + if ($this->concreteClasses->firstChild === null && $this->abstractClasses->firstChild === null ) { return; diff --git a/src/main/php/PHP/Depend/Log/Overview/Pyramid.php b/src/main/php/PHP/Depend/Log/Overview/Pyramid.php index e7190fbb1..8b141bf4a 100644 --- a/src/main/php/PHP/Depend/Log/Overview/Pyramid.php +++ b/src/main/php/PHP/Depend/Log/Overview/Pyramid.php @@ -61,10 +61,13 @@ * @version Release: @package_version@ * @link http://pdepend.org/ */ -class PHP_Depend_Log_Overview_Pyramid - implements PHP_Depend_Log_LoggerI, - PHP_Depend_Log_FileAwareI +class PHP_Depend_Log_Overview_Pyramid implements PHP_Depend_Log_FileAwareI { + /** + * The type of this class. + */ + const CLAZZ = __CLASS__; + /** * The output file name. * diff --git a/src/main/php/PHP/Depend/Log/Phpunit/Xml.php b/src/main/php/PHP/Depend/Log/Phpunit/Xml.php index 9748d9fba..fac2fbb97 100644 --- a/src/main/php/PHP/Depend/Log/Phpunit/Xml.php +++ b/src/main/php/PHP/Depend/Log/Phpunit/Xml.php @@ -44,6 +44,7 @@ * @license http://www.opensource.org/licenses/bsd-license.php BSD License * @version SVN: $Id$ * @link http://pdepend.org/ + * @deprecated Since release 0.10.5, please use the summary logger */ /** @@ -59,11 +60,11 @@ * @license http://www.opensource.org/licenses/bsd-license.php BSD License * @version Release: @package_version@ * @link http://pdepend.org/ + * @deprecated Since release 0.10.5, please use the summary logger */ class PHP_Depend_Log_Phpunit_Xml extends PHP_Depend_Visitor_AbstractVisitor - implements PHP_Depend_Log_LoggerI, - PHP_Depend_Log_CodeAwareI, + implements PHP_Depend_Log_CodeAwareI, PHP_Depend_Log_FileAwareI { /** diff --git a/src/main/php/PHP/Depend/Log/Summary/Xml.php b/src/main/php/PHP/Depend/Log/Summary/Xml.php index 971437a39..776ff6787 100644 --- a/src/main/php/PHP/Depend/Log/Summary/Xml.php +++ b/src/main/php/PHP/Depend/Log/Summary/Xml.php @@ -61,10 +61,14 @@ */ class PHP_Depend_Log_Summary_Xml extends PHP_Depend_Visitor_AbstractVisitor - implements PHP_Depend_Log_LoggerI, - PHP_Depend_Log_CodeAwareI, + implements PHP_Depend_Log_CodeAwareI, PHP_Depend_Log_FileAwareI { + /** + * The type of this class. + */ + const CLAZZ = __CLASS__; + /** * The log output file. * @@ -165,7 +169,7 @@ public function log(PHP_Depend_Metrics_AnalyzerI $analyzer) } if ($analyzer instanceof PHP_Depend_Metrics_NodeAwareI) { $this->_nodeAwareAnalyzers[] = $analyzer; - + $accepted = true; } return $accepted; diff --git a/src/test/php/PHP/Depend/Bugs/AllTests.php b/src/test/php/PHP/Depend/Bugs/AllTests.php index 51140e0dc..05a1a2b67 100644 --- a/src/test/php/PHP/Depend/Bugs/AllTests.php +++ b/src/test/php/PHP/Depend/Bugs/AllTests.php @@ -101,6 +101,7 @@ require_once dirname(__FILE__) . '/ParserBug8927377Test.php'; require_once dirname(__FILE__) . '/ClosureBug9634613Test.php'; require_once dirname(__FILE__) . '/ClassLevelAnalyzerBug09936901Test.php'; +require_once dirname(__FILE__) . '/PHPDependBug13405179Test.php'; /** * Test suite for bugs meta package. @@ -180,6 +181,7 @@ public static function suite() $suite->addTestSuite('PHP_Depend_Bugs_ParserBug8927377Test'); $suite->addTestSuite('PHP_Depend_Bugs_ClosureBug9634613Test'); $suite->addTestSuite('PHP_Depend_Bugs_ClassLevelAnalyzerBug09936901Test'); + $suite->addTestSuite('PHP_Depend_Bugs_PHPDependBug13405179Test'); return $suite; } diff --git a/src/test/php/PHP/Depend/Bugs/PHPDependBug13405179Test.php b/src/test/php/PHP/Depend/Bugs/PHPDependBug13405179Test.php new file mode 100644 index 000000000..a986e8597 --- /dev/null +++ b/src/test/php/PHP/Depend/Bugs/PHPDependBug13405179Test.php @@ -0,0 +1,110 @@ +. + * 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 + * @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/13405179 + */ + +require_once dirname(__FILE__) . '/AbstractTest.php'; + +/** + * Test case for bug #13405179. + * + * @category PHP + * @package PHP_Depend + * @subpackage Bugs + * @author Manuel Pichler + * @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/13405179 + * + * @ticket 13405179 + * @covers stdClass + * @group pdepend + * @group pdepend::bugs + * @group regressiontest + */ +class PHP_Depend_Bugs_PHPDependBug13405179Test extends PHP_Depend_Bugs_AbstractTest +{ + /** + * testLogFileIsCreatedForUnstructuredCode + * + * @param string $className Class name of a logger implementation. + * @param string $extension Log file extension. + * + * @return void + * @dataProvider getLoggerClassNames + */ + public function testLogFileIsCreatedForUnstructuredCode($className, $extension) + { + $file = self::createRunResourceURI() . '.' . $extension; + + $logger = new $className(); + $logger->setLogFile($file); + + $factory = new PHP_Depend_Util_Configuration_Factory(); + $pdepend = new PHP_Depend($factory->createDefault()); + $pdepend->addFile(self::createCodeResourceUriForTest()); + $pdepend->addLogger($logger); + $pdepend->analyze(); + + self::assertFileExists($file); + } + + /** + * Returns the class names of all file aware logger classes. + * + * @return array + */ + public function getLoggerClassNames() + { + return array( + array(PHP_Depend_Log_Jdepend_Chart::CLAZZ, 'svg'), + array(PHP_Depend_Log_Jdepend_Xml::CLAZZ, 'xml'), + array(PHP_Depend_Log_Overview_Pyramid::CLAZZ, 'svg'), + array(PHP_Depend_Log_Summary_Xml::CLAZZ, 'xml'), + ); + } +} \ No newline at end of file diff --git a/src/test/resources/files/bugs/13405179/testLogFileIsCreatedForUnstructuredCode.php b/src/test/resources/files/bugs/13405179/testLogFileIsCreatedForUnstructuredCode.php new file mode 100644 index 000000000..70a233921 --- /dev/null +++ b/src/test/resources/files/bugs/13405179/testLogFileIsCreatedForUnstructuredCode.php @@ -0,0 +1,11 @@ +