/** * Creates a new factory instance. */ public function __construct() { $autoload = new PHP_Depend_Autoload(); $autoload->register(); }
/** * Executes PHP_Depend_TextUI_Runner against PhingFile or a FileSet * * @return void * @throws BuildException */ public function main() { $autoload = new PHP_Depend_Autoload(); $autoload->register(); if (!isset($this->_file) and count($this->_filesets) == 0) { throw new BuildException("Missing either a nested fileset or attribute 'file' set"); } if (count($this->_loggers) == 0) { throw new BuildException("Missing nested 'logger' element"); } $this->validateLoggers(); $this->validateAnalyzers(); $filesToParse = array(); if ($this->_file instanceof PhingFile) { $filesToParse[] = $this->_file->__toString(); } else { // append any files in filesets foreach ($this->_filesets as $fs) { $files = $fs->getDirectoryScanner($this->project)->getIncludedFiles(); foreach ($files as $filename) { $f = new PhingFile($fs->getDir($this->project), $filename); $filesToParse[] = $f->getAbsolutePath(); } } } $this->_runner = new PHP_Depend_TextUI_Runner(); $this->_runner->addProcessListener(new PHP_Depend_TextUI_ResultPrinter()); $configurationFactory = new PHP_Depend_Util_Configuration_Factory(); $configuration = $configurationFactory->createDefault(); $this->_runner->setConfiguration($configuration); $this->_runner->setSourceArguments($filesToParse); foreach ($this->_loggers as $logger) { // Register logger $this->_runner->addLogger($logger->getType(), $logger->getOutfile()->__toString()); } foreach ($this->_analyzers as $analyzer) { // Register additional analyzer $this->_runner->addOption($analyzer->getType(), $analyzer->getValue()); } // Disable annotation parsing if ($this->_withoutAnnotations) { $this->_runner->setWithoutAnnotations(); } // Enable bad documentation support if ($this->_supportBadDocumentation) { $this->_runner->setSupportBadDocumentation(); } // Check for suffix if (count($this->_allowedFileExtensions) > 0) { $this->_runner->setFileExtensions($this->_allowedFileExtensions); } // Check for ignore directories if (count($this->_excludeDirectories) > 0) { $this->_runner->setExcludeDirectories($this->_excludeDirectories); } // Check for exclude packages if (count($this->_excludePackages) > 0) { $this->_runner->setExcludePackages($this->_excludePackages); } // Check for configuration option if ($this->_configFile instanceof PhingFile) { if (file_exists($this->_configFile->__toString()) === false) { throw new BuildException('The configuration file "' . $this->_configFile->__toString() . '" doesn\'t exist.'); } // Load configuration file $config = new PHP_Depend_Util_Configuration($this->_configFile->__toString(), null, true); // Store in config registry PHP_Depend_Util_ConfigurationInstance::set($config); } if ($this->_debug) { require_once 'PHP/Depend/Util/Log.php'; // Enable debug logging PHP_Depend_Util_Log::setSeverity(PHP_Depend_Util_Log::DEBUG); } $this->_runner->run(); if ($this->_runner->hasParseErrors() === true) { $this->log('Following errors occurred:'); foreach ($this->_runner->getParseErrors() as $error) { $this->log($error); } if ($this->_haltonerror === true) { throw new BuildException('Errors occurred during parse process'); } } }
* @author Manuel Pichler <*****@*****.**> * @copyright 2008-2012 Manuel Pichler. All rights reserved. * @license http://www.opensource.org/licenses/bsd-license.php BSD License * @version SVN: $Id$ * @link http://pdepend.org/ */ // PEAR/svn workaround if (strpos('@php_bin@', '@php_bin') === 0) { set_include_path('.' . PATH_SEPARATOR . dirname(__FILE__) . '/../main/php'); } require_once 'PHP/Depend/Autoload.php'; // Allow as much memory as possible by default if (extension_loaded('suhosin') && is_numeric(ini_get('suhosin.memory_limit'))) { $limit = ini_get('memory_limit'); if (preg_match('(^(\\d+)([BKMGT]))', $limit, $match)) { $shift = array('B' => 0, 'K' => 10, 'M' => 20, 'G' => 30, 'T' => 40); $limit = $match[1] * (1 << $shift[$match[2]]); } if (ini_get('suhosin.memory_limit') > $limit && $limit > -1) { ini_set('memory_limit', ini_get('suhosin.memory_limit')); } } else { ini_set('memory_limit', -1); } // Disable E_STRICT for all PHP versions < 5.3.x if (version_compare(phpversion(), '5.3.0')) { error_reporting(error_reporting() & ~E_STRICT); } $autoload = new PHP_Depend_Autoload(); $autoload->register(); exit(PHP_Depend_TextUI_Command::main());
/** * Load the necessary environment for running PHP_Depend * * @throws BuildException */ protected function requireDependencies() { // check composer autoloader if (class_exists('PHP_Depend_TextUI_Runner')) { // include_path hack for PHP_Depend 1.1.3 $rc = new ReflectionClass('PHP_Depend'); set_include_path(get_include_path() . ":" . realpath(dirname($rc->getFileName()) . "/../")); return; } @(include_once 'PHP/Depend/Autoload.php'); if (!class_exists('PHP_Depend_Autoload')) { throw new BuildException('PhpDependTask depends on PHP_Depend being installed and on include_path', $this->getLocation()); } // register PHP_Depend autoloader $autoload = new PHP_Depend_Autoload(); $autoload->register(); }
/** * Load the necessary environment for running PHP_Depend * * @throws BuildException */ protected function requireDependencies() { if (!empty($this->pharLocation)) { include_once 'phar://' . $this->pharLocation . '/vendor/autoload.php'; } // check 2.x version (composer/phar) if (class_exists('PDepend\\TextUI\\Runner')) { return; } $this->oldVersion = true; // check 1.x version (composer) if (class_exists('PHP_Depend_TextUI_Runner')) { // include_path hack for PHP_Depend 1.1.3 $rc = new ReflectionClass('PHP_Depend'); set_include_path(get_include_path() . ":" . realpath(dirname($rc->getFileName()) . "/../")); return; } @(include_once 'PHP/Depend/Autoload.php'); if (!class_exists('PHP_Depend_Autoload')) { throw new BuildException('PhpDependTask depends on PHP_Depend being installed and on include_path', $this->getLocation()); } // register PHP_Depend autoloader $autoload = new PHP_Depend_Autoload(); $autoload->register(); }
/** * This method initializes the test environment, it configures the files * directory and sets the include_path for svn versions. * * @return void */ public static function init() { self::$_filesDirectory = realpath(dirname(__FILE__) . '/../../../resources/files'); // file can contain test rule implementations. $include = self::$_filesDirectory; if (is_int($index = array_search('--include-path', $_SERVER['argv']))) { $ext = pathinfo($_SERVER['argv'][$index + 1], PATHINFO_EXTENSION); if (0 === strpos($ext, 'phar')) { include realpath($_SERVER['argv'][$index + 1]); } } else { if (strpos('@package_version@', '@package_version') === 0) { $include .= PATH_SEPARATOR . realpath(dirname(__FILE__) . '/../../../../main/php') . PATH_SEPARATOR . realpath(dirname(__FILE__) . '/../../../../../lib/pdepend/src/main/php'); } } // Configure include path set_include_path($include . PATH_SEPARATOR . get_include_path()); // Init PHP_Depend autoloader include_once 'PHP/Depend/Autoload.php'; $autoload = new PHP_Depend_Autoload(); $autoload->register(); // Prevent timezone warnings if no default TZ is set (PHP > 5.1.0) date_default_timezone_set('UTC'); }
/** * testAutoloadNotLoadsClassFromDifferentNamespace * * @return void */ public function testAutoloadNotLoadsClassFromDifferentNamespace() { $className = 'PHP_AutoloadNotLoadsClassFromDifferentNamespace'; $autoloader = new PHP_Depend_Autoload(); $autoloader->register(); set_include_path(self::createCodeResourceUriForTest()); $exists = class_exists($className, true); set_include_path($this->includePath); self::assertFalse($exists); }