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 }

Referenced by SimpleSAML\XML\Errors\begin(), and SimpleSAML\XML\Errors\end().

+ Here is the caller graph for this function:

◆ 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.

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 */
65 }
66
67 // Add a new level to the error stack
68 self::$errorStack[] = array();
69 }
static addErrors()
Append current XML errors to the current stack level.
Definition: Errors.php:32

References SimpleSAML\XML\Errors\addErrors().

+ Here is the call 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.

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
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 }
$ret
Definition: parser.php:6

References $ret, and SimpleSAML\XML\Errors\addErrors().

+ Here is the call 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.

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

References $error.

Referenced by SimpleSAML\XML\Errors\formatErrors().

+ Here is the caller graph for this function:

◆ 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.

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 }
static formatError($error)
Format an error as a string.
Definition: Errors.php:109
$errors
Definition: index.php:6

References $error, $errors, $ret, and SimpleSAML\XML\Errors\formatError().

+ Here is the call 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: