public function testLoadVendorDatabaseBadMask()
 {
     // Disable PHPUnit's error handler which would stop execution upon the
     // first error.
     \PHPUnit_Framework_Error_Notice::$enabled = false;
     // Disable all console error output
     $displayErrors = ini_get('display_errors');
     $logErrors = ini_get('log_errors');
     ini_set('display_errors', false);
     ini_set('log_errors', false);
     if (extension_loaded('xdebug')) {
         xdebug_disable();
     }
     // Invoke the tested method
     $input = array("13/37\tshort7", "00:00:5E:00:53:00\tshort");
     MacAddress::loadVendorDatabase($input);
     // Restore error handling
     \PHPUnit_Framework_Error_Notice::$enabled = true;
     if (ini_get('xdebug.default_enable')) {
         xdebug_enable();
     }
     ini_set('display_errors', $displayErrors);
     ini_set('log_errors', $logErrors);
     // Test the generated error
     $lastError = error_get_last();
     $this->assertEquals(E_USER_NOTICE, $lastError['type']);
     $this->assertEquals('Ignoring MAC address 13/37 because mask is not a multiple of 4.', $lastError['message']);
     // Parsing should continue after error.
     $expected = array(array('address' => '00005E005300', 'length' => 12, 'vendor' => 'short'));
     $reflectionClass = new \ReflectionClass('Library\\MacAddress');
     $this->assertEquals($expected, $reflectionClass->getStaticProperties()['_vendorList']);
 }
Beispiel #2
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();
     }
 }
Beispiel #3
0
 /**
  * Enables or disables debugging.  This includes:
  *
  *  - Toggling xdebug
  *  - Toggling error display
  *
  * @param  boolean  $enabled  true to enable debugging, false to disable.
  */
 public static function setEnabled($enabled)
 {
     self::$enabled = (bool) $enabled;
     if ($enabled) {
         if (extension_loaded('xdebug')) {
             xdebug_enable();
         }
         ini_set('display_errors', 'on');
     } else {
         if (extension_loaded('xdebug')) {
             xdebug_disable();
         }
         ini_set('display_errors', 'off');
     }
 }
 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()));
     }
 }
Beispiel #5
0
 /**
  * Perform the actual check and return a ResultInterface
  *
  * @return ResultInterface
  */
 public function check()
 {
     try {
         if (function_exists('xdebug_disable')) {
             xdebug_disable();
         }
         @new \SoapClient($this->wsdlUrl, array('cache_wsdl' => WSDL_CACHE_NONE, 'trace' => true, 'exceptions' => true, 'stream_context' => $this->context));
         if (function_exists('xdebug_enable')) {
             xdebug_enable();
         }
         return $this->success();
     } catch (\SoapFault $e) {
         $error = error_get_last();
         if ($error !== null && $error['message'] == $e->getMessage()) {
             // Overwrites E_ERROR with E_USER_NOTICE as seen in http://stackoverflow.com/a/36667322
             // Added @ to suppress the error
             @trigger_error($e->getMessage());
         }
         return $this->failure();
     } catch (\Exception $e) {
         return $this->failure();
     }
 }
Beispiel #6
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);
     }
 }
