ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Assertion.php
Go to the documentation of this file.
1<?php
2
10
11
16 private $assertion;
17
18
27 public function __construct($assertion = NULL) {
28 assert('is_null($assertion) || is_string($assertion)');
29
30 $msg = 'Assertion failed: ' . var_export($assertion, TRUE);
31 parent::__construct($msg);
32
33 $this->assertion = $assertion;
34 }
35
36
42 public function getAssertion() {
43 return $this->assertion;
44 }
45
46
53 public static function installHandler() {
54
55 assert_options(ASSERT_WARNING, 0);
56 assert_options(ASSERT_QUIET_EVAL, 0);
57 assert_options(ASSERT_CALLBACK, array('SimpleSAML_Error_Assertion', 'onAssertion'));
58 }
59
60
70 public static function onAssertion($file, $line, $message) {
71
72 if(!empty($message)) {
73 $exception = new self($message);
74 } else {
75 $exception = new self();
76 }
77
78 $exception->logError();
79 }
80
81}
An exception for terminatinating execution or to throw for unit testing.
$assertion
The assertion which failed, or NULL if only an expression was passed to the assert-function.
Definition: Assertion.php:16
getAssertion()
Retrieve the assertion which failed.
Definition: Assertion.php:42
static onAssertion($file, $line, $message)
Handle assertion.
Definition: Assertion.php:70
static installHandler()
Install this assertion handler.
Definition: Assertion.php:53
__construct($assertion=NULL)
Constructor for the assertion exception.
Definition: Assertion.php:27
catch(Exception $e) $message
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file