示例#1
0
 /**
  * @throws \RuntimeException
  */
 protected function checkXDebug()
 {
     if (extension_loaded('xdebug') && xdebug_is_enabled() && ini_get('xdebug.max_nesting_level') < 200) {
         $errorMessage = 'Please change PHP ini setting "xdebug.max_nesting_level". ' . 'Please change it to a value >= 200. ' . 'Your current value is ' . ini_get('xdebug.max_nesting_level');
         throw new \RuntimeException($errorMessage);
     }
 }
示例#2
0
 public static function xdebugIsEnabled()
 {
     if (extension_loaded('xdebug')) {
         return (bool) xdebug_is_enabled();
     }
     return false;
 }
示例#3
0
 public function _before(\Codeception\TestCase $test)
 {
     if (!$this->client) {
         if (!strpos($this->config['url'], '://')) {
             // not valid url
             foreach ($this->getModules() as $module) {
                 if ($module instanceof \Codeception\Lib\Framework) {
                     $this->client = $module->client;
                     $this->isFunctional = true;
                     break;
                 }
             }
         } else {
             if (!$this->hasModule('PhpBrowser')) {
                 throw new ModuleConfigException(__CLASS__, "For REST testing via HTTP please enable PhpBrowser module");
             }
             $this->client = $this->getModule('PhpBrowser')->client;
         }
         if (!$this->client) {
             throw new ModuleConfigException(__CLASS__, "Client for REST requests not initialized.\nProvide either PhpBrowser module, or a framework module which shares FrameworkInterface");
         }
     }
     $this->headers = array();
     $this->params = array();
     $this->response = "";
     $this->client->setServerParameters(array());
     if ($this->config['xdebug_remote'] && function_exists('xdebug_is_enabled') && xdebug_is_enabled() && ini_get('xdebug.remote_enable') && !$this->isFunctional) {
         $cookie = new Cookie('XDEBUG_SESSION', $this->config['xdebug_remote'], null, '/');
         $this->client->getCookieJar()->set($cookie);
     }
 }
示例#4
0
文件: xdebug.php 项目: alencarmo/OCF
function traceStop()
{
    if (!function_exists('xdebug_is_enabled') || !xdebug_is_enabled()) {
        return;
    }
    xdebug_stop_trace();
}
示例#5
0
文件: XDebug.php 项目: ksst/kf
 /**
  * XDebug Helper Functions.
  */
 public static function isXdebugActive()
 {
     if (extension_loaded('xdebug') and xdebug_is_enabled()) {
         return true;
     }
     return false;
 }
示例#6
0
 /**
  * Initializes the default configuration for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param  KObjectConfig $config An optional ObjectConfig object with configuration options.
  * @return void
  */
 protected function _initialize(KObjectConfig $config)
 {
     if (extension_loaded('xdebug') && xdebug_is_enabled() && getenv('JOOMLATOOLS_BOX')) {
         $level = self::ERROR_DEVELOPMENT;
         $type = self::TYPE_ALL;
     } else {
         $level = JDEBUG ? E_ERROR | E_PARSE : self::ERROR_REPORTING;
         $type = JDEBUG ? self::TYPE_ALL : false;
     }
     $config->append(array('exception_type' => $type, 'error_reporting' => $level));
     parent::_initialize($config);
 }
示例#7
0
 private function soapclient($host)
 {
     $xdebug_enabled = function_exists('xdebug_is_enabled') ? xdebug_is_enabled() : false;
     if ($xdebug_enabled) {
         xdebug_disable();
     }
     set_error_handler('esx_init_error_handler');
     $this->soap = new SoapClient('https://' . $host . '/sdk/vimService.wsdl', array('location' => 'https://' . $host . '/sdk/', 'uri' => 'urn:vim25', 'exceptions' => true, 'soap_version' => '1.1', 'trace' => true, 'cache_wsdl' => WSDL_CACHE_BOTH, 'features' => SOAP_SINGLE_ELEMENT_ARRAYS));
     restore_error_handler();
     if ($xdebug_enabled) {
         xdebug_enable();
     }
 }