Beispiel #7
0
 /**
  * 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();
                     }
                 }
             }
         }
     }
 }
Beispiel #8
0
 public static function XDebug($enabled = true)
 {
     if (!function_exists('xdebug_enable')) {
         return false;
     }
     if ($enabled) {
         ini_set('xdebug.collect_vars', 'on');
         ini_set('xdebug.collect_params', '1');
         ini_set('xdebug.dump_globals', 'off');
         ini_set('xdebug.dump.SERVER', 'REQUEST_URI');
         ini_set('xdebug.show_local_vars', 'off');
         xdebug_enable();
     } else {
         if (function_exists('xdebug_disable')) {
             xdebug_disable();
         }
         ini_set('xdebug.collect_vars', 'off');
         ini_set('xdebug.collect_params', '0');
     }
     return true;
 }
Beispiel #9
0
 /**
  * là c'est pour pouvoir s'en servir comme soapclient, avec du $soap->methode($arg1, $arg2) de maniere 
  * transparente
  * on y fait des eventuels traitements => si on a killé entre temps, on reconstruit
  * => si on a du csv qui arrive, on convertit en array php
  * @param type $name
  * @param type $arguments
  * @return type 
  */
 public function __call($name, $arguments)
 {
     // On desactive xDebug car c'est lui qui bug comme expliqué dans ces threads:
     // http://stackoverflow.com/questions/1406632/checking-a-url-is-valid-from-php-soap-client
     // http://bugs.xdebug.org/view.php?id=249
     xdebug_disable();
     try {
         // si killé entre temps ou jamais initialisé, on recrée
         if (!isset($this->client) && isset($this->wsdl)) {
             $this->initialize();
         }
     } catch (SoapFault $e) {
         throw new OrchestraException('Impossible de joindre le serveur centrale.', $e);
     }
     try {
         // on applique sur notre soap client
         $rtn = call_user_func_array(array($this->client, $name), $arguments);
     } catch (SoapFault $e) {
         throw new OrchestraException('Erreur d\'exécution sur la fonction ' . $name . ' au niveau du serveur centrale.', $e);
     }
     xdebug_enable();
     // on est obligé de faire une requete pour chopper un cookie, donc on attends la premiere
     if ($this->firstUse) {
         // le "PHPSESSID" c'est pas generique, vaudrait mieux chopper tout les cookies
         $this->cookie = $this->client->_cookies["PHPSESSID"][0];
         $_SESSION['SOAP'][$this->wsdl] = $this->cookie;
         $this->firstUse = false;
     }
     // si on detecte du csv (check si ","), on decode
     if (strpos($rtn, '","') != false) {
         $rtn = $this->str_getcsv_lines($rtn);
         if (count($rtn) == 1) {
             $rtn = array_pop($rtn);
         }
     }
     return $rtn;
 }
 /**
  * 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;
 }
 * Test environment constants
 */
define('PHPILLOW_TEST_ENV_SET_UP', true);
/**
 * Set timezone to get clearly defined dates
 */
date_default_timezone_set('UTC');
require __DIR__ . '/../vendor/autoload.php';
require dirname(__FILE__) . '/helper/general.php';
/**
 * Fix error reporting settings for test runs
 */
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', true);
if (function_exists('xdebug_enable')) {
    xdebug_enable(true);
}
/**
 * Set up mocks and fakes for the current test environment
 *
 * @package Tests
 * @version $Revision$
 * @license http://www.gnu.org/licenses/gpl-3.0.txt GPL
 */
