Example #1
0
 /**
  * More advanced var_export for HTML/Javascript, private recursive function
  *
  * Extracted from {@link http://mojavelinux.com/forum/viewforum.php?f=4}
  * originally by Dan Allen
  * @param mixed variable to var_export
  * @param boolean prints output by default, set to true to return a string
  * @static
  */
 function var_export2(&$variable, $return = false)
 {
     $result =& Error_Util::_var_export2($variable);
     if ($return) {
         return $result;
     } else {
         echo $result;
     }
 }
Example #2
0
 /**
  * Returns default error suffix
  * @param ERROR_RAISE_TEXT|ERROR_RAISE_HTML|ERROR_RAISE_ANSI format state
  *        that error message should be in
  * @param boolean If true, then return any context information.  By default,
  *                the source code is highlighted as PHP in HTML and returned
  *                or just returned as is in other states
  */
 function getErrorSuffix($state = ERROR_RAISE_TEXT, $context = false)
 {
     if ($context) {
         if (isset($this->backtrace)) {
             $this->_grabBacktrace();
         }
         if (isset($this->_file) && isset($this->_line)) {
             $context = Error_Util::getErrorContext($this->_file, $this->_line, $this->_contextLines);
             if ($state == ERROR_RAISE_HTML) {
                 return @highlight_string(trim($context['source']), true);
             } else {
                 $vars['context'] = trim($context['source']);
             }
             $suffix = "\n%context%\n";
             return Error_Raise::sprintfErrorMessageWithState($suffix, $vars, $state);
         }
     } else {
         return '';
     }
 }
Example #3
0
 /**
  * Change the error message generation method from one set in the
  * constructor
  *
  * If later logic requires the use of different error messages for a
  * package, use this static method to change the message generator.
  * @return true|Error_Raise_Error
  * @param string package name
  * @param string|array callback
  * @static
  */
 function setErrorMsgGenerator($package, $errorMsgGenerator)
 {
     if ($errorMsgGenerator) {
         $package = strtolower($package);
         Error_Raise::disableErrorCallbacks();
         $e = Error_Util::_validCallback($errorMsgGenerator);
         Error_Raise::reenableErrorCallbacks();
         if (PEAR::isError($e)) {
             return $e->rePackageError('Error_Raise', 'error', ERROR_RAISE_ERROR_INVALID_ERRMSGGEN, array('package' => $package));
         }
         $GLOBALS['_ERROR_RAISE_MSGS'][$package] = $errorMsgGenerator;
         return true;
     }
 }