示例#8
0
文件: REST.php 项目: pfz/codeception
 public function _before(\Codeception\TestCase $test)
 {
     if (!$this->client) {
         if (!strpos($this->config['url'], '://')) {
             // not valid url
             foreach ($this->getModules() as $module) {
                 if ($module instanceof \Codeception\Util\Framework) {
                     $this->client = $module->client;
                     $this->is_functional = true;
                     break;
                 }
             }
         } else {
             if (!$this->hasModule('PhpBrowser')) {
                 throw new ModuleConfigException(__CLASS__, "For REST testing via HTTP please enable PhpBrowser module");
             }
             $this->client = $this->getModule('PhpBrowser')->session->getDriver()->getClient();
         }
         if (!$this->client) {
             throw new ModuleConfigException(__CLASS__, "Client for REST requests not initialized.\nProvide either PhpBrowser module, or a framework module which shares FrameworkInterface");
         }
     }
     $this->headers = array();
     $this->params = array();
     $this->response = "";
     $this->client->setServerParameters(array());
     $timeout = $this->config['timeout'];
     if ($this->config['xdebug_remote'] && function_exists('xdebug_is_enabled') && xdebug_is_enabled() && ini_get('xdebug.remote_enable')) {
         $cookie = new Cookie('XDEBUG_SESSION', $this->config['xdebug_remote'], null, '/');
         $this->client->getCookieJar()->set($cookie);
         // timeout is disabled, so we can debug gently :)
         $timeout = 0;
     }
     if (method_exists($this->client, 'getClient')) {
         $clientConfig = $this->client->getClient()->getConfig();
         $curlOptions = $clientConfig->get('curl.options');
         $curlOptions[CURLOPT_TIMEOUT] = $timeout;
         $clientConfig->set('curl.options', $curlOptions);
     }
 }
 public function __construct($wsdl, $options = array('exceptions' => 1))
 {
     $xdebugIsDisabled = false;
     try {
         if (function_exists('xdebug_is_enabled') && xdebug_is_enabled()) {
             xdebug_disable();
             $xdebugIsDisabled = true;
         }
         if (!isset($options['exceptions'])) {
             $options['exceptions'] = 1;
         }
         @parent::__construct($wsdl, $options);
         if ($xdebugIsDisabled) {
             xdebug_enable();
         }
     } catch (SoapFault $e) {
         if ($xdebugIsDisabled) {
             xdebug_enable();
         }
         throw new RuntimeException(sprintf('Failed initialize SoapClient. Error: "%s"', $e->getMessage()));
     }
 }
示例#10
0
文件: Tag.php 项目: ngnpope/jerity
 /**
  * Checks for deprecated attributes and warns the developer - only displays a 
  * message if debugging is enabled.
  *
  * @see  http://dev.w3.org/html5/html4-differences/#absent-attributes
  */
 protected static function checkDeprecatedAttributes($tag, $attrs)
 {
     $deprecated[RenderContext::LANG_HTML]['5'] = array('a' => array('charset', 'coords', 'rev', 'shape'), 'area' => array('nohref'), 'body' => array('alink', 'background', 'bgcolor', 'link', 'text', 'vlink'), 'br' => array('clear'), 'caption' => array('align'), 'col' => array('align', 'char', 'charoff', 'valign', 'width'), 'colgroup' => array('align', 'char', 'charoff', 'valign', 'width'), 'div' => array('align'), 'dl' => array('compact'), 'h1' => array('align'), 'h2' => array('align'), 'h3' => array('align'), 'h4' => array('align'), 'h5' => array('align'), 'h6' => array('align'), 'head' => array('profile'), 'hr' => array('align', 'noshade', 'size', 'width'), 'html' => array('version'), 'iframe' => array('align', 'frameborder', 'marginheight', 'longdesc', 'marginwidth', 'scrolling'), 'img' => array('align', 'hspace', 'longdesc', 'name', 'vspace'), 'input' => array('align'), 'legend' => array('align'), 'li' => array('type'), 'link' => array('charset', 'rev', 'target'), 'menu' => array('compact'), 'meta' => array('scheme'), 'object' => array('align', 'archive', 'border', 'classid', 'codebase', 'codetype', 'declare', 'hspace', 'standby', 'vspace'), 'ol' => array('compact', 'type'), 'p' => array('align'), 'param' => array('type', 'valuetype'), 'pre' => array('width'), 'table' => array('align', 'bgcolor', 'border', 'cellpadding', 'cellspacing', 'frame', 'rules', 'width'), 'tbody' => array('align', 'char', 'charoff', 'valign'), 'td' => array('abbr', 'align', 'axis', 'bgcolor', 'char', 'charoff', 'height', 'nowrap', 'scope', 'valign', 'width'), 'tfoot' => array('align', 'char', 'charoff', 'valign'), 'th' => array('abbr', 'align', 'axis', 'bgcolor', 'char', 'charoff', 'height', 'nowrap', 'valign', 'width'), 'thead' => array('align', 'char', 'charoff', 'valign'), 'tr' => array('align', 'bgcolor', 'char', 'charoff', 'valign'), 'ul' => array('compact', 'type'));
     $deprecated[RenderContext::LANG_XHTML]['5'] =& $deprecated[RenderContext::LANG_HTML]['5'];
     $ctx = RenderContext::get();
     $x = $deprecated;
     if (array_key_exists($ctx->getLanguage(), $x)) {
         $x = $x[$ctx->getLanguage()];
         if (array_key_exists("{$ctx->getVersion()}", $x)) {
             $x = $x[$ctx->getVersion()];
             if (in_array($tag, array_keys($x))) {
                 $x = $x[$tag];
                 foreach ($attrs as $a) {
                     if (!in_array($a, $x)) {
                         continue;
                     }
                     $restore_xdebug = false;
                     if (extension_loaded('xdebug')) {
                         $restore_xebug = xdebug_is_enabled();
                         # A complete stack trace is overkill for a deprecation error
                         xdebug_disable();
                     }
                     trigger_error("'{$tag}[{$a}]' is deprecated or removed in {$ctx->getLanguage()} {$ctx->getVersion()}", E_USER_DEPRECATED);
                     if ($restore_xdebug) {
                         xdebug_enable();
                     }
                 }
             }
         }
     }
 }
