Make examples fail on any PHP diagnostic

Previously we called set_error_handler() in tests.php to do this, but
that only sets it for the test-suite.  Now we set it in on the PHP
command line, which works for both.
This commit is contained in:
Olly Betts 2021-04-19 13:17:14 +12:00
commit d6f9f4b6c0
3 changed files with 1 additions and 14 deletions

View file

@ -31,9 +31,7 @@ check::is_a($spam,"spam");
check::equal(1,$spam->_foo,"1==spam->_foo");
check::equal(2,$spam->_bar,"2==spam->_bar");
// multiple inheritance not supported in PHP
set_error_handler(function () {return true;}, E_NOTICE|E_WARNING); // Don't complain that _baz is unknown.
check::equal(null,$spam->_baz,"null==spam->_baz");
restore_error_handler();
check::equal(4,$spam->_spam,"4==spam->_spam");
check::done();

View file

@ -1,16 +1,5 @@
<?php
function die_on_error($errno, $errstr, $file, $line) {
if ($file !== Null) {
print $file;
if ($line !== Null) print ":$line";
print ": ";
}
print "$errstr\n";
exit(1);
}
set_error_handler("die_on_error", -1);
$_original_functions=get_defined_functions();
$_original_globals=1;
$_original_classes=get_declared_classes();