ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
SimpleSAML\XML\Errors Class Reference
+ Collaboration diagram for SimpleSAML\XML\Errors:

Static Public Member Functions

static begin ()
 Start error logging. More...
 
static end ()
 End error logging. More...
 
static formatError ($error)
 Format an error as a string. More...
 
static formatErrors ($errors)
 Format a list of errors as a string. More...
 

Static Private Member Functions

static addErrors ()
 Append current XML errors to the current stack level. More...
 

Static Private Attributes

static $errorStack = array()
 
static $xmlErrorState
 

Detailed Description

Definition at line 15 of file Errors.php.

Member Function Documentation

◆ addErrors()

static SimpleSAML\XML\Errors::addErrors ( )
staticprivate

Append current XML errors to the current stack level.

Definition at line 32 of file Errors.php.

33  {
34  $currentErrors = libxml_get_errors();
35  libxml_clear_errors();
36 
37  $level = count(self::$errorStack) - 1;
38  self::$errorStack[$level] = array_merge(self::$errorStack[$level], $currentErrors);
39  }

◆ begin()

static SimpleSAML\XML\Errors::begin ( )
static

Start error logging.

A call to this function will begin a new error logging context. Every call must have a corresponding call to end().

Definition at line 48 of file Errors.php.

References array.

Referenced by SimpleSAML\Utils\XML\isDOMNodeOfType().

49  {
50 
51  // Check whether the error access functions are present
52  if (!function_exists('libxml_use_internal_errors')) {
53  return;
54  }
55 
56  if (count(self::$errorStack) === 0) {
57  // No error logging is currently in progress. Initialize it.
58  self::$xmlErrorState = libxml_use_internal_errors(true);
59  libxml_clear_errors();
60  } else {
61  /* We have already started error logging. Append the current errors to the
62  * list of errors in this level.
63  */
64  self::addErrors();
65  }
66 
67  // Add a new level to the error stack
68  self::$errorStack[] = array();
69  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ end()

static SimpleSAML\XML\Errors::end ( )
static

End error logging.

Returns
array An array with the LibXMLErrors which has occurred since begin() was called.

Definition at line 77 of file Errors.php.

References $ret, and array.

Referenced by SimpleSAML\Utils\XML\isDOMNodeOfType().

78  {
79 
80  // Check whether the error access functions are present
81  if (!function_exists('libxml_use_internal_errors')) {
82  // Pretend that no errors occurred
83  return array();
84  }
85 
86  // Add any errors which may have occurred
87  self::addErrors();
88 
89 
90  $ret = array_pop(self::$errorStack);
91 
92  if (count(self::$errorStack) === 0) {
93  // Disable our error logging and restore the previous state
94  libxml_use_internal_errors(self::$xmlErrorState);
95  }
96 
97  return $ret;
98  }
Create styles array
The data for the language used.
$ret
Definition: parser.php:6
+ Here is the caller graph for this function:

◆ formatError()

static SimpleSAML\XML\Errors::formatError (   $error)
static

Format an error as a string.

This function formats the given LibXMLError object as a string.

Parameters
\LibXMLError$errorThe LibXMLError which should be formatted.
Returns
string A string representing the given LibXMLError.

Definition at line 109 of file Errors.php.

References $error.

110  {
111  assert('$error instanceof LibXMLError');
112  return 'level=' . $error->level . ',code=' . $error->code . ',line=' . $error->line . ',col=' . $error->column .
113  ',msg=' . trim($error->message);
114  }
$error
Definition: Error.php:17

◆ formatErrors()

static SimpleSAML\XML\Errors::formatErrors (   $errors)
static

Format a list of errors as a string.

This fucntion takes an array of LibXMLError objects and creates a string with all the errors. Each error will be separated by a newline, and the string will end with a newline-character.

Parameters
array$errorsAn array of errors.
Returns
string A string representing the errors. An empty string will be returned if there were no errors in the array.

Definition at line 127 of file Errors.php.

References $error, $errors, and $ret.

Referenced by SimpleSAML\Utils\XML\isDOMNodeOfType().

128  {
129  assert('is_array($errors)');
130 
131  $ret = '';
132  foreach ($errors as $error) {
133  $ret .= self::formatError($error) . "\n";
134  }
135 
136  return $ret;
137  }
$error
Definition: Error.php:17
$errors
Definition: index.php:6
$ret
Definition: parser.php:6
+ Here is the caller graph for this function:

Field Documentation

◆ $errorStack

SimpleSAML\XML\Errors::$errorStack = array()
staticprivate

Definition at line 21 of file Errors.php.

◆ $xmlErrorState

SimpleSAML\XML\Errors::$xmlErrorState
staticprivate

Definition at line 26 of file Errors.php.


The documentation for this class was generated from the following file: