ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 17 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 34 of file Errors.php.

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

◆ 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 50 of file Errors.php.

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

51  {
52 
53  // Check whether the error access functions are present
54  if (!function_exists('libxml_use_internal_errors')) {
55  return;
56  }
57 
58  if (count(self::$errorStack) === 0) {
59  // No error logging is currently in progress. Initialize it.
60  self::$xmlErrorState = libxml_use_internal_errors(true);
61  libxml_clear_errors();
62  } else {
63  /* We have already started error logging. Append the current errors to the
64  * list of errors in this level.
65  */
66  self::addErrors();
67  }
68 
69  // Add a new level to the error stack
70  self::$errorStack[] = array();
71  }
+ 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 79 of file Errors.php.

References $ret.

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

80  {
81 
82  // Check whether the error access functions are present
83  if (!function_exists('libxml_use_internal_errors')) {
84  // Pretend that no errors occurred
85  return array();
86  }
87 
88  // Add any errors which may have occurred
89  self::addErrors();
90 
91 
92  $ret = array_pop(self::$errorStack);
93 
94  if (count(self::$errorStack) === 0) {
95  // Disable our error logging and restore the previous state
96  libxml_use_internal_errors(self::$xmlErrorState);
97  }
98 
99  return $ret;
100  }
$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 111 of file Errors.php.

112  {
113  assert($error instanceof LibXMLError);
114  return 'level=' . $error->level . ',code=' . $error->code . ',line=' . $error->line . ',col=' . $error->column .
115  ',msg=' . trim($error->message);
116  }

◆ 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 129 of file Errors.php.

References $errors, and $ret.

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

130  {
131  assert(is_array($errors));
132 
133  $ret = '';
134  foreach ($errors as $error) {
135  $ret .= self::formatError($error) . "\n";
136  }
137 
138  return $ret;
139  }
$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 23 of file Errors.php.

◆ $xmlErrorState

SimpleSAML\XML\Errors::$xmlErrorState
staticprivate

Definition at line 28 of file Errors.php.


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