Skip to content

Commit

Permalink
[fixes #13405179] PHP Depend report not generated
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelpichler committed May 20, 2011
1 parent 264c67f commit 554ade1
Show file tree
Hide file tree
Showing 12 changed files with 166 additions and 24 deletions.
7 changes: 7 additions & 0 deletions 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
-----------------
Expand Down
6 changes: 1 addition & 5 deletions src/main/php/PHP/Depend.php
Expand Up @@ -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();
Expand Down Expand Up @@ -643,7 +639,7 @@ private function _initAnalyseListeners(
}
}
}

return $analyzerLoader;
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/php/PHP/Depend/Log/CodeAwareI.php
@@ -1,7 +1,7 @@
<?php
/**
* This file is part of PHP_Depend.
*
*
* PHP Version 5
*
* Copyright (c) 2008-2011, Manuel Pichler <mapi@pdepend.org>.
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/main/php/PHP/Depend/Log/FileAwareI.php
@@ -1,7 +1,7 @@
<?php
/**
* This file is part of PHP_Depend.
*
*
* PHP Version 5
*
* Copyright (c) 2008-2011, Manuel Pichler <mapi@pdepend.org>.
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 6 additions & 2 deletions src/main/php/PHP/Depend/Log/Jdepend/Chart.php
Expand Up @@ -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.
*
Expand Down
10 changes: 7 additions & 3 deletions src/main/php/PHP/Depend/Log/Jdepend/Xml.php
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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;
Expand Down
9 changes: 6 additions & 3 deletions src/main/php/PHP/Depend/Log/Overview/Pyramid.php
Expand Up @@ -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.
*
Expand Down
5 changes: 3 additions & 2 deletions src/main/php/PHP/Depend/Log/Phpunit/Xml.php
Expand Up @@ -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
*/

/**
Expand All @@ -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
{
/**
Expand Down
10 changes: 7 additions & 3 deletions src/main/php/PHP/Depend/Log/Summary/Xml.php
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/test/php/PHP/Depend/Bugs/AllTests.php
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}
Expand Down
110 changes: 110 additions & 0 deletions src/test/php/PHP/Depend/Bugs/PHPDependBug13405179Test.php
@@ -0,0 +1,110 @@
<?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/13405179
*/

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

/**
* Test case for bug #13405179.
*
* @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/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'),
);
}
}
@@ -0,0 +1,11 @@
<?php

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
if (isset($_REQUEST['foo'])) {
echo 'bar';
}

?>

0 comments on commit 554ade1

Please sign in to comment.