class phpillowTestEnvironmentSetup
{
    /**
     * Reset database depending on provided options
     *
     * @param array $options
     * @return void
Beispiel #12
0
 /**
  * Enable showing stack traces on error conditions.
  * @return void
  */
 public function enable()
 {
     xdebug_enable();
 }
Beispiel #13
0
require_once 'GLA_PostFinalize.cc.php';
require_once 'GLA.cc.php';
require_once 'GT.cc.php';
require_once 'GIST.cc.php';
require_once 'JoinLHS.cc.php';
require_once 'JoinLHSHash.cc.php';
require_once 'JoinRHS.cc.php';
require_once 'JoinMergeWorkFuncs.cc.php';
require_once 'Cleaner.cc.php';
require_once 'Cache.cc.php';
require_once 'Cluster.cc.php';
require_once 'grokit_codegen.php';
require_once 'codegen_helpers.php';
require_once 'Make.php';
/*************** HELPER FUNCTIONS ************************/
xdebug_enable();
/*************** COMMAND LINE PARSING *********************/
if ($argc < 2) {
    echo "Usage: php Process.php query.json";
    exit(1);
}
if (!file_exists($argv[1])) {
    echo "File " . $argv[1] . " cannot be read";
    exit(1);
}
$configFile = './config/default.json';
if ($argc >= 3) {
    $configFile = $argv[2];
}
if (!file_exists($configFile)) {
    echo "Configuration file " . $configFile . " does not exist" . PHP_EOL;
    function testRegister()
    {
        $f = tempnam('/', 'test');
        $this->assertTrue(false !== $f);
        error_reporting(-1);
        $h = new InDepthErrorHandler(null, array('scream' => E_PARSE, 'trace' => 0));
        InDepthErrorHandler::register($h, $f);
        $h = InDepthErrorHandler::getHandler();
        $h->getLogger()->loggedGlobals = array();
        try {
            user_error('fake user error', E_USER_ERROR);
            $this->assertFalse(true);
        } catch (\Patchwork\PHP\InDepthRecoverableErrorException $e) {
            $h->handleUncaughtException($e);
        }
        if (function_exists('xdebug_disable')) {
            xdebug_disable();
        }
        eval("");
        // Uncatchable E_COMPILE_WARNING
        if (function_exists('xdebug_disable')) {
            xdebug_enable();
        }
        error_reporting(0);
        @eval('abc');
        // Parse error to populate error_get_last()
        InDepthErrorHandler::shutdown();
        error_reporting(-1);
        $e = file_get_contents($f);
        unlink($f);
        $this->assertStringMatchesFormat('*** php-error ***
{"_":"1:array:3",
  "time": "%s %dus - %fms - %fms",
  "mem": "%d - %d",
  "data": {"_":"4:array:4",
    "mesg": "Uncaught \\\\Patchwork\\\\PHP\\\\InDepthRecoverableErrorException: fake user error",
    "type": "E_ERROR ' . __FILE__ . ':43",
    "level": "1/-1",
    "exception": {"_":"8:Patchwork\\\\PHP\\\\InDepthRecoverableErrorException",
      "context": {"_":"9:array:2",
        "f": "' . $f . '",
        "h": {"_":"11:Patchwork\\\\PHP\\\\InDepthErrorHandler",
          "*:loggedErrors": -1,
          "*:screamErrors": 4,
          "*:thrownErrors": 4437,
          "*:scopedErrors": 0,
          "*:tracedErrors": 0,
          "*:logger": {"_":"17:Patchwork\\\\PHP\\\\Logger",
            "lineFormat": "%s",
            "loggedGlobals": [],
            "*:uniqId": %d,
            "*:logStream": {"_":"21:resource:stream",
              "~:wrapper_type": "plainfile",
              "~:stream_type": "STDIO",
              "~:mode": "ab",
              "~:unread_bytes": 0,
              "~:seekable": true,
              "~:uri": "/tmp/test%s",
              "~:timed_out": false,
              "~:blocked": true,
              "~:eof": false
            },
            "*:prevTime": %f,
            "*:startTime": %f,
            "*:isFirstEvent": true
          },
          "*:loggedTraces": []
        }
      },
      "*:message": "fake user error",
      "*:code": 0,
      "*:file": "' . __FILE__ . '",
      "*:line": 43,
      "*:severity": "E_USER_ERROR",
      "~:hash": "%x"
    }
  }
}
***
[%s] PHP Warning:  Unexpected character in input:  ' . "''" . ' (ASCII=1) state=0 in ' . __FILE__ . '(52) : eval()\'d code on line 1
*** php-error ***
{"_":"1:array:3",
  "time": "%s %dus - %fms - %fms",
  "mem": "%d - %d",
  "data": {"_":"4:array:3",
    "mesg": "syntax error, unexpected ' . (PHP_VERSION_ID >= 50400 ? 'end of file' : '$end') . '",
    "type": "E_PARSE ' . __FILE__ . '(56) : eval()\'d code:1",
    "level": "4/0"
  }
}
***
', $e);
    }
 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();
     }
 }
Beispiel #16
0
 public function checkFileExist($args)
 {
     $fileID = $args[0];
     if (strlen($fileID) > 0) {
         if (function_exists('xdebug_disable')) {
             xdebug_disable();
         }
         try {
             return true;
         } catch (Google_ServiceException $e) {
             if ($e->getCode() == 404) {
             }
             return false;
         } catch (Exception $e) {
             if ($e->getCode() == 404) {
                 //print "The event doesn't exist";
             }
             return false;
         }
         if (function_exists('xdebug_enable')) {
             xdebug_enable();
         }
     } else {
         return false;
     }
 }
    function testStart()
    {
        $f = tempnam('/', 'test');
        $this->assertTrue(false !== $f);
        error_reporting(E_ALL | E_STRICT);
        ErrorHandler::start($f);
        $h = ErrorHandler::getHandler();
        $h->tracedErrors = 0;
        $h->getLogger()->loggedGlobals = array();
        try {
            user_error('fake user error', E_USER_ERROR);
            $this->assertFalse(true);
        } catch (\Patchwork\PHP\RecoverableErrorException $e) {
            $h->handleException($e);
        }
        if (function_exists('xdebug_disable')) {
            xdebug_disable();
        }
        eval("");
        // Uncatchable E_COMPILE_WARNING
        if (function_exists('xdebug_disable')) {
            xdebug_enable();
        }
        error_reporting(0);
        @eval('abc');
        // Parse error to populate error_get_last()
        $h->scream = E_PARSE;
        ErrorHandler::shutdown();
        error_reporting(E_ALL | E_STRICT);
        $h->unregister();
        $e = file_get_contents($f);
        unlink($f);
        $this->assertStringMatchesFormat('*** php-error ***
{"_":"1:array:3",
  "time": "%s %dus - %fms - %fms",
  "mem": "%d - %d",
  "data": {"_":"4:array:4",
    "mesg": "Uncaught exception: fake user error",
    "type": "E_USER_ERROR ' . __FILE__ . ':23",
    "level": "256/32767",
    "scope": {"_":"8:array:1",
      "0": {"_":"9:Patchwork\\\\PHP\\\\RecoverableErrorException",
        "scope": {"_":"10:array:2",
          "f": "' . $f . '",
          "h": {"_":"12:Patchwork\\\\PHP\\\\ErrorHandler",
            "scream": 4433,
            "thrownErrors": 0,
            "scopedErrors": 4867,
            "tracedErrors": 0,
            "*:logger": {"_":"17:Patchwork\\\\PHP\\\\Logger",
              "writeLock": true,
              "lineFormat": "%s",
              "loggedGlobals": [],
              "*:logStream": {"_":"21:resource:stream",
                "wrapper_type": "plainfile",
                "stream_type": "STDIO",
                "mode": "ab",
                "unread_bytes": 0,
                "seekable": true,
                "uri": "' . $f . '",
                "timed_out": false,
                "blocked": true,
                "eof": false
              },
              "*:prevTime": %f,
              "*:startTime": %f,
              "*:isFirstEvent": true
            },
            "*:loggedTraces": [],
            "*:registeredErrors": 32767
          }
        },
        "*:message": "fake user error",
        "*:code": 0,
        "*:file": "' . __FILE__ . '",
        "*:line": 23,
        "*:severity": "E_USER_ERROR"
      }
    }
  }
}
***
[%s] PHP Warning:  Unexpected character in input:  ' . "''" . ' (ASCII=1) state=0 in ' . __FILE__ . '(32) : eval()\'d code on line 1
*** php-error ***
{"_":"1:array:3",
  "time": "%s %dus - %fms - %fms",
  "mem": "%d - %d",
  "data": {"_":"4:array:3",
    "mesg": "syntax error, unexpected ' . (PHP_VERSION_ID >= 50400 ? 'end of file' : '$end') . '",
    "type": "E_PARSE ' . __FILE__ . '(36) : eval()\'d code:1",
    "level": "4/0"
  }
}
***
', $e);
    }
Beispiel #18
0
 /**
  * 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;
 }
 function _disableErrorReporting()
 {
     ini_set('track_errors', $this->_old_track_errors);
     if ($this->_xdebug_is_enabled) {
         xdebug_enable();
     }
 }
Beispiel #20
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
    */
}