Enabler PHP natives assertion in debug and use Platal::assert() as a
[platal.git] / include / platal.inc.php
index a174482..900220c 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -144,7 +144,14 @@ function pl_print_errors($html = false)
     }
 }
 
+function pl_assert_cb($file, $line, $message)
+{
+    Platal::assert(false, "Assertion failed at $file:$line with message: $message");
+}
+
 set_error_handler('pl_error_handler', E_ALL | E_STRICT);
+assert_options(ASSERT_CALLBACK, 'pl_assert_cb');
+assert_options(ASSERT_WARNING, false);
 if (php_sapi_name() == 'cli') {
     register_shutdown_function('pl_print_errors');
 }