Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
19 changes: 10 additions & 9 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -323,21 +323,21 @@ Relevant RFCs:
Changes to error handling
-------------------------

* The new base class of the exception hierarchy is BaseException, from which
Exception extends. Typehints in exception handling code may need to be changed
to account for this.
* There are now two exception classes: Exception and Error. Both classes
implement a new interface Throwable. Type hints in exception handling code
may need to be changed to account for this.

* Some fatal errors and recoverable fatal errors now throw an EngineException
instead. As EngineException extends BaseException but not Exception, these
exceptions will not caught by existing try/catch blocks.
* Some fatal errors and recoverable fatal errors now throw an Error instead.
As Error is a separate class from Exception, these exceptions will not be
caught by existing try/catch blocks.

For the recoverable fatal errors which have been converted into an exception,
it is no longer possible to silently ignore the error from an error handler.
In particular, it is no longer possible to ignore typehint failures.
In particular, it is no longer possible to ignore type hint failures.

* Parser errors now generate a ParseException (extends BaseException). Error
* Parser errors now generate a ParseError that extends Error. Error
handling for eval()s on potentially invalid code should be changed to catch
ParseException in addition to the previous return value / error_get_last()
ParseError in addition to the previous return value / error_get_last()
based handling.

* Constructors of internal classes will now always throw an exception on
Expand All @@ -347,6 +347,7 @@ Changes to error handling

Relevant RFCs:
* https://wiki.php.net/rfc/engine_exceptions_for_php7
* https://wiki.php.net/rfc/throwable-interface
* https://wiki.php.net/rfc/internal_constructor_behaviour
* https://wiki.php.net/rfc/reclassify_e_strict

Expand Down
2 changes: 1 addition & 1 deletion Zend/tests/028.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ bool(true)

Notice: Undefined offset: 2 in %s on line %d

Fatal error: Uncaught EngineException: Function name must be a string in %s:%d
Fatal error: Uncaught Error: Function name must be a string in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d
6 changes: 3 additions & 3 deletions Zend/tests/030.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ $test->bar();
object(Exception)#%d (7) {
["message":protected]=>
string(3) "foo"
["string":"BaseException":private]=>
["string":"Exception":private]=>
string(0) ""
["code":protected]=>
int(0)
["file":protected]=>
string(%d) "%s030.php"
["line":protected]=>
int(%d)
["trace":"BaseException":private]=>
["trace":"Exception":private]=>
array(1) {
[0]=>
array(6) {
Expand All @@ -61,7 +61,7 @@ object(Exception)#%d (7) {
}
}
}
["previous":"BaseException":private]=>
["previous":"Exception":private]=>
NULL
}
'test' => '0'
Expand Down
2 changes: 1 addition & 1 deletion Zend/tests/037.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var_dump($x::$x);
--EXPECTF--
int(1)

Fatal error: Uncaught EngineException: Access to undeclared static property: Closure::$x in %s:%d
Fatal error: Uncaught Error: Access to undeclared static property: Closure::$x in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d
2 changes: 1 addition & 1 deletion Zend/tests/access_modifiers_010.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ new c;

?>
--EXPECTF--
Fatal error: Uncaught EngineException: Call to private method d::test2() from context 'a' in %s:%d
Fatal error: Uncaught Error: Call to private method d::test2() from context 'a' in %s:%d
Stack trace:
#0 %s(%d): a->test()
#1 %s(%d): c->__construct()
Expand Down
4 changes: 2 additions & 2 deletions Zend/tests/add_002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ $o->prop = "value";

try {
var_dump($a + $o);
} catch (EngineException $e) {
} catch (Error $e) {
echo "\nException: " . $e->getMessage() . "\n";
}

Expand All @@ -26,7 +26,7 @@ Exception: Unsupported operand types

Notice: Object of class stdClass could not be converted to int in %s on line %d

Fatal error: Uncaught EngineException: Unsupported operand types in %s:%d
Fatal error: Uncaught Error: Unsupported operand types in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d
4 changes: 2 additions & 2 deletions Zend/tests/add_003.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ $o->prop = "value";

