You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When opcache is enabled, error handling is altered in the following ways:
* Errors emitted during compilation bypass the user-defined error handler
* Exceptions emitted during class linking are turned into fatal errors
Changes here make the behavior consistent regardless of opcache being enabled or
not:
* Errors emitted during compilation and class linking are always delayed and
handled after compilation or class linking. During handling, user-defined
error handlers are not bypassed. Fatal errors emitted during compilation or
class linking cause any delayed errors to be handled immediately (without
calling user-defined error handlers, as it would be unsafe).
* Exceptions thrown by user-defined error handlers when handling class linking
error are not promoted to fatal errors anymore and do not prevent linking.
FixesGH-17422.
ClosesGH-18541.
ClosesGH-17627.
Co-authored-by: Tim Düsterhus <[email protected]>
Copy file name to clipboardExpand all lines: Zend/tests/inheritance/deprecation_to_exception_during_inheritance.phpt
+4-3Lines changed: 4 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
--TEST--
2
-
Deprecation promoted to exception should result in fatal error during inheritance
2
+
Deprecation promoted to exception during inheritance
3
3
--SKIPIF--
4
4
<?php
5
5
if (getenv('SKIP_PRELOAD')) die('skip Error handler not active during preloading');
@@ -17,7 +17,8 @@ $class = new class extends DateTime {
17
17
18
18
?>
19
19
--EXPECTF--
20
-
Fatal error: During inheritance of DateTime: Uncaught Exception: Return type of DateTime@anonymous::getTimezone() should either be compatible with DateTime::getTimezone(): DateTimeZone|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in %s:%d
20
+
Fatal error: Uncaught Exception: Return type of DateTime@anonymous::getTimezone() should either be compatible with DateTime::getTimezone(): DateTimeZone|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in %s:%d
21
21
Stack trace:
22
22
#0 %s(%d): {closure:%s:%d}(8192, 'Return type of ...', '%s', 8)
Deprecation promoted to exception during inheritance
3
+
--SKIPIF--
4
+
<?php
5
+
if (getenv('SKIP_PRELOAD')) die('skip Error handler not active during preloading');
6
+
?>
7
+
--FILE--
8
+
<?php
9
+
10
+
set_error_handler(function($code, $message) {
11
+
thrownewException($message);
12
+
});
13
+
14
+
try {
15
+
class C extends DateTime {
16
+
publicfunctiongetTimezone() {}
17
+
publicfunctiongetTimestamp() {}
18
+
};
19
+
} catch (Exception$e) {
20
+
printf("%s: %s\n", $e::class, $e->getMessage());
21
+
}
22
+
23
+
var_dump(newC());
24
+
25
+
?>
26
+
--EXPECTF--
27
+
Exception: Return type of C::getTimezone() should either be compatible with DateTime::getTimezone(): DateTimeZone|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Copy file name to clipboardExpand all lines: Zend/tests/inheritance/gh15907.phpt
+5-2Lines changed: 5 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -14,5 +14,8 @@ class C implements Serializable {
14
14
15
15
?>
16
16
--EXPECTF--
17
-
Fatal error: During inheritance of C, while implementing Serializable: Uncaught Exception: C implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s:%d
18
-
%a
17
+
Fatal error: Uncaught Exception: C implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s:%d
0 commit comments