示例#11
0
文件: DB.php 项目: ircoco/BlackCatCMS
 /**
  * connect to the database; returns Doctrine connection
  *
  * @access public
  * @return object
  **/
 public static function connect($opt = array())
 {
     self::setExceptionHandler();
     if (!self::$conn) {
         $config = new \Doctrine\DBAL\Configuration();
         $config->setSQLLogger(new Doctrine\DBAL\Logging\DebugStack());
         if (!defined('CAT_DB_NAME') && file_exists(dirname(__FILE__) . '/../../../config.php')) {
             include dirname(__FILE__) . '/../../../config.php';
         }
         $connectionParams = array('charset' => 'utf8', 'driver' => 'pdo_mysql', 'dbname' => isset($opt['DB_NAME']) ? $opt['DB_NAME'] : CAT_DB_NAME, 'host' => isset($opt['DB_HOST']) ? $opt['DB_HOST'] : CAT_DB_HOST, 'password' => isset($opt['DB_PASSWORD']) ? $opt['DB_PASSWORD'] : CAT_DB_PASSWORD, 'user' => isset($opt['DB_USERNAME']) ? $opt['DB_USERNAME'] : CAT_DB_USERNAME, 'port' => isset($opt['DB_PORT']) ? $opt['DB_PORT'] : CAT_DB_PORT);
         if (function_exists('xdebug_is_enabled')) {
             $xdebug_state = xdebug_is_enabled();
         } else {
             $xdebug_state = false;
         }
         if (function_exists('xdebug_disable')) {
             xdebug_disable();
         }
         try {
             self::$conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config);
         } catch (\PDO\PDOException $e) {
             $this->setError($e->message);
             CAT_Object::printFatalError($e->message);
         }
         if (function_exists('xdebug_enable') && $xdebug_state) {
             xdebug_enable();
         }
     }
     self::restoreExceptionHandler();
     return self::$conn;
 }
示例#12
0
文件: debug.class.php 项目: Geotex/v6
 protected final function __construct()
 {
     // Turn error reporting off as it is displayed in debugger mode only!
     ini_set('display_errors', false);
     // Show ALL errors & notices
     error_reporting(E_ALL ^ E_NOTICE);
     ini_set('ignore_repeated_errors', true);
     ini_set('ignore_repeated_source', true);
     // Enable HTML Error messages
     ini_set('html_errors', true);
     ini_set('docref_root', 'http://docs.php.net/manual/en/');
     ini_set('docref_ext', '.php');
     // Define the Error & Exception handlers
     set_error_handler(array(&$this, 'errorLogger'), ini_get('error_reporting'));
     set_exception_handler(array(&$this, 'exceptionHandler'));
     // Enable debugger
     if (isset($GLOBALS['config']) && is_object($GLOBALS['config'])) {
         $this->_enabled = (bool) $GLOBALS['config']->get('config', 'debug');
         $ip_string = $GLOBALS['config']->get('config', 'debug_ip_addresses');
         if (!empty($ip_string)) {
             if (strstr($ip_string, ',')) {
                 $ip_addresses = explode(',', $ip_string);
                 if (!in_array(get_ip_address(), $ip_addresses)) {
                     $this->_enabled = false;
                 }
             } else {
                 if ($ip_string !== get_ip_address()) {
                     $this->_enabled = false;
                 }
             }
         }
     }
     //If its time to clear the cache
     if (isset($_GET['debug-cache-clear'])) {
         $GLOBALS['cache']->clear();
         $GLOBALS['cache']->tidy();
         httpredir(currentPage(array('debug-cache-clear')));
     }
     //Check for xdebug
     if (extension_loaded('xdebug') && function_exists('xdebug_is_enabled')) {
         $this->_xdebug = xdebug_is_enabled();
     }
     $this->_debug_timer = $this->_getTime();
     // Check register_globals
     if (ini_get('register_globals')) {
         trigger_error('register_globals are enabled. It is highly recommended that you disable this in your PHP configuration, as it is a large security hole, and may wreak havoc.', E_USER_WARNING);
     }
     Sanitize::cleanGlobals();
 }
示例#13
0
文件: page.php 项目: rentalhost/core
">
						<?php 
echo $core_lang->get_value($lang_order[0]);
?>
					</div>
					&#41;
				</span>
				<span class="labs-platform"><?php 
echo $lang->running_on(CORE_TITLE, CORE_VERSION, PHP_VERSION);
?>
</span>
			</div>
		</div>

		<?php 
$xdebug_enabled = extension_loaded('xdebug') && xdebug_is_enabled();
?>

		<div id="content">
			<div class="content">
				<ul id="toolbar">
					<li data-href=""><?php 
echo $lang->button_run;
?>
</li>
					<?php 