try {
var_dump($o + $a);
} catch (EngineException $e) {
} catch (Error $e) {
echo "\nException: " . $e->getMessage() . "\n";
}

Expand All @@ -26,7 +26,7 @@ Exception: Unsupported operand types

Notice: Object of class stdClass could not be converted to int in %s on line %d

Fatal error: Uncaught EngineException: Unsupported operand types in %s:%d
Fatal error: Uncaught Error: Unsupported operand types in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d
4 changes: 2 additions & 2 deletions Zend/tests/add_004.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ $a = array(1,2,3);

try {
var_dump($a + 5);
} catch (EngineException $e) {
} catch (Error $e) {
echo "\nException: " . $e->getMessage() . "\n";
}

Expand All @@ -19,7 +19,7 @@ echo "Done\n";
--EXPECTF--
Exception: Unsupported operand types

Fatal error: Uncaught EngineException: Unsupported operand types in %s:%d
Fatal error: Uncaught Error: Unsupported operand types in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d
4 changes: 2 additions & 2 deletions Zend/tests/add_007.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ $s1 = "some string";

try {
var_dump($a + $s1);
} catch (EngineException $e) {
} catch (Error $e) {
echo "\nException: " . $e->getMessage() . "\n";
}

Expand All @@ -21,7 +21,7 @@ echo "Done\n";
--EXPECTF--
Exception: Unsupported operand types

