Add the 13 SPL exception classes (RuntimeException, LogicException, …)#245
Merged
Conversation
The SPL exception hierarchy was undeclared — class_exists("RuntimeException")
returned false, so any framework or library code that throws or catches these
(extremely common) types died with "Call to undefined class".
Added all 13 as embedded PHP source in the PH7_BUILTIN_LIB macro (vm.c, after
ErrorException), following the existing `class X extends Error { }` template — no
C required. They use PHP's exact two-root hierarchy so catch / instanceof /
get_parent_class match PHP:
LogicException, RuntimeException extends Exception
BadFunctionCallException, DomainException, InvalidArgumentException,
LengthException, OutOfRangeException extends LogicException
BadMethodCallException extends BadFunctionCallException
OutOfBoundsException, OverflowException, RangeException, UnderflowException,
UnexpectedValueException extends RuntimeException
Each is an empty body inheriting Exception's constructor and
getMessage/getCode/getPrevious/... Declaration order places the two roots
before their subclasses so the compile-time parent resolution succeeds.
Declared-class count: 14 -> 27.
Byte-for-byte parity with PHP 8.5.7 (catch-by-base, instanceof chains,
get_parent_class, inherited ctor/getMessage/getCode all match). Regression:
lang/spl_exception_{class_exists,hierarchy,instanceof,catch_by_base}.phpt
(pass under both phl and real php). make test / test-compat green.
Coverage
Details: https://github.com/alganet/PHL/actions/runs/27577744001 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The SPL exception hierarchy was undeclared — class_exists("RuntimeException") returned false, so any framework or library code that throws or catches these (extremely common) types died with "Call to undefined class".
Added all 13 as embedded PHP source in the PH7_BUILTIN_LIB macro (vm.c, after ErrorException), following the existing
class X extends Error { }template — no C required. They use PHP's exact two-root hierarchy so catch / instanceof / get_parent_class match PHP:LogicException, RuntimeException extends Exception
BadFunctionCallException, DomainException, InvalidArgumentException,
LengthException, OutOfRangeException extends LogicException
BadMethodCallException extends BadFunctionCallException
OutOfBoundsException, OverflowException, RangeException, UnderflowException,
UnexpectedValueException extends RuntimeException
Each is an empty body inheriting Exception's constructor and getMessage/getCode/getPrevious/... Declaration order places the two roots before their subclasses so the compile-time parent resolution succeeds. Declared-class count: 14 -> 27.
Byte-for-byte parity with PHP 8.5.7 (catch-by-base, instanceof chains, get_parent_class, inherited ctor/getMessage/getCode all match). Regression: lang/spl_exception_{class_exists,hierarchy,instanceof,catch_by_base}.phpt (pass under both phl and real php). make test / test-compat green.