if ($xdebug_enabled) {
    $extra_class = isset($_GET['class']) ? 'class=' . urlencode($_GET['class']) . '&' : null;
    ?>
					<li data-href="?<?php 
    echo $extra_class;
示例#14
0
if (!class_exists('SemanticMediaWiki') || ($version = SemanticMediaWiki::getVersion()) === null) {
    die("\\Semantic MediaWiki is not available, please check your LocalSettings or Composer settings.\n");
}
// @codingStandardsIgnoreStart phpcs, ignore --sniffs=Generic.Files.LineLength.MaxExceeded
print sprintf("\n%-20s%s\n", "Semantic MediaWiki:", $version . ' (' . implode(', ', SemanticMediaWiki::getEnvironment()) . ')');
// @codingStandardsIgnoreEnd
if (is_readable($path = __DIR__ . '/../vendor/autoload.php')) {
    print sprintf("%-20s%s\n", "MediaWiki:", $GLOBALS['wgVersion'] . " (Extension vendor autoloader)");
} elseif (is_readable($path = __DIR__ . '/../../../vendor/autoload.php')) {
    print sprintf("%-20s%s\n", "MediaWiki:", $GLOBALS['wgVersion'] . " (MediaWiki vendor autoloader)");
} else {
    die('To run tests it is required that packages are installed using Composer.');
}
print sprintf("%-20s%s\n", "Site language:", $GLOBALS['wgLanguageCode']);
$dateTimeUtc = new \DateTime('now', new \DateTimeZone('UTC'));
print sprintf("\n%-20s%s\n", "Execution time:", $dateTimeUtc->format('Y-m-d h:i'));
if (extension_loaded('xdebug') && xdebug_is_enabled()) {
    print sprintf("%-20s%s\n\n", "Xdebug:", phpversion('xdebug') . ' (enabled)');
} else {
    print sprintf("%-20s%s\n\n", "Xdebug:", 'Disabled (or not installed)');
}
/**
 * Available to aid third-party extensions therefore any change should be made with
 * care
 *
 * @since  2.0
 */
$autoloader = (require $path);
$autoloader->addPsr4('SMW\\Tests\\Utils\\', __DIR__ . '/phpunit/Utils');
$autoloader->addClassMap(array('SMW\\Tests\\TestEnvironment' => __DIR__ . '/phpunit/TestEnvironment.php', 'SMW\\Tests\\MwDBaseUnitTestCase' => __DIR__ . '/phpunit/MwDBaseUnitTestCase.php', 'SMW\\Tests\\ByJsonTestCaseProvider' => __DIR__ . '/phpunit/ByJsonTestCaseProvider.php', 'SMW\\Tests\\JsonTestCaseFileHandler' => __DIR__ . '/phpunit/JsonTestCaseFileHandler.php', 'SMW\\Test\\QueryPrinterTestCase' => __DIR__ . '/phpunit/QueryPrinterTestCase.php', 'SMW\\Test\\QueryPrinterRegistryTestCase' => __DIR__ . '/phpunit/QueryPrinterRegistryTestCase.php'));
return $autoloader;
示例#15
0
 /**
  * Gets the backgrace from an exception.
  *
  * If xdebug is installed
  *
  * @param Exception $e
  * @return array
  */
 protected function getTrace(\Exception $e)
 {
     $traces = $e->getTrace();
     // Get trace from xdebug if enabled, failure exceptions only trace to the shutdown handler by default
     if (!$e instanceof \ErrorException) {
         return $traces;
     }
     if (!Misc::isLevelFatal($e->getSeverity())) {
         return $traces;
     }
     if (!extension_loaded('xdebug') || !xdebug_is_enabled()) {
         return array();
     }
     // Use xdebug to get the full stack trace and remove the shutdown handler stack trace
     $stack = array_reverse(xdebug_get_function_stack());
     $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
     $traces = array_diff_key($stack, $trace);
     return $traces;
 }
 /**
  * Connect to the web service and return the connection
  *
  * @since 0.1
  * @throws SoapFault for the following conditions:
  *         Invalid username/password
  *         WSDL error/unavailable (note that XDebug must be disabled otherwise this becomes a un-catchable fatal.  This can be done with xdebug_disable() followed by xdebug_enable() )
  * @return SoapClient connection to the web service
  */
 private function get_connection()
 {
     if (is_object($this->client)) {
         return $this->client;
     }
     $enable_xdebug = function_exists('xdebug_is_enabled') && xdebug_is_enabled() ? true : false;
     // disable xdebug
     if (function_exists('xdebug_disable')) {
         xdebug_disable();
     }
     // setup a new SoapClient and don't cache the WSDL
     $this->client = @new SoapClient($this->endpoint, array('cache_wsdl' => 'WSDL_CACHE_NONE'));
     // enable xdebug
     if ($enable_xdebug && function_exists('xdebug_enable')) {
         xdebug_enable();
     }
     return $this->client;
 }
示例#17
0
 /**
  *    Sets the name of the test suite.
  *    @param string $label    Name sent at the start and end
  *                            of the test.
  *    @access public
  */
 function __construct($label = false)
 {
     $this->_label = $label ? $label : get_class($this);
     $this->_test_cases = array();
     $this->_old_track_errors = ini_get('track_errors');
     $this->_xdebug_is_enabled = function_exists('xdebug_is_enabled') ? xdebug_is_enabled() : false;
 }
示例#18
0
    function fetchLog()
    {
        global $cfg;
        if ($cfg['servertype'] == 'prod') {
            return "";
        }
        if ($this->enabled) {
            $this->printed = true;
            ob_start();
            ?>
	    <div id="log">
	        <table id="log" border="1" summary="table">
	    	<thead>
			<?php 
            print LogEntry::getHeader();
            ?>
	    	</thead>
	    	<tbody>
			<?php 
            for ($i = count($this->entries) - 1; $i >= 0; $i--) {
                $row = $this->entries[$i];
                print $row->getEntry();
            }
            ?>
	    	    <tr>
			    <?php 
            $peak_mem = sprintf("%.3f MB", memory_get_peak_usage() / 1000000);
            $memory_limit = ini_get('memory_limit');
            if (function_exists("xdebug_is_enabled") && xdebug_is_enabled()) {
                $time_in_db = Dbase::get_all_timer_info();
                $time = sprintf("%.3f ms", xdebug_time_index() * 1000);
            }
            echo <<<EOT
\t\t<pre>
\t\tFinal Debugging Info
\t\tTotal time taken      : {$time}
\t\tPeak Memory Used      : {$peak_mem}
\t\tTime spend in DB      : {$time_in_db}
\t\tMemory Limit          : {$memory_limit};
\t\t</pre>
EOT;
            ?>
	    	    </tr>
	    	</tbody>
	        </table>
	    </div>
	    <?php 
            return ob_get_clean();
            //return  "Log: ".$this->getLevel()."\n".str_replace("<br />","\n", $this->msg)." ";
        }
    }
 function GroupTest($label)
 {
     $this->_label = $label;
     $this->_test_cases = array();
     $this->_old_track_errors = ini_get('track_errors');
     $this->_xdebug_is_enabled = function_exists('xdebug_is_enabled') ? xdebug_is_enabled() : false;
 }
 public function render($nameOrModel, $values = null)
 {
     if ($nameOrModel instanceof Model) {
         $model = $nameOrModel;
         $nameOrModel = $model->getTemplate();
         if (empty($nameOrModel)) {
             throw new Exception\DomainException(sprintf('%s: received View Model argument, but template is empty', __METHOD__));
         }
         $options = $model->getOptions();
         foreach ($options as $setting => $value) {
             $method = 'set' . $setting;
             if (method_exists($this, $method)) {
                 $this->{$method}($value);
             }
             unset($method, $setting, $value);
         }
         unset($options);
         // Give view model awareness via ViewModel helper
         $helper = $this->plugin('view_model');
         $helper->setCurrent($model);
         $values = $model->getVariables();
         unset($model);
     }
     $this->__engine->set('doctype', $this->doctype());
     $this->__engine->set('headTitle', $this->headTitle());
     $this->__engine->set('headScript', $this->headScript());
     $this->__engine->set('headLink', $this->headLink());
     $this->__engine->set('headMeta', $this->headMeta());
     $this->__engine->set('headStyle', $this->headStyle());
     $this->__engine->set('content', '');
     $values = $values ?: array();
     foreach ($values as $key => $value) {
         $this->__engine->set($key, $value);
     }
     if ($this->__purgeCacheBeforeRender) {
         $cacheFolder = $this->__engine->getPhpCodeDestination();
         if (is_dir($cacheFolder)) {
             foreach (new DirectoryIterator($cacheFolder) as $cacheItem) {
                 if (strncmp($cacheItem->getFilename(), 'tpl_', 4) != 0 || $cacheItem->isdir()) {
                     continue;
                 }
                 @unlink($cacheItem->getPathname());
             }
         }
     }
     $template = $this->resolver($nameOrModel);
     $this->__engine->setTemplate($template);
     unset($nameOrModel);
     unset($template);
     if ($this->__compressWhitespace == true) {
         $this->__engine->addPreFilter(new PHPTAL_PreFilter_Compress());
     }
     try {
         $result = $this->__engine->execute();
     } catch (PHPTAL_TemplateException $e) {
         // If the exception is a root PHPTAL_TemplateException
         // rather than a subclass of this exception and xdebug is enabled,
         // it will have already been picked up by xdebug, if enabled, and
         // should be shown like any other php error.
         // Any subclass of PHPTAL_TemplateException can be handled by
         // the phptal internal exception handler as it gives a useful
         // error output
         if (get_class($e) == 'PHPTAL_TemplateException' && function_exists('xdebug_is_enabled') && xdebug_is_enabled()) {
             exit;
         }
         throw $e;
     }
     return $result;
 }
示例#21
0
<?php

if (function_exists('xdebug_is_enabled')) {
    if (xdebug_is_enabled()) {
        echo "it seems xdebug is installed and enabled showing memory usage is \n";
        echo number_format(xdebug_memory_usage());
    } else {
        echo "xdebug is installed but not enabled \n";
    }
} else {
    echo 'it seems like xdebug is not installed <a href="http://xdebug.org/wizard.php">http://xdebug.org/wizard.php</a> \\n';
}
示例#22
0
文件: View.php 项目: namesco/ztal
 /**
  * Returns PHPTAL output - either from a render or from the cache.
  *
  * @param string|array $template The name of the template to render or
  *                               an array with the ('src') src for a template
  *                               and a ('name') name to help identify the
  *                               template in error messages.
  *
  * @return string
  */
 public function render($template)
 {
     // Check we are fully configured and initialised.
     if ($this->_engine == null) {
         throw new \Zend_View_Exception('PHPTAL is not defined', $this);
     }
     // If a cache has been setup and content is available, return it
     if ($this->_zendPageCacheContent != false) {
         return $this->_zendPageCacheContent;
     }
     // Setup the script locations based on the view's script paths
     $this->_engine->setTemplateRepository($this->getScriptPaths());
     // Do this at this point rather than in the constructor because we don't
     // know what the template repositories are going to be at that point.
     $this->_engine->addSourceResolver(new PharResolver($this->getScriptPaths()));
     // Assign all the variables set here through to the PHPTAL engine.
     foreach ($this->getVars() as $key => $value) {
         $this->_engine->set($key, $value);
     }
     if (!is_array($template)) {
         $this->_engine->setTemplate($this->_convertTemplateName($template));
     } else {
         $this->_engine->setSource($template['src'], $template['name']);
     }
     // Setup a collection of standard variable available in the view
     $this->_engine->set('doctype', $this->doctype());
     $this->_engine->set('headTitle', $this->headTitle());
     $this->_engine->set('headScript', $this->headScript());
     $this->_engine->set('headLink', $this->headLink());
     $this->_engine->set('headMeta', $this->headMeta());
     $this->_engine->set('headStyle', $this->headStyle());
     $this->productionMode = 'production' == APPLICATION_ENV;
     // If perging of the tal template cache is enabled
     // find all template cache files and delete them
     if ($this->_purgeCacheBeforeRender) {
         $cacheFolder = $this->_engine->getPhpCodeDestination();
         if (is_dir($cacheFolder)) {
             foreach (new \DirectoryIterator($cacheFolder) as $cacheItem) {
                 if (strncmp($cacheItem->getFilename(), 'tpl_', 4) != 0 || $cacheItem->isdir()) {
                     continue;
                 }
                 @unlink($cacheItem->getPathname());
             }
         }
     }
     // if a layout is being used and nothing has already overloaded the viewContent,
     // register the content as viewContent, otherwise set it to empty
     if (!isset($this->viewContent)) {
         if ($this->getHelperPath('layout') != false && $this->layout()->isEnabled()) {
             $this->_engine->set('viewContent', $this->layout()->content);
         } else {
             $this->viewContent = '';
         }
     }
     if (!$this->_preFiltersRegistered) {
         // Strip html comments and compress un-needed whitespace
         $this->_engine->addPreFilter(new \PHPTAL_PreFilter_StripComments());
         if ($this->_compressWhitespace == true) {
             $this->_engine->addPreFilter(new \PHPTAL_PreFilter_Compress());
         }
         $this->_preFiltersRegistered = true;
     }
     try {
         $result = $this->_engine->execute();
     } catch (\PHPTAL_TemplateException $e) {
         // If the exception is a root PHPTAL_TemplateException
         // rather than a subclass of this exception and xdebug is enabled,
         // it will have already been picked up by xdebug, if enabled, and
         // should be shown like any other php error.
         // Any subclass of PHPTAL_TemplateException can be handled by
         // the phptal internal exception handler as it gives a useful
         // error output
         if (get_class($e) == 'PHPTAL_TemplateException' && function_exists('xdebug_is_enabled') && xdebug_is_enabled()) {
             exit;
         }
         throw $e;
     }
     // If the page needed to be rendered but was configured to
     // cache then cache the result of the render.
     if ($this->_zendPageCache instanceof \Zend_Cache_Core) {
         $this->_zendPageCache->save($result, $this->_zendPageCacheKey, array(), $this->_zendPageCacheDuration);
     }
     return $result;
 }
示例#23
0
文件: View.php 项目: jo-m/ecamp3
 /**
  * Returns PHPTAL output - either from a render or from the cache.
  *
  * @param string|array $template The name of the template to render or
  *                                an array with the ('src') src for a template
  *                                and a ('name') name to help identify the
  *                                template in error messages.
  *
  * @return string
  */
 public function render($template)
 {
     $this->_checkLoaded();
     if ($this->_zendPageCacheContent != false) {
         return $this->_zendPageCacheContent;
     }
     if (!is_array($template)) {
         //conversion of template names from '-' split to camel-case
         $templateParts = explode('-', $template);
         $firstPart = array_shift($templateParts);
         foreach ($templateParts as &$currentPart) {
             $currentPart = ucfirst($currentPart);
         }
         $template = $firstPart . implode('', $templateParts);
         $this->_engine->setTemplate($template);
     } else {
         $this->_engine->setSource($template['src'], $template['name']);
     }
     $this->productionMode = 'production' == APPLICATION_ENV;
     $this->_engine->set('doctype', $this->doctype());
     $this->_engine->set('headTitle', $this->headTitle());
     $this->_engine->set('headScript', $this->headScript());
     $this->_engine->set('headLink', $this->headLink());
     $this->_engine->set('headMeta', $this->headMeta());
     $this->_engine->set('headStyle', $this->headStyle());
     if ($this->_purgeCacheBeforeRender) {
         $cacheFolder = $this->_engine->getPhpCodeDestination();
         if (is_dir($cacheFolder)) {
             foreach (new DirectoryIterator($cacheFolder) as $cacheItem) {
                 if (strncmp($cacheItem->getFilename(), 'tpl_', 4) != 0 || $cacheItem->isdir()) {
                     continue;
                 }
                 @unlink($cacheItem->getPathname());
             }
         }
     }
     // if a layout is being used and nothing has already overloaded the viewContent,
     // register the content as viewContent, otherwise set it to empty
     if (!isset($this->viewContent)) {
         if ($this->getHelperPath('layout') != false && $this->layout()->isEnabled()) {
             $this->_engine->set('viewContent', $this->layout()->content);
         } else {
             $this->viewContent = '';
         }
     }
     // Strip html comments and compress un-needed whitespace
     $this->_engine->addPreFilter(new PHPTAL_PreFilter_StripComments());
     if ($this->_compressWhitespace == true) {
         $this->_engine->addPreFilter(new PHPTAL_PreFilter_Compress());
     }
     try {
         $result = $this->_engine->execute();
     } catch (PHPTAL_TemplateException $e) {
         // If the exception is a root PHPTAL_TemplateException
         // rather than a subclass of this exception and xdebug is enabled,
         // it will have already been picked up by xdebug, if enabled, and
         // should be shown like any other php error.
         // Any subclass of PHPTAL_TemplateException can be handled by
         // the phptal internal exception handler as it gives a useful
         // error output
         if (get_class($e) == 'PHPTAL_TemplateException' && function_exists('xdebug_is_enabled') && xdebug_is_enabled()) {
             exit;
         }
         throw $e;
     }
     if ($this->_zendPageCache instanceof Zend_Cache_Core) {
         $this->_zendPageCache->save($result, $this->_zendPageCacheKey, array(), $this->_zendPageCacheDuration);
     }
     return $result;
 }
示例#24
0
 public function testMaximumNesting()
 {
     if (!function_exists('xdebug_is_enabled')) {
         $this->markTestSkipped('xDebug is not installed');
     }
     $xdebug_start = !xdebug_is_enabled();
     if ($xdebug_start) {
         xdebug_enable();
     }
     ini_set('xdebug.max_nesting_level', 200);
     $file = new \SplTempFileObject();
     for ($i = 0; $i < 500; $i++) {
         $file->fwrite("1,2,3\n");
     }
     $reader = new CsvReader($file);
     $reader->rewind();
     $reader->setStrict(true);
     $reader->setColumnHeaders(array('one', 'two'));
     $current = $reader->current();
     $this->assertEquals(null, $current);
     if ($xdebug_start) {
         xdebug_disable();
     }
 }
示例#25
0
 /**
  * Initializes Soap Client with WSDL and an options array
  *
  * @throws CouldNotConnectException
  */
 protected function initializeClient()
 {
     // Store some specific soap-client related data locally
     // so it can be injected in the SoapClient and compared
     // for changes later
     $this->wsdl = $this->request->getLocation();
     $this->clientOptions = $this->request->getOptions();
     // store hash to make it possible to detect changes to the client
     $this->clientHash = $this->makeSoapClientHash();
     $xdebugEnabled = extension_loaded('xdebug') && xdebug_is_enabled();
     try {
         // temporarily disable xdebug to prevent PHP Fatal error
         // while constructing SoapClient
         if ($xdebugEnabled) {
             xdebug_disable();
         }
         $this->client = app($this->soapClientClass, [$this->wsdl, $this->clientOptions]);
         if ($xdebugEnabled) {
             xdebug_enable();
         }
     } catch (SoapFault $e) {
         throw new CouldNotConnectException($e->getMessage(), $e->getCode(), $e);
     } catch (Exception $e) {
         throw new CouldNotConnectException($e->getMessage(), $e->getCode(), $e);
     }
 }
示例#26
0
function gjShowErrors()
{
    //call this first after session start
    error_reporting(E_ALL);
    //for test if sessionstart put it after error_reporting
    ini_set('display_errors', 1);
    // 1 to display errors
    ini_set('log_errors', 1);
    global $gjDebug;
    global $gjLocal;
    //usually have to set this in php.ini
    //xdebug_disable();
    //xdebug.collect_assignments
    ini_set('xdebug.collect_includes', '1');
    ini_set('xdebug.collect_params', '1');
    //terse is 1
    ini_set('xdebug.collect_return', '1');
    ini_set('xdebug.collect_vars', '1');
    //for xdebug_get_declared_vars().
    //xdebug.coverage_enable
    ini_set('xdebug.default_enable', '1');
    ini_set('xdebug.dump.SERVER', 'REQUEST_URI,REQUEST_METHOD');
    ini_set('xdebug.dump.GET', '*');
    ini_set('xdebug.dump.SESSION', '*');
    ini_set('xdebug.dump.REQUEST', '*');
    ini_set('xdebug.dump.FILES', '*');
    ini_set('xdebug.dump.COOKIE', '*');
    ini_set('xdebug.dump_globals', '1');
    //xdebug.dump_undefined
    //xdebug.extended_info  only in php.ini
    //xdebug.file_link_format for IDE
    //xdebug.idekey
    //xdebug.manual_url ,link to php manual  defualt http://www.php.net
    ini_set('xdebug.max_nesting_level', '50');
    //xdebug.overload_var_dump
    //xdebug.profiler_append
    //xdebug.profiler_enable
    // ... more profiler options
    // ... more remote options
    ini_set('xdebug.scream', '1');
    // xdebug.show_exception_trace
    ini_set('xdebug.show_local_vars', '1');
    //xdebug.show_mem_delta
    //xdebug.trace_enable_trigger
    ini_set('xdebug.trace_format', '0');
    //0 is for the editor 1 is for IDEs 2 is html
    // xdebug.trace_options
    //xdebug.trace_output_dir  /tmp
    // bad  see php.ini ini_set('xdebug.trace_output_name', 'F:\tmp');
    ini_set('xdebug.var_display_max_children', '128');
    ini_set('xdebug.var_display_max_data', '-1');
    ini_set('xdebug.var_display_max_depth', '-1');
    //not set up on hosted accounts
    if ($gjLocal) {
        try {
            xdebug_enable();
            if (xdebug_is_enabled()) {
                echo 'stack traces are enabled - debugging<BR>';
                //xdebug_start_error_collection();
                echo 'xdebug_memory_usage() ' . number_format(xdebug_memory_usage()) . '<BR>';
                xdebug_start_trace();
            } else {
                echo 'not debugging<br>';
            }
        } catch (Exception $e) {
            echo 'Caught Exception -> message: ', $e->getMessage(), "\n";
            //   or if extended over ridden exception var_dump e->getMessage()
        }
    }
    /*
    xdebug_start_error_collection();
    Starts recording all notices, warnings and errors and prevents their display
    Xdebug will cause PHP not to display any notices, warnings or errors.
    Instead, they are formatted according to Xdebug's normal error formatting rules
    (ie, the error table with the red exclamation mark) and then stored in a buffer.
    This will continue until you call .
    xdebug_stop_error_collection();
    This buffer's contents can be retrieved by calling
    xdebug_get_collected_errors()
    */
    /*
    $bt = debug_backtrace();
    - Generates a user-level error/warning/notice message
    trigger_error("I want a backtrace", E_USER_ERROR);
    debug_print_backtrace() - Prints a backtrace
    */
}
    /**
     * Renders the form shown on top of the test screen
     *
     * @return string HTML code for the test selection/submission form
     * @author Karsten Dambekalns <*****@*****.**>
     */
    protected function renderTestForm()
    {
        echo '<form action="testing/" id="packageselectorbox" method="post">' . PHP_EOL;
        $this->renderPackageSelectorBox();
        echo '<br /><label title="Xdebug is required in order to enable code coverage analysis"><input type="checkbox" name="collectCodeCoverageData" value="1" ';
        if (function_exists('xdebug_is_enabled') && xdebug_is_enabled()) {
            echo isset($_REQUEST['collectCodeCoverageData']) && $_REQUEST['collectCodeCoverageData'] ? 'checked="checked"' : '';
        } else {
            echo 'disabled="disabled"';
        }
        echo '/> analyze Code Coverage</label><br />';
        echo '<label title="Run unit tests"><input type="checkbox" name="testTypes[]" value="' . self::TYPE_UNIT . '" ' . (in_array(self::TYPE_UNIT, $this->testTypes) ? 'checked="checked"' : '');
        echo '/> Unit </label>';
        echo '<label title="Run unit tests"><input type="checkbox" name="testTypes[]" value="' . self::TYPE_INTEGRATION . '" ' . (in_array(self::TYPE_INTEGRATION, $this->testTypes) ? 'checked="checked"' : '');
        echo '/> Integration </label>';
        echo '<label title="Run unit tests"><input type="checkbox" name="testTypes[]" value="' . self::TYPE_SYSTEM . '" ' . (in_array(self::TYPE_SYSTEM, $this->testTypes) ? 'checked="checked"' : '');
        echo '/> System </label>';
        echo '<input type="submit" value=" Run " />
			</form>';
    }
示例#28
0
 public function getBackTrace(Exception $exception)
 {
     $traces = array();
     if ($exception instanceof KExceptionError) {
         $traces = $exception->getTrace();
         //Remove the first trace containing the call to KExceptionHandler
         unset($traces[0]);
         //Get trace from xdebug if enabled
         if ($exception instanceof KExceptionFailure && extension_loaded('xdebug') && xdebug_is_enabled()) {
             $stack = array_reverse(xdebug_get_function_stack());
             $trace = debug_backtrace(PHP_VERSION_ID >= 50306 ? DEBUG_BACKTRACE_IGNORE_ARGS : false);
             $traces = array_diff_key($stack, $trace);
         }
     } else {
         $traces = $exception->getTrace();
     }
     //Remove the keys from the trace, we don't need those.
     $traces = array_values($traces);
     return $traces;
 }
 /**
  * Fetches any test output from the output buffer. If xdebug is not enabled the output
  * is run through htmlspecialchars() and nl2br() before it is returned.
  *
  * @return string HTML code of test output (if any)
  * @author Karsten Dambekalns <*****@*****.**>
  */
 protected function getTestOutput()
 {
     if (function_exists('xdebug_is_enabled') && xdebug_is_enabled()) {
         return @ob_get_clean();
     } else {
         return nl2br(htmlspecialchars(@ob_get_clean()));
     }
 }
示例#30
0
 /**
  * Gets the backgrace from an exception.
  *
  * If xdebug is installed
  *
  * @param Exception $e
  * @return array
  */
 protected function getTrace(\Exception $e)
 {
     $traces = $e->getTrace();
     // Get trace from xdebug if enabled, failure exceptions only trace to the shutdown handler by default
     if (!$e instanceof \ErrorException) {
         return $traces;
     }
     switch ($e->getSeverity()) {
         case E_ERROR:
         case E_RECOVERABLE_ERROR:
         case E_PARSE:
         case E_CORE_ERROR:
         case E_COMPILE_ERROR:
         case E_USER_ERROR:
             $fatal = true;
             break;
         default:
             $fatal = false;
             break;
     }
     if (!$fatal) {
         return $traces;
     }
     if (!extension_loaded('xdebug') || !xdebug_is_enabled()) {
         return array();
     }
     // Use xdebug to get the full stack trace and remove the shutdown handler stack trace
     $stack = array_reverse(xdebug_get_function_stack());
     $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
     $traces = array_diff_key($stack, $trace);
     return $traces;
 }