Fatal error: Uncaught EngineException: Unsupported operand types in %s:%d
Fatal error: Uncaught Error: Unsupported operand types in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d
4 changes: 2 additions & 2 deletions Zend/tests/arg_unpack/string_keys.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ set_error_handler(function($errno, $errstr) {

try {
var_dump(...[1, 2, "foo" => 3, 4]);
} catch (EngineException $ex) {
} catch (Error $ex) {
var_dump($ex->getMessage());
}
try {
var_dump(...new ArrayIterator([1, 2, "foo" => 3, 4]));
} catch (EngineException $ex) {
} catch (Error $ex) {
var_dump($ex->getMessage());
}

Expand Down
2 changes: 1 addition & 1 deletion Zend/tests/array_type_hint_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ foo(123);
--EXPECTF--
3

Fatal error: Uncaught TypeException: Argument 1 passed to foo() must be of the type array, integer given, called in %sarray_type_hint_001.php on line 7 and defined in %sarray_type_hint_001.php:2
Fatal error: Uncaught TypeError: Argument 1 passed to foo() must be of the type array, integer given, called in %sarray_type_hint_001.php on line 7 and defined in %sarray_type_hint_001.php:2
Stack trace:
#0 %s(%d): foo(123)
#1 {main}
Expand Down
2 changes: 1 addition & 1 deletion Zend/tests/assert/expect_002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ assert(false);
var_dump(true);
?>
--EXPECTF--
Fatal error: Uncaught AssertionException: assert(false) in %sexpect_002.php:%d
Fatal error: Uncaught AssertionError: assert(false) in %sexpect_002.php:%d
Stack trace:
#0 %sexpect_002.php(%d): assert(false, 'assert(false)')
#1 {main}
Expand Down
2 changes: 1 addition & 1 deletion Zend/tests/assert/expect_003.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ assert.exception=1
<?php
try {
assert(false);
} catch (AssertionException $ex) {
} catch (AssertionError $ex) {
var_dump($ex->getMessage());
}
?>
Expand Down
2 changes: 1 addition & 1 deletion Zend/tests/assert/expect_004.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ assert.exception=1
<?php
try {
assert(false, "I require this to succeed");
} catch (AssertionException $ex) {
} catch (AssertionError $ex) {
var_dump($ex->getMessage());
}
?>
Expand Down
2 changes: 1 addition & 1 deletion Zend/tests/assert/expect_005.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ assert.exception=1
try {
/* by passing we test there are no leaks upon success */
assert(true, "I require this to succeed");
} catch (AssertionException $ex) {
} catch (AssertionError $ex) {
var_dump($ex->getMessage());
}
var_dump(true);
Expand Down
6 changes: 3 additions & 3 deletions Zend/tests/assert/expect_007.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ $data = array(
"value" => "testing"
);

class HeaderMalfunctionException extends AssertionException {}
class HeaderMalfunctionError extends AssertionError {}

assert (preg_match("~^([a-zA-Z0-9-]+)$~", $data["key"]), new HeaderMalfunctionException("malformed key found at {$next} \"{$data["key"]}\""));
assert (preg_match("~^([a-zA-Z0-9-]+)$~", $data["key"]), new HeaderMalfunctionError("malformed key found at {$next} \"{$data["key"]}\""));
?>
--EXPECTF--
Fatal error: Uncaught HeaderMalfunctionException: malformed key found at 1 "X-HTTP " in %sexpect_007.php:10
Fatal error: Uncaught HeaderMalfunctionError: malformed key found at 1 "X-HTTP " in %sexpect_007.php:10
Stack trace:
#0 {main}
thrown in %sexpect_007.php on line 10
2 changes: 1 addition & 1 deletion Zend/tests/assert/expect_008.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class One {
}
class Two extends One {}

class OdEar extends AssertionException {}
class OdEar extends AssertionError {}

function blah(){ return 1; }

Expand Down
2 changes: 1 addition & 1 deletion Zend/tests/assert/expect_009.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Two extends One {
new Two();
?>
--EXPECTF--
Fatal error: Uncaught AssertionException: assert(false) in %sexpect_009.php:%d
Fatal error: Uncaught AssertionError: assert(false) in %sexpect_009.php:%d
Stack trace:
#0 %sexpect_009.php(%d): assert(false, 'assert(false)')
#1 %sexpect_009.php(%d): Two->__construct()
Expand Down
2 changes: 1 addition & 1 deletion Zend/tests/assert/expect_010.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Two extends One {}
new Two();
?>
--EXPECTF--
Fatal error: Uncaught AssertionException: assert(false) in %sexpect_010.php:%d
Fatal error: Uncaught AssertionError: assert(false) in %sexpect_010.php:%d
Stack trace:
#0 %sexpect_010.php(%d): assert(false, 'assert(false)')
#1 %sexpect_010.php(%d): One->__construct()
Expand Down
4 changes: 2 additions & 2 deletions Zend/tests/assert/expect_011.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ zend.assertions=1
assert.exception=1
--FILE--
<?php
class MyExpectations extends AssertionException {
class MyExpectations extends AssertionError {
public function __toString() {
return sprintf(
"[Message]: %s", __CLASS__);
Expand All @@ -22,7 +22,7 @@ class Two extends One {}
new Two();
?>
--EXPECTF--
Fatal error: Uncaught AssertionException: [Message]: MyExpectations in %sexpect_011.php:%d
Fatal error: Uncaught AssertionError: [Message]: MyExpectations in %sexpect_011.php:%d
Stack trace:
#0 %sexpect_011.php(%d): assert(false, '[Message]: MyEx...')
#1 %sexpect_011.php(%d): One->__construct()
Expand Down
2 changes: 1 addition & 1 deletion Zend/tests/bug24773.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Bug #24773 (unset() of integers treated as arrays causes a crash)
unset($array["lvl1"]["lvl2"]["b"]);
?>
--EXPECTF--
Fatal error: Uncaught EngineException: Cannot use string offset as an array in %s:%d
Fatal error: Uncaught Error: Cannot use string offset as an array in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d
12 changes: 6 additions & 6 deletions Zend/tests/bug26166.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,25 @@ function my_error_handler($errno, $errstr, $errfile, $errline) {

set_error_handler('my_error_handler');

class None
class NoneTest
{
function __toString() {
}
}

$o = new None;
$o = new NoneTest;
echo $o;

echo "===THROW===\n";

class Error
class ErrorTest
{
function __toString() {
throw new Exception("This is an error!");
}
}

$o = new Error;
$o = new ErrorTest;
try {
echo $o;
}
Expand All @@ -68,7 +68,7 @@ catch (Exception $e) {
--EXPECTF--
Hello World!
===NONE===
string(52) "Method None::__toString() must return a string value"
string(56) "Method NoneTest::__toString() must return a string value"
===THROW===

Fatal error: Method Error::__toString() must not throw an exception in %sbug26166.php on line %d
Fatal error: Method ErrorTest::__toString() must not throw an exception in %sbug26166.php on line %d
2 changes: 1 addition & 1 deletion Zend/tests/bug29015.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ $a->$x = "string('')";
var_dump($a);
?>
--EXPECTF--
Fatal error: Uncaught EngineException: Cannot access empty property in %sbug29015.php:4
Fatal error: Uncaught Error: Cannot access empty property in %sbug29015.php:4
Stack trace:
#0 {main}
thrown in %sbug29015.php on line 4
2 changes: 1 addition & 1 deletion Zend/tests/bug29674.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ NULL
===CHILD===
string(4) "Base"

Fatal error: Uncaught EngineException: Cannot access private property ChildClass::$private_child in %sbug29674.php:%d
Fatal error: Uncaught Error: Cannot access private property ChildClass::$private_child in %sbug29674.php:%d
Stack trace:
#0 %s(%d): BaseClass->printVars()
#1 {main}
Expand Down
2 changes: 1 addition & 1 deletion Zend/tests/bug31102.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ __autoload(Test2,2)
Caught: __autoload
__autoload(Test3,3)

Fatal error: Uncaught EngineException: Class 'Test3' not found in %sbug31102.php(%d) : eval()'d code:1
Fatal error: Uncaught Error: Class 'Test3' not found in %sbug31102.php(%d) : eval()'d code:1
Stack trace:
#0 %s(%d): eval()
#1 {main}
Expand Down
2 changes: 1 addition & 1 deletion Zend/tests/bug32660.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ A Object

Notice: Indirect modification of overloaded property A::$whatever has no effect in %sbug32660.php on line 23

Fatal error: Uncaught EngineException: Cannot assign by reference to overloaded object in %sbug32660.php:23
Fatal error: Uncaught Error: Cannot assign by reference to overloaded object in %sbug32660.php:23
Stack trace:
#0 {main}
thrown in %sbug32660.php on line 23
2 changes: 1 addition & 1 deletion Zend/tests/bug33318.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Bug #33318 (throw 1; results in Invalid opcode 108/1/8)
throw 1;
?>
--EXPECTF--
Fatal error: Uncaught EngineException: Can only throw objects in %sbug33318.php:2
Fatal error: Uncaught Error: Can only throw objects in %sbug33318.php:2
Stack trace:
#0 {main}
thrown in %sbug33318.php on line 2
2 changes: 1 addition & 1 deletion Zend/tests/bug33996.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ FooTest(new Foo());
--EXPECTF--
Warning: Missing argument 1 for NormalTest(), called in %sbug33996.php on line %d and defined in %sbug33996.php on line %d
Hi!
Fatal error: Uncaught TypeException: Argument 1 passed to FooTest() must be an instance of Foo, none given, called in %sbug33996.php on line %d and defined in %sbug33996.php:%d
Fatal error: Uncaught TypeError: Argument 1 passed to FooTest() must be an instance of Foo, none given, called in %sbug33996.php on line %d and defined in %sbug33996.php:%d
Stack trace:
#0 %s(%d): FooTest()
#1 {main}
Expand Down
2 changes: 1 addition & 1 deletion Zend/tests/bug34064.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ array(1) {
string(2) "ok"
}

Fatal error: Uncaught EngineException: Cannot use [] for reading in %sbug34064.php:18
Fatal error: Uncaught Error: Cannot use [] for reading in %sbug34064.php:18
Stack trace:
#0 %s(%d): XmlTest->run()
#1 {main}
Expand Down
Loading