From a4e4c05f27f95a68ce04e2e7c51d4c9f0eabce3c Mon Sep 17 00:00:00 2001 From: NickSdot Date: Sun, 20 Sep 2026 14:42:47 +0000 Subject: [PATCH] ext/reflection: applied fixers to improve test robustness --- ext/reflection/tests/002.phpt | 12 +-- ext/reflection/tests/004.phpt | 16 +-- ext/reflection/tests/007.phpt | 26 ++--- ext/reflection/tests/008.phpt | 42 ++++---- ext/reflection/tests/027.phpt | 6 +- ...eflectionClassConstant_getValue_typed.phpt | 12 +-- ...eflectionClassConstant_toString_error.phpt | 6 +- .../ReflectionClassConstant_unset_name.phpt | 12 +-- .../ReflectionClass_constructor_002.phpt | 42 ++++---- .../ReflectionClass_getConstant_typed.phpt | 6 +- .../tests/ReflectionClass_getMethod_001.phpt | 16 +-- .../tests/ReflectionClass_getMethod_002.phpt | 48 ++++----- .../ReflectionClass_getProperty_001.phpt | 42 ++++---- .../ReflectionClass_getProperty_002.phpt | 48 ++++----- .../ReflectionClass_getProperty_003.phpt | 22 ++--- .../ReflectionClass_getProperty_004.phpt | 26 ++--- ...ctionClass_getStaticPropertyValue_001.phpt | 12 +-- ...ctionClass_getStaticPropertyValue_002.phpt | 28 +++--- ...flectionClass_implementsInterface_001.phpt | 98 +++++++++---------- .../ReflectionClass_isSubclassOf_002.phpt | 30 +++--- .../ReflectionClass_newInstanceArgs_001.phpt | 22 ++--- ...onClass_newInstanceWithoutConstructor.phpt | 6 +- .../ReflectionClass_newInstance_001.phpt | 24 ++--- ...ctionClass_setStaticPropertyValue_001.phpt | 12 +-- ...ctionClass_setStaticPropertyValue_002.phpt | 36 +++---- ...ctionClass_setStaticPropertyValue_003.phpt | 8 +- .../tests/ReflectionClass_toString_004.phpt | 6 +- .../tests/ReflectionClass_toString_007.phpt | 6 +- .../tests/ReflectionConstant_inexistent.phpt | 4 +- ...lectionEnumBackedCase_getBackingValue.phpt | 12 +-- ...ionEnumBackedCase_getBackingValue_002.phpt | 6 +- .../ReflectionEnumUnitCase_construct.phpt | 18 ++-- .../tests/ReflectionEnum_construct.phpt | 18 ++-- .../tests/ReflectionEnum_getCase.phpt | 2 +- ...ReflectionExtension_constructor_error.phpt | 18 ++-- .../tests/ReflectionFiber_errors.phpt | 42 ++++---- .../ReflectionFunction_construct.001.phpt | 30 +++--- .../ReflectionFunction_isDisabled_basic.phpt | 6 +- .../tests/ReflectionGenerator_isClosed.phpt | 8 +- .../ReflectionGenerator_isClosed_002.phpt | 6 +- .../tests/ReflectionMethod_006.phpt | 12 +-- .../ReflectionMethod_constructor_error2.phpt | 30 +++--- ...ReflectionMethod_createFromMethodName.phpt | 6 +- .../ReflectionMethod_getClosure_error.phpt | 6 +- .../ReflectionMethod_invokeArgs_basic.phpt | 6 +- .../ReflectionMethod_invokeArgs_error2.phpt | 6 +- .../ReflectionMethod_invokeArgs_error3.phpt | 22 ++--- .../tests/ReflectionMethod_invoke_basic.phpt | 22 ++--- .../tests/ReflectionMethod_invoke_error1.phpt | 18 ++-- ...n_abstract_method_after_setAccessible.phpt | 6 +- .../ReflectionObject_isSubclassOf.002.phpt | 30 +++--- ...nParameter_DefaultValueConstant_error.phpt | 6 +- .../tests/ReflectionParameter_ctor_cast.phpt | 6 +- ...arameter_getClass_self_parent_closure.phpt | 18 ++-- ...flectionParameter_getDocComment_basic.phpt | 1 - ...nParameter_invalidMethodInConstructor.phpt | 12 +-- .../ReflectionProperty_constructor_error.phpt | 22 ++--- ...ectionProperty_constructor_variation1.phpt | 24 ++--- .../tests/ReflectionProperty_error.phpt | 18 ++-- ...ectionProperty_getMangledName_dynamic.phpt | 14 +-- ...flectionProperty_getMangledName_hooks.phpt | 4 +- ...onProperty_getMangledName_inheritance.phpt | 12 +-- ...ctionProperty_getMangledName_instance.phpt | 11 +-- .../ReflectionProperty_getValue_error.phpt | 20 ++-- .../ReflectionProperty_isInitialized.phpt | 12 +-- ...onProperty_lazy_initialization_errors.phpt | 27 +++-- .../ReflectionProperty_setValue_readonly.phpt | 6 +- .../ReflectionProperty_typed_static.phpt | 18 ++-- .../tests/ReflectionReference_errors.phpt | 36 +++---- .../tests/ReflectionZendExtension_error.phpt | 6 +- .../ReflectionAttribute_constructor_001.phpt | 6 +- ext/reflection/tests/bug38217.phpt | 4 +- ext/reflection/tests/bug41061.phpt | 1 - ext/reflection/tests/bug46064.phpt | 6 +- ext/reflection/tests/bug49719.phpt | 6 +- ext/reflection/tests/bug52854.phpt | 6 +- ext/reflection/tests/bug64007.phpt | 6 +- ext/reflection/tests/bug71018.phpt | 6 +- ext/reflection/tests/bug74454.phpt | 2 +- ext/reflection/tests/bug74949.phpt | 6 +- ext/reflection/tests/bug76737.phpt | 18 ++-- ext/reflection/tests/bug78697.phpt | 6 +- ext/reflection/tests/bug78895.phpt | 2 +- ext/reflection/tests/bug81208.phpt | 6 +- ...fault_value_internal_userland_arginfo.phpt | 6 +- ext/reflection/tests/gh12856.phpt | 6 +- ext/reflection/tests/gh21362.phpt | 36 +++---- ext/reflection/tests/gh8982.phpt | 8 +- ..._getDefaultValueConstantName_Internal.phpt | 16 +-- ...ionParameter_getDefaultValue_Internal.phpt | 12 +-- ...meter_isDefaultValueConstant_Internal.phpt | 12 +-- .../check_all.phpt | 4 +- ext/reflection/tests/parameters_001.phpt | 12 +-- ext/reflection/tests/parameters_002.phpt | 8 +- ext/reflection/tests/property_exists.phpt | 12 +-- .../ReflectionProperty_getSetRawValue.phpt | 12 +-- .../tests/property_hooks/basics.phpt | 4 +- .../tests/property_hooks/gh17713.phpt | 24 ++--- ext/reflection/tests/request38992.phpt | 12 +-- ...roperties_with_typed_class_constants1.phpt | 6 +- 100 files changed, 772 insertions(+), 776 deletions(-) diff --git a/ext/reflection/tests/002.phpt b/ext/reflection/tests/002.phpt index 5e35859c7cee..416dfdad435f 100644 --- a/ext/reflection/tests/002.phpt +++ b/ext/reflection/tests/002.phpt @@ -26,17 +26,17 @@ try { $r->class = 'bullshit'; } -catch(ReflectionException $e) +catch(Throwable $e) { - echo $e->getMessage() . "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } try { $r->name = 'bullshit'; } -catch(ReflectionException $e) +catch(Throwable $e) { - echo $e->getMessage() . "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } $r->foo = 'bar'; @@ -54,8 +54,8 @@ string(26) "ReflectionFunctionAbstract" string(7) "getName" string(3) "xyz" NULL -Cannot set read-only property ReflectionMethodEx::$class -Cannot set read-only property ReflectionMethodEx::$name +ReflectionException: Cannot set read-only property ReflectionMethodEx::$class +ReflectionException: Cannot set read-only property ReflectionMethodEx::$name string(26) "ReflectionFunctionAbstract" string(7) "getName" string(3) "bar" diff --git a/ext/reflection/tests/004.phpt b/ext/reflection/tests/004.phpt index 3739d2e55c94..25ec550fafc9 100644 --- a/ext/reflection/tests/004.phpt +++ b/ext/reflection/tests/004.phpt @@ -17,25 +17,25 @@ $m=$a->getMethod("__construct"); try { $m->invoke(null); -} catch (ReflectionException $E) { - echo $E->getMessage()."\n"; +} catch (Throwable $E) { + echo $E::class, ': ', $E->getMessage(), "\n"; } try { $m->invoke($b); -} catch (ReflectionException $E) { - echo $E->getMessage()."\n"; +} catch (Throwable $E) { + echo $E::class, ': ', $E->getMessage(), "\n"; } $b = new a(); try { $m->invoke($b); -} catch (ReflectionException $E) { - echo $E->getMessage()."\n"; +} catch (Throwable $E) { + echo $E::class, ': ', $E->getMessage(), "\n"; } ?> --EXPECT-- -Trying to invoke non static method a::__construct() without an object -Given object is not an instance of the class this method was declared in +ReflectionException: Trying to invoke non static method a::__construct() without an object +ReflectionException: Given object is not an instance of the class this method was declared in diff --git a/ext/reflection/tests/007.phpt b/ext/reflection/tests/007.phpt index 8e90f7a010a9..5cc5c3b7769b 100644 --- a/ext/reflection/tests/007.phpt +++ b/ext/reflection/tests/007.phpt @@ -10,9 +10,9 @@ function test($class) { $ref = new ReflectionClass($class); } - catch (ReflectionException $e) + catch (Throwable $e) { - var_dump($e->getMessage()); + echo $e::class, ': ', $e->getMessage(), "\n"; return; // only here } @@ -21,13 +21,13 @@ function test($class) { var_dump($ref->newInstance()); } - catch (ReflectionException $e) + catch (Throwable $e) { - var_dump($e->getMessage()); + echo $e::class, ': ', $e->getMessage(), "\n"; } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } echo "====>newInstance(25)\n"; @@ -35,9 +35,9 @@ function test($class) { var_dump($ref->newInstance(25)); } - catch (ReflectionException $e) + catch (Throwable $e) { - var_dump($e->getMessage()); + echo $e::class, ': ', $e->getMessage(), "\n"; } echo "====>newInstance(25, 42)\n"; @@ -45,9 +45,9 @@ function test($class) { var_dump($ref->newInstance(25, 42)); } - catch (ReflectionException $e) + catch (Throwable $e) { - var_dump($e->getMessage()); + echo $e::class, ': ', $e->getMessage(), "\n"; } echo "\n"; @@ -91,15 +91,15 @@ test('WithCtorWithArgs'); --EXPECTF-- ====>Class_does_not_exist {closure:%s:%d}(Class_does_not_exist) -string(43) "Class "Class_does_not_exist" does not exist" +ReflectionException: Class "Class_does_not_exist" does not exist ====>NoCtor ====>newInstance() object(NoCtor)#%d (0) { } ====>newInstance(25) -string(86) "Class NoCtor does not have a constructor, so you cannot pass any constructor arguments" +ReflectionException: Class NoCtor does not have a constructor, so you cannot pass any constructor arguments ====>newInstance(25, 42) -string(86) "Class NoCtor does not have a constructor, so you cannot pass any constructor arguments" +ReflectionException: Class NoCtor does not have a constructor, so you cannot pass any constructor arguments ====>WithCtor ====>newInstance() @@ -129,7 +129,7 @@ object(WithCtor)#%d (0) { ====>WithCtorWithArgs ====>newInstance() -Exception: Too few arguments to function WithCtorWithArgs::__construct(), 0 passed and exactly 1 expected +ArgumentCountError: Too few arguments to function WithCtorWithArgs::__construct(), 0 passed and exactly 1 expected ====>newInstance(25) WithCtorWithArgs::__construct(25) array(1) { diff --git a/ext/reflection/tests/008.phpt b/ext/reflection/tests/008.phpt index 64866bbe6993..e5590c26aecc 100644 --- a/ext/reflection/tests/008.phpt +++ b/ext/reflection/tests/008.phpt @@ -8,14 +8,14 @@ $a = array("", 1, "::", "a::", "::b", "a::b"); foreach ($a as $val) { try { new ReflectionMethod($val); - } catch (Exception $e) { - var_dump($e->getMessage()); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { ReflectionMethod::createFromMethodName($val); - } catch (Exception $e) { - var_dump($e->getMessage()); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } } @@ -25,8 +25,8 @@ $b = array("", "", 1); foreach ($a as $key=>$val) { try { new ReflectionMethod($val, $b[$key]); - } catch (Exception $e) { - var_dump($e->getMessage()); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } } @@ -34,29 +34,29 @@ echo "Done\n"; ?> --EXPECTF-- Deprecated: Calling ReflectionMethod::__construct() with 1 argument is deprecated, use ReflectionMethod::createFromMethodName() instead in %s on line %d -string(90) "ReflectionMethod::__construct(): Argument #1 ($objectOrMethod) must be a valid method name" -string(91) "ReflectionMethod::createFromMethodName(): Argument #1 ($method) must be a valid method name" +ReflectionException: ReflectionMethod::__construct(): Argument #1 ($objectOrMethod) must be a valid method name +ReflectionException: ReflectionMethod::createFromMethodName(): Argument #1 ($method) must be a valid method name Deprecated: Calling ReflectionMethod::__construct() with 1 argument is deprecated, use ReflectionMethod::createFromMethodName() instead in %s on line %d -string(90) "ReflectionMethod::__construct(): Argument #1 ($objectOrMethod) must be a valid method name" -string(91) "ReflectionMethod::createFromMethodName(): Argument #1 ($method) must be a valid method name" +ReflectionException: ReflectionMethod::__construct(): Argument #1 ($objectOrMethod) must be a valid method name +ReflectionException: ReflectionMethod::createFromMethodName(): Argument #1 ($method) must be a valid method name Deprecated: Calling ReflectionMethod::__construct() with 1 argument is deprecated, use ReflectionMethod::createFromMethodName() instead in %s on line %d -string(23) "Class "" does not exist" -string(23) "Class "" does not exist" +ReflectionException: Class "" does not exist +ReflectionException: Class "" does not exist Deprecated: Calling ReflectionMethod::__construct() with 1 argument is deprecated, use ReflectionMethod::createFromMethodName() instead in %s on line %d -string(24) "Class "a" does not exist" -string(24) "Class "a" does not exist" +ReflectionException: Class "a" does not exist +ReflectionException: Class "a" does not exist Deprecated: Calling ReflectionMethod::__construct() with 1 argument is deprecated, use ReflectionMethod::createFromMethodName() instead in %s on line %d -string(23) "Class "" does not exist" -string(23) "Class "" does not exist" +ReflectionException: Class "" does not exist +ReflectionException: Class "" does not exist Deprecated: Calling ReflectionMethod::__construct() with 1 argument is deprecated, use ReflectionMethod::createFromMethodName() instead in %s on line %d -string(24) "Class "a" does not exist" -string(24) "Class "a" does not exist" -string(23) "Class "" does not exist" -string(24) "Class "1" does not exist" -string(23) "Class "" does not exist" +ReflectionException: Class "a" does not exist +ReflectionException: Class "a" does not exist +ReflectionException: Class "" does not exist +ReflectionException: Class "1" does not exist +ReflectionException: Class "" does not exist Done diff --git a/ext/reflection/tests/027.phpt b/ext/reflection/tests/027.phpt index 40153791ad34..11c20f9d0057 100644 --- a/ext/reflection/tests/027.phpt +++ b/ext/reflection/tests/027.phpt @@ -14,9 +14,9 @@ $g->next(); try { $r->getTrace(); -} catch (ReflectionException $e) { - echo $e->getMessage(); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- -Cannot fetch information from a closed Generator +ReflectionException: Cannot fetch information from a closed Generator diff --git a/ext/reflection/tests/ReflectionClassConstant_getValue_typed.phpt b/ext/reflection/tests/ReflectionClassConstant_getValue_typed.phpt index f964f4c146fb..83b60f483a18 100644 --- a/ext/reflection/tests/ReflectionClassConstant_getValue_typed.phpt +++ b/ext/reflection/tests/ReflectionClassConstant_getValue_typed.phpt @@ -20,14 +20,14 @@ echo $rc; $rc = new ReflectionClassConstant(B::class, 'CONST1'); try { $rc->getValue(); -} catch (TypeError $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { echo $rc; -} catch (TypeError $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> @@ -35,5 +35,5 @@ try { object(stdClass)#1 (0) { } Constant [ public object CONST1 ] { Object } -Cannot assign stdClass to class constant B::CONST1 of type array -Cannot assign stdClass to class constant B::CONST1 of type array +TypeError: Cannot assign stdClass to class constant B::CONST1 of type array +TypeError: Cannot assign stdClass to class constant B::CONST1 of type array diff --git a/ext/reflection/tests/ReflectionClassConstant_toString_error.phpt b/ext/reflection/tests/ReflectionClassConstant_toString_error.phpt index 54290e97aa30..d2ff59c86f8e 100644 --- a/ext/reflection/tests/ReflectionClassConstant_toString_error.phpt +++ b/ext/reflection/tests/ReflectionClassConstant_toString_error.phpt @@ -9,10 +9,10 @@ class B { try { echo new ReflectionClassConstant('B', 'X'); -} catch (Error $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- -Undefined constant self::UNKNOWN +Error: Undefined constant self::UNKNOWN diff --git a/ext/reflection/tests/ReflectionClassConstant_unset_name.phpt b/ext/reflection/tests/ReflectionClassConstant_unset_name.phpt index a571f4a47766..b7b4be698787 100644 --- a/ext/reflection/tests/ReflectionClassConstant_unset_name.phpt +++ b/ext/reflection/tests/ReflectionClassConstant_unset_name.phpt @@ -13,16 +13,16 @@ $rc = new ReflectionClassConstant(Test::class, 'C'); unset($rc->name); try { var_dump($rc->getName()); -} catch (Error $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { echo $rc, "\n"; -} catch (Error $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- -Typed property ReflectionClassConstant::$name must not be accessed before initialization -Typed property ReflectionClassConstant::$name must not be accessed before initialization +Error: Typed property ReflectionClassConstant::$name must not be accessed before initialization +Error: Typed property ReflectionClassConstant::$name must not be accessed before initialization diff --git a/ext/reflection/tests/ReflectionClass_constructor_002.phpt b/ext/reflection/tests/ReflectionClass_constructor_002.phpt index adb378434737..580570450186 100644 --- a/ext/reflection/tests/ReflectionClass_constructor_002.phpt +++ b/ext/reflection/tests/ReflectionClass_constructor_002.phpt @@ -4,54 +4,54 @@ ReflectionClass::__constructor() - bad arguments getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump(new ReflectionClass(null)); -} catch (Exception $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump(new ReflectionClass(true)); -} catch (Exception $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump(new ReflectionClass(1)); -} catch (Exception $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump(new ReflectionClass(array(1,2,3))); -} catch (TypeError $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump(new ReflectionClass("stdClass", 1)); -} catch (TypeError $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump(new ReflectionClass("X")); -} catch (Exception $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECTF-- -ReflectionClass::__construct() expects exactly 1 argument, 0 given +ArgumentCountError: ReflectionClass::__construct() expects exactly 1 argument, 0 given Deprecated: ReflectionClass::__construct(): Passing null to parameter #1 ($objectOrClass) of type object|string is deprecated in %s on line %d -Class "" does not exist -Class "1" does not exist -Class "1" does not exist -ReflectionClass::__construct(): Argument #1 ($objectOrClass) must be of type object|string, array given -ReflectionClass::__construct() expects exactly 1 argument, 2 given -Class "X" does not exist +ReflectionException: Class "" does not exist +ReflectionException: Class "1" does not exist +ReflectionException: Class "1" does not exist +TypeError: ReflectionClass::__construct(): Argument #1 ($objectOrClass) must be of type object|string, array given +ArgumentCountError: ReflectionClass::__construct() expects exactly 1 argument, 2 given +ReflectionException: Class "X" does not exist diff --git a/ext/reflection/tests/ReflectionClass_getConstant_typed.phpt b/ext/reflection/tests/ReflectionClass_getConstant_typed.phpt index c63eaab5d902..92ea4cdae241 100644 --- a/ext/reflection/tests/ReflectionClass_getConstant_typed.phpt +++ b/ext/reflection/tests/ReflectionClass_getConstant_typed.phpt @@ -18,12 +18,12 @@ var_dump($rc->getConstant("CONST1")); $rc = new ReflectionClass(D::class); try { $rc->getConstant("CONST1"); -} catch (TypeError $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- object(stdClass)#1 (0) { } -Cannot assign stdClass to class constant D::CONST1 of type array +TypeError: Cannot assign stdClass to class constant D::CONST1 of type array diff --git a/ext/reflection/tests/ReflectionClass_getMethod_001.phpt b/ext/reflection/tests/ReflectionClass_getMethod_001.phpt index 4e89466af021..fc3a2f583472 100644 --- a/ext/reflection/tests/ReflectionClass_getMethod_001.phpt +++ b/ext/reflection/tests/ReflectionClass_getMethod_001.phpt @@ -40,8 +40,8 @@ foreach($classes as $class) { echo " --> Check for doesNotExist(): "; try { var_dump($rc->getMethod("doesNotExist")); - } catch (Exception $e) { - echo $e->getMessage() . "\n"; + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } } ?> @@ -65,7 +65,7 @@ Reflecting on class pubf: ["class"]=> string(4) "pubf" } - --> Check for doesNotExist(): Method pubf::doesNotExist() does not exist + --> Check for doesNotExist(): ReflectionException: Method pubf::doesNotExist() does not exist Reflecting on class subpubf: --> Check for f(): object(ReflectionMethod)#%d (2) { ["name"]=> @@ -85,7 +85,7 @@ Reflecting on class subpubf: ["class"]=> string(4) "pubf" } - --> Check for doesNotExist(): Method subpubf::doesNotExist() does not exist + --> Check for doesNotExist(): ReflectionException: Method subpubf::doesNotExist() does not exist Reflecting on class protf: --> Check for f(): object(ReflectionMethod)#%d (2) { ["name"]=> @@ -105,7 +105,7 @@ Reflecting on class protf: ["class"]=> string(5) "protf" } - --> Check for doesNotExist(): Method protf::doesNotExist() does not exist + --> Check for doesNotExist(): ReflectionException: Method protf::doesNotExist() does not exist Reflecting on class subprotf: --> Check for f(): object(ReflectionMethod)#%d (2) { ["name"]=> @@ -125,7 +125,7 @@ Reflecting on class subprotf: ["class"]=> string(5) "protf" } - --> Check for doesNotExist(): Method subprotf::doesNotExist() does not exist + --> Check for doesNotExist(): ReflectionException: Method subprotf::doesNotExist() does not exist Reflecting on class privf: --> Check for f(): object(ReflectionMethod)#%d (2) { ["name"]=> @@ -145,7 +145,7 @@ Reflecting on class privf: ["class"]=> string(5) "privf" } - --> Check for doesNotExist(): Method privf::doesNotExist() does not exist + --> Check for doesNotExist(): ReflectionException: Method privf::doesNotExist() does not exist Reflecting on class subprivf: --> Check for f(): object(ReflectionMethod)#%d (2) { ["name"]=> @@ -165,4 +165,4 @@ Reflecting on class subprivf: ["class"]=> string(5) "privf" } - --> Check for doesNotExist(): Method subprivf::doesNotExist() does not exist + --> Check for doesNotExist(): ReflectionException: Method subprivf::doesNotExist() does not exist diff --git a/ext/reflection/tests/ReflectionClass_getMethod_002.phpt b/ext/reflection/tests/ReflectionClass_getMethod_002.phpt index 9278b4787544..f48072d2c85d 100644 --- a/ext/reflection/tests/ReflectionClass_getMethod_002.phpt +++ b/ext/reflection/tests/ReflectionClass_getMethod_002.phpt @@ -13,56 +13,56 @@ $rc = new ReflectionClass("C"); echo "Check invalid params:\n"; try { var_dump($rc->getMethod()); -} catch (TypeError $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump($rc->getMethod("f", "f")); -} catch (TypeError $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump($rc->getMethod(null)); -} catch (Exception $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump($rc->getMethod(1)); -} catch (Exception $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump($rc->getMethod(1.5)); -} catch (Exception $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump($rc->getMethod(true)); -} catch (Exception $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump($rc->getMethod(array(1,2,3))); -} catch (TypeError $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump($rc->getMethod(new C)); -} catch (TypeError $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECTF-- Check invalid params: -ReflectionClass::getMethod() expects exactly 1 argument, 0 given -ReflectionClass::getMethod() expects exactly 1 argument, 2 given +ArgumentCountError: ReflectionClass::getMethod() expects exactly 1 argument, 0 given +ArgumentCountError: ReflectionClass::getMethod() expects exactly 1 argument, 2 given Deprecated: ReflectionClass::getMethod(): Passing null to parameter #1 ($name) of type string is deprecated in %s on line %d -Method C::() does not exist -Method C::1() does not exist -Method C::1.5() does not exist -Method C::1() does not exist -ReflectionClass::getMethod(): Argument #1 ($name) must be of type string, array given -ReflectionClass::getMethod(): Argument #1 ($name) must be of type string, C given +ReflectionException: Method C::() does not exist +ReflectionException: Method C::1() does not exist +ReflectionException: Method C::1.5() does not exist +ReflectionException: Method C::1() does not exist +TypeError: ReflectionClass::getMethod(): Argument #1 ($name) must be of type string, array given +TypeError: ReflectionClass::getMethod(): Argument #1 ($name) must be of type string, C given diff --git a/ext/reflection/tests/ReflectionClass_getProperty_001.phpt b/ext/reflection/tests/ReflectionClass_getProperty_001.phpt index e2e6e3ba3cbe..33df69a4332d 100644 --- a/ext/reflection/tests/ReflectionClass_getProperty_001.phpt +++ b/ext/reflection/tests/ReflectionClass_getProperty_001.phpt @@ -34,26 +34,26 @@ foreach($classes as $class) { try { echo " --> Check for s: "; var_dump($rc->getProperty("s")); - } catch (exception $e) { - echo $e->getMessage() . "\n"; + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { echo " --> Check for a: "; var_dump($rc->getProperty("a")); - } catch (exception $e) { - echo $e->getMessage() . "\n"; + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { echo " --> Check for A: "; var_dump($rc->getProperty("A")); - } catch (exception $e) { - echo $e->getMessage() . "\n"; + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { echo " --> Check for doesNotExist: "; var_dump($rc->getProperty("doesNotExist")); - } catch (exception $e) { - echo $e->getMessage() . "\n"; + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } } @@ -72,8 +72,8 @@ Reflecting on class pubf: ["class"]=> string(4) "pubf" } - --> Check for A: Property pubf::$A does not exist - --> Check for doesNotExist: Property pubf::$doesNotExist does not exist + --> Check for A: ReflectionException: Property pubf::$A does not exist + --> Check for doesNotExist: ReflectionException: Property pubf::$doesNotExist does not exist Reflecting on class subpubf: --> Check for s: object(ReflectionProperty)#%d (2) { ["name"]=> @@ -87,8 +87,8 @@ Reflecting on class subpubf: ["class"]=> string(4) "pubf" } - --> Check for A: Property subpubf::$A does not exist - --> Check for doesNotExist: Property subpubf::$doesNotExist does not exist + --> Check for A: ReflectionException: Property subpubf::$A does not exist + --> Check for doesNotExist: ReflectionException: Property subpubf::$doesNotExist does not exist Reflecting on class protf: --> Check for s: object(ReflectionProperty)#%d (2) { ["name"]=> @@ -102,8 +102,8 @@ Reflecting on class protf: ["class"]=> string(5) "protf" } - --> Check for A: Property protf::$A does not exist - --> Check for doesNotExist: Property protf::$doesNotExist does not exist + --> Check for A: ReflectionException: Property protf::$A does not exist + --> Check for doesNotExist: ReflectionException: Property protf::$doesNotExist does not exist Reflecting on class subprotf: --> Check for s: object(ReflectionProperty)#%d (2) { ["name"]=> @@ -117,8 +117,8 @@ Reflecting on class subprotf: ["class"]=> string(5) "protf" } - --> Check for A: Property subprotf::$A does not exist - --> Check for doesNotExist: Property subprotf::$doesNotExist does not exist + --> Check for A: ReflectionException: Property subprotf::$A does not exist + --> Check for doesNotExist: ReflectionException: Property subprotf::$doesNotExist does not exist Reflecting on class privf: --> Check for s: object(ReflectionProperty)#%d (2) { ["name"]=> @@ -132,8 +132,8 @@ Reflecting on class privf: ["class"]=> string(5) "privf" } - --> Check for A: Property privf::$A does not exist - --> Check for doesNotExist: Property privf::$doesNotExist does not exist + --> Check for A: ReflectionException: Property privf::$A does not exist + --> Check for doesNotExist: ReflectionException: Property privf::$doesNotExist does not exist Reflecting on class subprivf: --> Check for s: object(ReflectionProperty)#%d (2) { ["name"]=> @@ -141,6 +141,6 @@ Reflecting on class subprivf: ["class"]=> string(5) "privf" } - --> Check for a: Property subprivf::$a does not exist - --> Check for A: Property subprivf::$A does not exist - --> Check for doesNotExist: Property subprivf::$doesNotExist does not exist + --> Check for a: ReflectionException: Property subprivf::$a does not exist + --> Check for A: ReflectionException: Property subprivf::$A does not exist + --> Check for doesNotExist: ReflectionException: Property subprivf::$doesNotExist does not exist diff --git a/ext/reflection/tests/ReflectionClass_getProperty_002.phpt b/ext/reflection/tests/ReflectionClass_getProperty_002.phpt index c2f8419a1ea7..2034b628cf23 100644 --- a/ext/reflection/tests/ReflectionClass_getProperty_002.phpt +++ b/ext/reflection/tests/ReflectionClass_getProperty_002.phpt @@ -13,54 +13,54 @@ $rc = new ReflectionClass("C"); echo "Check invalid params:\n"; try { var_dump($rc->getProperty()); -} catch (TypeError $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump($rc->getProperty("a", "a")); -} catch (TypeError $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump($rc->getProperty(null)); -} catch (exception $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump($rc->getProperty(1)); -} catch (exception $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump($rc->getProperty(1.5)); -} catch (exception $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump($rc->getProperty(true)); -} catch (exception $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump($rc->getProperty(array(1,2,3))); -} catch (TypeError $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump($rc->getProperty(new C)); -} catch (TypeError $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECTF-- Check invalid params: -ReflectionClass::getProperty() expects exactly 1 argument, 0 given -ReflectionClass::getProperty() expects exactly 1 argument, 2 given +ArgumentCountError: ReflectionClass::getProperty() expects exactly 1 argument, 0 given +ArgumentCountError: ReflectionClass::getProperty() expects exactly 1 argument, 2 given Deprecated: ReflectionClass::getProperty(): Passing null to parameter #1 ($name) of type string is deprecated in %s on line %d -Property C::$ does not exist -Property C::$1 does not exist -Property C::$1.5 does not exist -Property C::$1 does not exist -ReflectionClass::getProperty(): Argument #1 ($name) must be of type string, array given -ReflectionClass::getProperty(): Argument #1 ($name) must be of type string, C given +ReflectionException: Property C::$ does not exist +ReflectionException: Property C::$1 does not exist +ReflectionException: Property C::$1.5 does not exist +ReflectionException: Property C::$1 does not exist +TypeError: ReflectionClass::getProperty(): Argument #1 ($name) must be of type string, array given +TypeError: ReflectionClass::getProperty(): Argument #1 ($name) must be of type string, C given diff --git a/ext/reflection/tests/ReflectionClass_getProperty_003.phpt b/ext/reflection/tests/ReflectionClass_getProperty_003.phpt index 8be2f4bf85b6..1b8e94807f8e 100644 --- a/ext/reflection/tests/ReflectionClass_getProperty_003.phpt +++ b/ext/reflection/tests/ReflectionClass_getProperty_003.phpt @@ -45,8 +45,8 @@ function showInfo($name) { echo "--- (Reflecting on $name) ---\n"; try { $rp = $rc->getProperty($name); - } catch (Exception $e) { - echo $e->getMessage() . "\n"; + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; return; } @@ -108,7 +108,7 @@ object(ReflectionProperty)#%d (2) { } string(10) "protA in A" --- (Reflecting on privA) --- -Property C::$privA does not exist +ReflectionException: Property C::$privA does not exist --- (Reflecting on pubB) --- object(ReflectionProperty)#%d (2) { ["name"]=> @@ -126,7 +126,7 @@ object(ReflectionProperty)#%d (2) { } string(10) "protB in B" --- (Reflecting on privB) --- -Property C::$privB does not exist +ReflectionException: Property C::$privB does not exist --- (Reflecting on pubC) --- object(ReflectionProperty)#%d (2) { ["name"]=> @@ -152,7 +152,7 @@ object(ReflectionProperty)#%d (2) { } string(10) "privC in C" --- (Reflecting on doesNotExist) --- -Property C::$doesNotExist does not exist +ReflectionException: Property C::$doesNotExist does not exist --- (Reflecting on A::pubC) --- object(ReflectionProperty)#%d (2) { ["name"]=> @@ -210,7 +210,7 @@ object(ReflectionProperty)#%d (2) { } string(9) "pubC in C" --- (Reflecting on c::PUBC) --- -Property C::$PUBC does not exist +ReflectionException: Property C::$PUBC does not exist --- (Reflecting on C::pubC) --- object(ReflectionProperty)#%d (2) { ["name"]=> @@ -236,12 +236,12 @@ object(ReflectionProperty)#%d (2) { } string(10) "privC in C" --- (Reflecting on X::pubC) --- -Fully qualified property name X::$pubC does not specify a base class of C +ReflectionException: Fully qualified property name X::$pubC does not specify a base class of C --- (Reflecting on X::protC) --- -Fully qualified property name X::$protC does not specify a base class of C +ReflectionException: Fully qualified property name X::$protC does not specify a base class of C --- (Reflecting on X::privC) --- -Fully qualified property name X::$privC does not specify a base class of C +ReflectionException: Fully qualified property name X::$privC does not specify a base class of C --- (Reflecting on X::doesNotExist) --- -Fully qualified property name X::$doesNotExist does not specify a base class of C +ReflectionException: Fully qualified property name X::$doesNotExist does not specify a base class of C --- (Reflecting on doesNotexist::doesNotExist) --- -Class "doesNotexist" does not exist +ReflectionException: Class "doesNotexist" does not exist diff --git a/ext/reflection/tests/ReflectionClass_getProperty_004.phpt b/ext/reflection/tests/ReflectionClass_getProperty_004.phpt index 6a4f44ee5977..f9809bb6c5ff 100644 --- a/ext/reflection/tests/ReflectionClass_getProperty_004.phpt +++ b/ext/reflection/tests/ReflectionClass_getProperty_004.phpt @@ -45,15 +45,15 @@ function showInfo($name) { echo "--- (Reflecting on $name) ---\n"; try { $rp = $rc->getProperty($name); - } catch (Exception $e) { - echo $e->getMessage() . "\n"; + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; return; } try { var_dump($rp); var_dump($rp->getValue($myC)); - } catch (Exception $e) { - echo $e->getMessage() . "\n"; + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; return; } } @@ -112,7 +112,7 @@ object(ReflectionProperty)#%d (2) { } string(10) "protA in A" --- (Reflecting on privA) --- -Property C::$privA does not exist +ReflectionException: Property C::$privA does not exist --- (Reflecting on pubB) --- object(ReflectionProperty)#%d (2) { ["name"]=> @@ -130,7 +130,7 @@ object(ReflectionProperty)#%d (2) { } string(10) "protB in B" --- (Reflecting on privB) --- -Property C::$privB does not exist +ReflectionException: Property C::$privB does not exist --- (Reflecting on pubC) --- object(ReflectionProperty)#%d (2) { ["name"]=> @@ -156,7 +156,7 @@ object(ReflectionProperty)#%d (2) { } string(10) "privC in C" --- (Reflecting on doesNotExist) --- -Property C::$doesNotExist does not exist +ReflectionException: Property C::$doesNotExist does not exist --- (Reflecting on A::pubC) --- object(ReflectionProperty)#%d (2) { ["name"]=> @@ -214,7 +214,7 @@ object(ReflectionProperty)#%d (2) { } string(9) "pubC in C" --- (Reflecting on c::PUBC) --- -Property C::$PUBC does not exist +ReflectionException: Property C::$PUBC does not exist --- (Reflecting on C::pubC) --- object(ReflectionProperty)#%d (2) { ["name"]=> @@ -240,12 +240,12 @@ object(ReflectionProperty)#%d (2) { } string(10) "privC in C" --- (Reflecting on X::pubC) --- -Fully qualified property name X::$pubC does not specify a base class of C +ReflectionException: Fully qualified property name X::$pubC does not specify a base class of C --- (Reflecting on X::protC) --- -Fully qualified property name X::$protC does not specify a base class of C +ReflectionException: Fully qualified property name X::$protC does not specify a base class of C --- (Reflecting on X::privC) --- -Fully qualified property name X::$privC does not specify a base class of C +ReflectionException: Fully qualified property name X::$privC does not specify a base class of C --- (Reflecting on X::doesNotExist) --- -Fully qualified property name X::$doesNotExist does not specify a base class of C +ReflectionException: Fully qualified property name X::$doesNotExist does not specify a base class of C --- (Reflecting on doesNotexist::doesNotExist) --- -Class "doesNotexist" does not exist +ReflectionException: Class "doesNotexist" does not exist diff --git a/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_001.phpt b/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_001.phpt index e4546bdb78fb..762fc333f2e8 100644 --- a/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_001.phpt +++ b/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_001.phpt @@ -35,15 +35,15 @@ echo "\nRetrieving non-existent values from A with no default value:\n"; try { var_dump($rcA->getStaticPropertyValue("protectedDoesNotExist")); echo "you should not see this"; -} catch (Exception $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump($rcA->getStaticPropertyValue("privateDoesNotExist")); echo "you should not see this"; -} catch (Exception $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> @@ -61,5 +61,5 @@ string(17) "changed protected" string(14) "changed public" Retrieving non-existent values from A with no default value: -Property A::$protectedDoesNotExist does not exist -Property A::$privateDoesNotExist does not exist +ReflectionException: Property A::$protectedDoesNotExist does not exist +ReflectionException: Property A::$privateDoesNotExist does not exist diff --git a/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_002.phpt b/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_002.phpt index 2b6fda059084..845bdd377a3c 100644 --- a/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_002.phpt +++ b/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_002.phpt @@ -12,37 +12,37 @@ class C { $rc = new ReflectionClass('C'); try { var_dump($rc->getStaticPropertyValue("x", "default value", 'blah')); -} catch (TypeError $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump($rc->getStaticPropertyValue()); -} catch (TypeError $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump($rc->getStaticPropertyValue(null)); -} catch (Exception $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump($rc->getStaticPropertyValue(1.5, 'def')); -} catch (Exception $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump($rc->getStaticPropertyValue(array(1,2,3))); -} catch (TypeError $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECTF-- -ReflectionClass::getStaticPropertyValue() expects at most 2 arguments, 3 given -ReflectionClass::getStaticPropertyValue() expects at least 1 argument, 0 given +ArgumentCountError: ReflectionClass::getStaticPropertyValue() expects at most 2 arguments, 3 given +ArgumentCountError: ReflectionClass::getStaticPropertyValue() expects at least 1 argument, 0 given Deprecated: ReflectionClass::getStaticPropertyValue(): Passing null to parameter #1 ($name) of type string is deprecated in %s on line %d -Property C::$ does not exist +ReflectionException: Property C::$ does not exist string(3) "def" -ReflectionClass::getStaticPropertyValue(): Argument #1 ($name) must be of type string, array given +TypeError: ReflectionClass::getStaticPropertyValue(): Argument #1 ($name) must be of type string, array given diff --git a/ext/reflection/tests/ReflectionClass_implementsInterface_001.phpt b/ext/reflection/tests/ReflectionClass_implementsInterface_001.phpt index 7af12f07b701..d011c569fde9 100644 --- a/ext/reflection/tests/ReflectionClass_implementsInterface_001.phpt +++ b/ext/reflection/tests/ReflectionClass_implementsInterface_001.phpt @@ -24,14 +24,14 @@ foreach ($rcs as $childName => $child) { echo " - Using object argument: "; try { var_dump($child->implementsInterface($parent)); - } catch (Exception|TypeError $e) { - echo $e->getMessage() . "\n"; + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } echo " - Using string argument: "; try { var_dump($child->implementsInterface($parentName)); - } catch (Exception|TypeError $e) { - echo $e->getMessage() . "\n"; + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } } } @@ -41,40 +41,40 @@ foreach ($rcs as $childName => $child) { echo "\n\nTest bad arguments:\n"; try { $rcs['A']->implementsInterface(); -} catch (ArgumentCountError $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { $rcs['A']->implementsInterface('C', 'C'); -} catch (ArgumentCountError $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { $rcs['A']->implementsInterface(null); -} catch (ReflectionException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { $rcs['A']->implementsInterface('ThisClassDoesNotExist'); -} catch (ReflectionException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { $rcs['A']->implementsInterface(2); -} catch (ReflectionException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECTF-- Does A implement A? - - Using object argument: A is not an interface - - Using string argument: A is not an interface + - Using object argument: ReflectionException: A is not an interface + - Using string argument: ReflectionException: A is not an interface Does A implement B? - - Using object argument: B is not an interface - - Using string argument: B is not an interface + - Using object argument: ReflectionException: B is not an interface + - Using string argument: ReflectionException: B is not an interface Does A implement C? - - Using object argument: C is not an interface - - Using string argument: C is not an interface + - Using object argument: ReflectionException: C is not an interface + - Using string argument: ReflectionException: C is not an interface Does A implement I1? - Using object argument: bool(true) - Using string argument: bool(true) @@ -82,14 +82,14 @@ Does A implement I2? - Using object argument: bool(false) - Using string argument: bool(false) Does B implement A? - - Using object argument: A is not an interface - - Using string argument: A is not an interface + - Using object argument: ReflectionException: A is not an interface + - Using string argument: ReflectionException: A is not an interface Does B implement B? - - Using object argument: B is not an interface - - Using string argument: B is not an interface + - Using object argument: ReflectionException: B is not an interface + - Using string argument: ReflectionException: B is not an interface Does B implement C? - - Using object argument: C is not an interface - - Using string argument: C is not an interface + - Using object argument: ReflectionException: C is not an interface + - Using string argument: ReflectionException: C is not an interface Does B implement I1? - Using object argument: bool(true) - Using string argument: bool(true) @@ -97,14 +97,14 @@ Does B implement I2? - Using object argument: bool(false) - Using string argument: bool(false) Does C implement A? - - Using object argument: A is not an interface - - Using string argument: A is not an interface + - Using object argument: ReflectionException: A is not an interface + - Using string argument: ReflectionException: A is not an interface Does C implement B? - - Using object argument: B is not an interface - - Using string argument: B is not an interface + - Using object argument: ReflectionException: B is not an interface + - Using string argument: ReflectionException: B is not an interface Does C implement C? - - Using object argument: C is not an interface - - Using string argument: C is not an interface + - Using object argument: ReflectionException: C is not an interface + - Using string argument: ReflectionException: C is not an interface Does C implement I1? - Using object argument: bool(true) - Using string argument: bool(true) @@ -112,14 +112,14 @@ Does C implement I2? - Using object argument: bool(true) - Using string argument: bool(true) Does I1 implement A? - - Using object argument: A is not an interface - - Using string argument: A is not an interface + - Using object argument: ReflectionException: A is not an interface + - Using string argument: ReflectionException: A is not an interface Does I1 implement B? - - Using object argument: B is not an interface - - Using string argument: B is not an interface + - Using object argument: ReflectionException: B is not an interface + - Using string argument: ReflectionException: B is not an interface Does I1 implement C? - - Using object argument: C is not an interface - - Using string argument: C is not an interface + - Using object argument: ReflectionException: C is not an interface + - Using string argument: ReflectionException: C is not an interface Does I1 implement I1? - Using object argument: bool(true) - Using string argument: bool(true) @@ -127,14 +127,14 @@ Does I1 implement I2? - Using object argument: bool(false) - Using string argument: bool(false) Does I2 implement A? - - Using object argument: A is not an interface - - Using string argument: A is not an interface + - Using object argument: ReflectionException: A is not an interface + - Using string argument: ReflectionException: A is not an interface Does I2 implement B? - - Using object argument: B is not an interface - - Using string argument: B is not an interface + - Using object argument: ReflectionException: B is not an interface + - Using string argument: ReflectionException: B is not an interface Does I2 implement C? - - Using object argument: C is not an interface - - Using string argument: C is not an interface + - Using object argument: ReflectionException: C is not an interface + - Using string argument: ReflectionException: C is not an interface Does I2 implement I1? - Using object argument: bool(true) - Using string argument: bool(true) @@ -144,10 +144,10 @@ Does I2 implement I2? Test bad arguments: -ReflectionClass::implementsInterface() expects exactly 1 argument, 0 given -ReflectionClass::implementsInterface() expects exactly 1 argument, 2 given +ArgumentCountError: ReflectionClass::implementsInterface() expects exactly 1 argument, 0 given +ArgumentCountError: ReflectionClass::implementsInterface() expects exactly 1 argument, 2 given Deprecated: ReflectionClass::implementsInterface(): Passing null to parameter #1 ($interface) of type ReflectionClass|string is deprecated in %s on line %d -Interface "" does not exist -Interface "ThisClassDoesNotExist" does not exist -Interface "2" does not exist +ReflectionException: Interface "" does not exist +ReflectionException: Interface "ThisClassDoesNotExist" does not exist +ReflectionException: Interface "2" does not exist diff --git a/ext/reflection/tests/ReflectionClass_isSubclassOf_002.phpt b/ext/reflection/tests/ReflectionClass_isSubclassOf_002.phpt index db3961b3e649..7d71b63b4dee 100644 --- a/ext/reflection/tests/ReflectionClass_isSubclassOf_002.phpt +++ b/ext/reflection/tests/ReflectionClass_isSubclassOf_002.phpt @@ -11,36 +11,36 @@ $rc = new ReflectionClass('A'); echo "\n\nTest bad arguments:\n"; try { $rc->isSubclassOf(); -} catch (ArgumentCountError $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { $rc->isSubclassOf('C', 'C'); -} catch (ArgumentCountError $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { $rc->isSubclassOf(null); -} catch (ReflectionException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { $rc->isSubclassOf('ThisClassDoesNotExist'); -} catch (ReflectionException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { $rc->isSubclassOf(2); -} catch (ReflectionException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECTF-- Test bad arguments: -ReflectionClass::isSubclassOf() expects exactly 1 argument, 0 given -ReflectionClass::isSubclassOf() expects exactly 1 argument, 2 given +ArgumentCountError: ReflectionClass::isSubclassOf() expects exactly 1 argument, 0 given +ArgumentCountError: ReflectionClass::isSubclassOf() expects exactly 1 argument, 2 given Deprecated: ReflectionClass::isSubclassOf(): Passing null to parameter #1 ($class) of type ReflectionClass|string is deprecated in %s on line %d -Class "" does not exist -Class "ThisClassDoesNotExist" does not exist -Class "2" does not exist +ReflectionException: Class "" does not exist +ReflectionException: Class "ThisClassDoesNotExist" does not exist +ReflectionException: Class "2" does not exist diff --git a/ext/reflection/tests/ReflectionClass_newInstanceArgs_001.phpt b/ext/reflection/tests/ReflectionClass_newInstanceArgs_001.phpt index 7dded54d3fae..df538ca1661b 100644 --- a/ext/reflection/tests/ReflectionClass_newInstanceArgs_001.phpt +++ b/ext/reflection/tests/ReflectionClass_newInstanceArgs_001.phpt @@ -35,7 +35,7 @@ $rcE = new ReflectionClass('E'); try { $rcB->newInstanceArgs(); } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } var_dump($rcB->newInstanceArgs(array('x', 123))); @@ -43,15 +43,15 @@ var_dump($rcB->newInstanceArgs(array('x', 123))); try { $rcC->newInstanceArgs(); echo "you should not see this\n"; -} catch (Exception $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { $rcD->newInstanceArgs(); echo "you should not see this\n"; -} catch (Exception $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } $e1 = $rcE->newInstanceArgs(); @@ -60,17 +60,17 @@ var_dump($e1); try { $e2 = $rcE->newInstanceArgs(array('x')); echo "you should not see this\n"; -} catch (Exception $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECTF-- -Exception: Too few arguments to function B::__construct(), 0 passed and exactly 2 expected +ArgumentCountError: Too few arguments to function B::__construct(), 0 passed and exactly 2 expected In constructor of class B with args x, 123 object(B)#%d (0) { } -Access to non-public constructor of class C -Access to non-public constructor of class D +ReflectionException: Access to non-public constructor of class C +ReflectionException: Access to non-public constructor of class D object(E)#%d (0) { } -Class E does not have a constructor, so you cannot pass any constructor arguments +ReflectionException: Class E does not have a constructor, so you cannot pass any constructor arguments diff --git a/ext/reflection/tests/ReflectionClass_newInstanceWithoutConstructor.phpt b/ext/reflection/tests/ReflectionClass_newInstanceWithoutConstructor.phpt index 59337f09e8b4..9116fad1b822 100644 --- a/ext/reflection/tests/ReflectionClass_newInstanceWithoutConstructor.phpt +++ b/ext/reflection/tests/ReflectionClass_newInstanceWithoutConstructor.phpt @@ -24,8 +24,8 @@ var_dump($class->newInstanceWithoutConstructor()); $class = new ReflectionClass('Generator'); try { var_dump($class->newInstanceWithoutConstructor()); -} catch (ReflectionException $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } final class Bar extends ArrayObject { @@ -42,7 +42,7 @@ object(stdClass)#%d (0) { } object(DateTime)#%d (0) { } -Class Generator is an internal class marked as final that cannot be instantiated without invoking its constructor +ReflectionException: Class Generator is an internal class marked as final that cannot be instantiated without invoking its constructor object(Bar)#%d (1) { ["storage":"ArrayObject":private]=> array(0) { diff --git a/ext/reflection/tests/ReflectionClass_newInstance_001.phpt b/ext/reflection/tests/ReflectionClass_newInstance_001.phpt index 22d06e328270..9233f1063baf 100644 --- a/ext/reflection/tests/ReflectionClass_newInstance_001.phpt +++ b/ext/reflection/tests/ReflectionClass_newInstance_001.phpt @@ -35,26 +35,26 @@ $rcE = new ReflectionClass('E'); try { var_dump($rcB->newInstance()); } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump($rcB->newInstance('x', 123)); } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } try { $rcC->newInstance(); echo "you should not see this\n"; -} catch (Exception $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { $rcD->newInstance(); echo "you should not see this\n"; -} catch (Exception $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } $e1 = $rcE->newInstance(); @@ -63,17 +63,17 @@ var_dump($e1); try { $e2 = $rcE->newInstance('x'); echo "you should not see this\n"; -} catch (Exception $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECTF-- -Exception: Too few arguments to function B::__construct(), 0 passed and exactly 2 expected +ArgumentCountError: Too few arguments to function B::__construct(), 0 passed and exactly 2 expected In constructor of class B with args x, 123 object(B)#%d (0) { } -Access to non-public constructor of class C -Access to non-public constructor of class D +ReflectionException: Access to non-public constructor of class C +ReflectionException: Access to non-public constructor of class D object(E)#%d (0) { } -Class E does not have a constructor, so you cannot pass any constructor arguments +ReflectionException: Class E does not have a constructor, so you cannot pass any constructor arguments diff --git a/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_001.phpt b/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_001.phpt index 512fb5d6d916..5e6793321d80 100644 --- a/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_001.phpt +++ b/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_001.phpt @@ -37,15 +37,15 @@ echo "\nSet non-existent values from A with no default value:\n"; try { var_dump($rcA->setStaticPropertyValue("protectedDoesNotExist", "new value 8")); echo "you should not see this"; -} catch (Exception $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump($rcA->setStaticPropertyValue("privateDoesNotExist", "new value 9")); echo "you should not see this"; -} catch (Exception $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> @@ -73,5 +73,5 @@ Array ) Set non-existent values from A with no default value: -Property A::$protectedDoesNotExist does not exist -Property A::$privateDoesNotExist does not exist +ReflectionException: Property A::$protectedDoesNotExist does not exist +ReflectionException: Property A::$privateDoesNotExist does not exist diff --git a/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_002.phpt b/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_002.phpt index 2822471a3971..1e810ea09e0d 100644 --- a/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_002.phpt +++ b/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_002.phpt @@ -12,43 +12,43 @@ class C { $rc = new ReflectionClass('C'); try { var_dump($rc->setStaticPropertyValue("x", "default value", 'blah')); -} catch (TypeError $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump($rc->setStaticPropertyValue()); -} catch (TypeError $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump($rc->setStaticPropertyValue(null)); -} catch (TypeError $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump($rc->setStaticPropertyValue(null,null)); -} catch (Exception $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump($rc->setStaticPropertyValue(1.5, 'def')); -} catch (Exception $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump($rc->setStaticPropertyValue(array(1,2,3), 'blah')); -} catch (TypeError $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECTF-- -ReflectionClass::setStaticPropertyValue() expects exactly 2 arguments, 3 given -ReflectionClass::setStaticPropertyValue() expects exactly 2 arguments, 0 given -ReflectionClass::setStaticPropertyValue() expects exactly 2 arguments, 1 given +ArgumentCountError: ReflectionClass::setStaticPropertyValue() expects exactly 2 arguments, 3 given +ArgumentCountError: ReflectionClass::setStaticPropertyValue() expects exactly 2 arguments, 0 given +ArgumentCountError: ReflectionClass::setStaticPropertyValue() expects exactly 2 arguments, 1 given Deprecated: ReflectionClass::setStaticPropertyValue(): Passing null to parameter #1 ($name) of type string is deprecated in %s on line %d -Property C::$ does not exist -Property C::$1.5 does not exist -ReflectionClass::setStaticPropertyValue(): Argument #1 ($name) must be of type string, array given +ReflectionException: Property C::$ does not exist +ReflectionException: Property C::$1.5 does not exist +TypeError: ReflectionClass::setStaticPropertyValue(): Argument #1 ($name) must be of type string, array given diff --git a/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_003.phpt b/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_003.phpt index 959cc1bea079..f59fdaa5cf40 100644 --- a/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_003.phpt +++ b/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_003.phpt @@ -12,7 +12,7 @@ $rc = new ReflectionClass('Test'); try { $rc->setStaticPropertyValue("y", "foo"); -} catch (TypeError $e) { echo $e->getMessage(), "\n"; } +} catch (Throwable $e) { echo $e::class, ': ', $e->getMessage(), "\n"; } var_dump(Test::$y); $rc->setStaticPropertyValue("y", "21"); @@ -23,7 +23,7 @@ Test::$x =& Test::$y; try { $rc->setStaticPropertyValue("x", "foo"); -} catch (TypeError $e) { echo $e->getMessage(), "\n"; } +} catch (Throwable $e) { echo $e::class, ': ', $e->getMessage(), "\n"; } var_dump(Test::$y); $rc->setStaticPropertyValue("x", "42"); @@ -31,9 +31,9 @@ var_dump(Test::$y); ?> --EXPECT-- -Cannot assign string to property Test::$y of type int +TypeError: Cannot assign string to property Test::$y of type int int(2) int(21) -Cannot assign string to reference held by property Test::$y of type int +TypeError: Cannot assign string to reference held by property Test::$y of type int int(21) int(42) diff --git a/ext/reflection/tests/ReflectionClass_toString_004.phpt b/ext/reflection/tests/ReflectionClass_toString_004.phpt index 0eecb3c8a346..a87564dfc6e3 100644 --- a/ext/reflection/tests/ReflectionClass_toString_004.phpt +++ b/ext/reflection/tests/ReflectionClass_toString_004.phpt @@ -8,10 +8,10 @@ class A { } try { echo new ReflectionClass(A::class); -} catch (Error $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- -Undefined constant self::UNKNOWN +Error: Undefined constant self::UNKNOWN diff --git a/ext/reflection/tests/ReflectionClass_toString_007.phpt b/ext/reflection/tests/ReflectionClass_toString_007.phpt index fd3ed8f32e35..ebd3803429a2 100644 --- a/ext/reflection/tests/ReflectionClass_toString_007.phpt +++ b/ext/reflection/tests/ReflectionClass_toString_007.phpt @@ -11,10 +11,10 @@ define("C", new stdClass()); try { (string) new ReflectionClass(Foo::class); -} catch (TypeError $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- -Cannot assign stdClass to class constant Foo::CONST1 of type array +TypeError: Cannot assign stdClass to class constant Foo::CONST1 of type array diff --git a/ext/reflection/tests/ReflectionConstant_inexistent.phpt b/ext/reflection/tests/ReflectionConstant_inexistent.phpt index 19d038ae12d0..48bf4ed0316f 100644 --- a/ext/reflection/tests/ReflectionConstant_inexistent.phpt +++ b/ext/reflection/tests/ReflectionConstant_inexistent.phpt @@ -5,8 +5,8 @@ ReflectionConstant on inexistent constant try { new \ReflectionConstant('C'); -} catch (Exception $e) { - echo get_class($e) . ': ' . $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> diff --git a/ext/reflection/tests/ReflectionEnumBackedCase_getBackingValue.phpt b/ext/reflection/tests/ReflectionEnumBackedCase_getBackingValue.phpt index f81241d73a9e..bfcbef821f91 100644 --- a/ext/reflection/tests/ReflectionEnumBackedCase_getBackingValue.phpt +++ b/ext/reflection/tests/ReflectionEnumBackedCase_getBackingValue.phpt @@ -17,14 +17,14 @@ enum StringEnum: string { try { var_dump(new ReflectionEnumBackedCase(Enum_::class, 'Foo')); -} catch (ReflectionException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump(new ReflectionEnumBackedCase([], 'Foo')); -} catch (Error $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } var_dump((new ReflectionEnumBackedCase(IntEnum::class, 'Foo'))->getBackingValue()); @@ -32,7 +32,7 @@ var_dump((new ReflectionEnumBackedCase(StringEnum::class, 'Foo'))->getBackingVal ?> --EXPECT-- -Enum case Enum_::Foo is not a backed case -ReflectionEnumBackedCase::__construct(): Argument #1 ($class) must be of type object|string, array given +ReflectionException: Enum case Enum_::Foo is not a backed case +TypeError: ReflectionEnumBackedCase::__construct(): Argument #1 ($class) must be of type object|string, array given int(0) string(3) "Foo" diff --git a/ext/reflection/tests/ReflectionEnumBackedCase_getBackingValue_002.phpt b/ext/reflection/tests/ReflectionEnumBackedCase_getBackingValue_002.phpt index 7a942e31ad17..87f2e3ea7cd6 100644 --- a/ext/reflection/tests/ReflectionEnumBackedCase_getBackingValue_002.phpt +++ b/ext/reflection/tests/ReflectionEnumBackedCase_getBackingValue_002.phpt @@ -7,9 +7,9 @@ enum Inm:int { } try { var_dump((new ReflectionEnumBackedCase(Inm::class,'Foo'))->getBackingValue()); -} catch (Error $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- -Undefined constant "y" +Error: Undefined constant "y" diff --git a/ext/reflection/tests/ReflectionEnumUnitCase_construct.phpt b/ext/reflection/tests/ReflectionEnumUnitCase_construct.phpt index 18ab0222eb5b..2ed76b77f9d0 100644 --- a/ext/reflection/tests/ReflectionEnumUnitCase_construct.phpt +++ b/ext/reflection/tests/ReflectionEnumUnitCase_construct.phpt @@ -15,20 +15,20 @@ var_dump($case->getModifiers()); try { new ReflectionEnumUnitCase(Foo::class, 'Baz'); -} catch (\Exception $e) { - echo $e->getMessage() . "\n"; +} catch (\Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { new ReflectionEnumUnitCase(Foo::class, 'Qux'); -} catch (\Exception $e) { - echo $e->getMessage() . "\n"; +} catch (\Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { new ReflectionEnumUnitCase([], 'Foo'); -} catch (Error $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> @@ -36,6 +36,6 @@ try { string(3) "Bar" bool(true) int(1) -Constant Foo::Baz is not a case -Constant Foo::Qux does not exist -ReflectionEnumUnitCase::__construct(): Argument #1 ($class) must be of type object|string, array given +ReflectionException: Constant Foo::Baz is not a case +ReflectionException: Constant Foo::Qux does not exist +TypeError: ReflectionEnumUnitCase::__construct(): Argument #1 ($class) must be of type object|string, array given diff --git a/ext/reflection/tests/ReflectionEnum_construct.phpt b/ext/reflection/tests/ReflectionEnum_construct.phpt index 4b4a0391052a..03dcbbf943a9 100644 --- a/ext/reflection/tests/ReflectionEnum_construct.phpt +++ b/ext/reflection/tests/ReflectionEnum_construct.phpt @@ -10,25 +10,25 @@ echo (new ReflectionEnum(Foo::class))->getName() . "\n"; try { new ReflectionEnum('Bar'); -} catch (\Exception $e) { - echo $e->getMessage() . "\n"; +} catch (\Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { new ReflectionEnum('Baz'); -} catch (\Exception $e) { - echo $e->getMessage() . "\n"; +} catch (\Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { new ReflectionEnum([]); -} catch (Error $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- Foo -Class "Bar" is not an enum -Class "Baz" does not exist -ReflectionEnum::__construct(): Argument #1 ($objectOrClass) must be of type object|string, array given +ReflectionException: Class "Bar" is not an enum +ReflectionException: Class "Baz" does not exist +TypeError: ReflectionEnum::__construct(): Argument #1 ($objectOrClass) must be of type object|string, array given diff --git a/ext/reflection/tests/ReflectionEnum_getCase.phpt b/ext/reflection/tests/ReflectionEnum_getCase.phpt index f2b53cf65792..c8b7c14b6def 100644 --- a/ext/reflection/tests/ReflectionEnum_getCase.phpt +++ b/ext/reflection/tests/ReflectionEnum_getCase.phpt @@ -18,7 +18,7 @@ function test(string $enumName, string $caseName) { $reflectionEnum = new ReflectionEnum($enumName); var_dump($reflectionEnum->getCase($caseName)); } catch (Throwable $e) { - echo get_class($e) . ': ' . $e->getMessage() . "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } } diff --git a/ext/reflection/tests/ReflectionExtension_constructor_error.phpt b/ext/reflection/tests/ReflectionExtension_constructor_error.phpt index f4241bcd9221..68fa2c8545fd 100644 --- a/ext/reflection/tests/ReflectionExtension_constructor_error.phpt +++ b/ext/reflection/tests/ReflectionExtension_constructor_error.phpt @@ -7,25 +7,25 @@ Leon Luijkx getMessage().PHP_EOL; +} catch (Throwable $re) { + echo $re::class, ': ', $re->getMessage(), "\n"; } try { $obj = new ReflectionExtension('foo', 'bar'); -} catch (TypeError $re) { - echo "Ok - ".$re->getMessage().PHP_EOL; +} catch (Throwable $re) { + echo $re::class, ': ', $re->getMessage(), "\n"; } try { $obj = new ReflectionExtension([]); -} catch (TypeError $re) { - echo "Ok - ".$re->getMessage().PHP_EOL; +} catch (Throwable $re) { + echo $re::class, ': ', $re->getMessage(), "\n"; } ?> --EXPECT-- -Ok - ReflectionExtension::__construct() expects exactly 1 argument, 0 given -Ok - ReflectionExtension::__construct() expects exactly 1 argument, 2 given -Ok - ReflectionExtension::__construct(): Argument #1 ($name) must be of type string, array given +ArgumentCountError: ReflectionExtension::__construct() expects exactly 1 argument, 0 given +ArgumentCountError: ReflectionExtension::__construct() expects exactly 1 argument, 2 given +TypeError: ReflectionExtension::__construct(): Argument #1 ($name) must be of type string, array given diff --git a/ext/reflection/tests/ReflectionFiber_errors.phpt b/ext/reflection/tests/ReflectionFiber_errors.phpt index 640cdcb3bc89..9fab5f875b20 100644 --- a/ext/reflection/tests/ReflectionFiber_errors.phpt +++ b/ext/reflection/tests/ReflectionFiber_errors.phpt @@ -11,20 +11,20 @@ $reflection = new ReflectionFiber($fiber); try { $reflection->getTrace(); -} catch (Error $error) { - echo $error->getMessage(), "\n"; +} catch (Throwable $error) { + echo $error::class, ': ', $error->getMessage(), "\n"; } try { $reflection->getExecutingFile(); -} catch (Error $error) { - echo $error->getMessage(), "\n"; +} catch (Throwable $error) { + echo $error::class, ': ', $error->getMessage(), "\n"; } try { $reflection->getExecutingLine(); -} catch (Error $error) { - echo $error->getMessage(), "\n"; +} catch (Throwable $error) { + echo $error::class, ': ', $error->getMessage(), "\n"; } $fiber->start(); @@ -36,36 +36,36 @@ $fiber->resume(); try { $reflection->getTrace(); -} catch (Error $error) { - echo $error->getMessage(), "\n"; +} catch (Throwable $error) { + echo $error::class, ': ', $error->getMessage(), "\n"; } try { $reflection->getExecutingFile(); -} catch (Error $error) { - echo $error->getMessage(), "\n"; +} catch (Throwable $error) { + echo $error::class, ': ', $error->getMessage(), "\n"; } try { $reflection->getExecutingLine(); -} catch (Error $error) { - echo $error->getMessage(), "\n"; +} catch (Throwable $error) { + echo $error::class, ': ', $error->getMessage(), "\n"; } try { $reflection->getCallable(); -} catch (Error $error) { - echo $error->getMessage(), "\n"; +} catch (Throwable $error) { + echo $error::class, ': ', $error->getMessage(), "\n"; } ?> --EXPECTF-- -Cannot fetch information from a fiber that has not been started or is terminated -Cannot fetch information from a fiber that has not been started or is terminated -Cannot fetch information from a fiber that has not been started or is terminated +Error: Cannot fetch information from a fiber that has not been started or is terminated +Error: Cannot fetch information from a fiber that has not been started or is terminated +Error: Cannot fetch information from a fiber that has not been started or is terminated string(%d) "%s%eReflectionFiber_errors.php" int(4) -Cannot fetch information from a fiber that has not been started or is terminated -Cannot fetch information from a fiber that has not been started or is terminated -Cannot fetch information from a fiber that has not been started or is terminated -Cannot fetch the callable from a fiber that has terminated +Error: Cannot fetch information from a fiber that has not been started or is terminated +Error: Cannot fetch information from a fiber that has not been started or is terminated +Error: Cannot fetch information from a fiber that has not been started or is terminated +Error: Cannot fetch the callable from a fiber that has terminated diff --git a/ext/reflection/tests/ReflectionFunction_construct.001.phpt b/ext/reflection/tests/ReflectionFunction_construct.001.phpt index f7020699d564..963a5c0882ee 100644 --- a/ext/reflection/tests/ReflectionFunction_construct.001.phpt +++ b/ext/reflection/tests/ReflectionFunction_construct.001.phpt @@ -9,34 +9,34 @@ Steve Seear try { $a = new ReflectionFunction(array(1, 2, 3)); echo "exception not thrown.".PHP_EOL; -} catch (TypeError $re) { - echo "Ok - ".$re->getMessage().PHP_EOL; +} catch (Throwable $re) { + echo $re::class, ': ', $re->getMessage(), "\n"; } try { $a = new ReflectionFunction('nonExistentFunction'); -} catch (ReflectionException $e) { - echo $e->getMessage().PHP_EOL; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { $a = new ReflectionFunction(); -} catch (TypeError $re) { - echo "Ok - ".$re->getMessage().PHP_EOL; +} catch (Throwable $re) { + echo $re::class, ': ', $re->getMessage(), "\n"; } try { $a = new ReflectionFunction(1, 2); -} catch (TypeError $re) { - echo "Ok - ".$re->getMessage().PHP_EOL; +} catch (Throwable $re) { + echo $re::class, ': ', $re->getMessage(), "\n"; } try { $a = new ReflectionFunction([]); -} catch (TypeError $re) { - echo "Ok - ".$re->getMessage().PHP_EOL; +} catch (Throwable $re) { + echo $re::class, ': ', $re->getMessage(), "\n"; } ?> --EXPECT-- -Ok - ReflectionFunction::__construct(): Argument #1 ($function) must be of type Closure|string, array given -Function nonExistentFunction() does not exist -Ok - ReflectionFunction::__construct() expects exactly 1 argument, 0 given -Ok - ReflectionFunction::__construct() expects exactly 1 argument, 2 given -Ok - ReflectionFunction::__construct(): Argument #1 ($function) must be of type Closure|string, array given +TypeError: ReflectionFunction::__construct(): Argument #1 ($function) must be of type Closure|string, array given +ReflectionException: Function nonExistentFunction() does not exist +ArgumentCountError: ReflectionFunction::__construct() expects exactly 1 argument, 0 given +ArgumentCountError: ReflectionFunction::__construct() expects exactly 1 argument, 2 given +TypeError: ReflectionFunction::__construct(): Argument #1 ($function) must be of type Closure|string, array given diff --git a/ext/reflection/tests/ReflectionFunction_isDisabled_basic.phpt b/ext/reflection/tests/ReflectionFunction_isDisabled_basic.phpt index 64f8612fd853..e6009b06cc43 100644 --- a/ext/reflection/tests/ReflectionFunction_isDisabled_basic.phpt +++ b/ext/reflection/tests/ReflectionFunction_isDisabled_basic.phpt @@ -10,15 +10,15 @@ disable_functions=is_file try { $rf = new ReflectionFunction('is_file'); var_dump($rf->isDisabled()); -} catch (ReflectionException $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } $rf = new ReflectionFunction('is_string'); var_dump($rf->isDisabled()); ?> --EXPECTF-- -Function is_file() does not exist +ReflectionException: Function is_file() does not exist Deprecated: Method ReflectionFunction::isDisabled() is deprecated since 8.0, as ReflectionFunction can no longer be constructed for disabled functions in %s on line %d bool(false) diff --git a/ext/reflection/tests/ReflectionGenerator_isClosed.phpt b/ext/reflection/tests/ReflectionGenerator_isClosed.phpt index 3fc893083ce9..443d0980ca8f 100644 --- a/ext/reflection/tests/ReflectionGenerator_isClosed.phpt +++ b/ext/reflection/tests/ReflectionGenerator_isClosed.phpt @@ -24,8 +24,8 @@ foreach ($gens as $gen) { var_dump($ref->isClosed()); try { var_dump($ref->getExecutingLine()); - } catch (\Exception $e) { - echo $e->getMessage(), PHP_EOL; + } catch (\Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } echo PHP_EOL; @@ -37,10 +37,10 @@ int(9) bool(false) int(9) bool(true) -Cannot fetch information from a closed Generator +ReflectionException: Cannot fetch information from a closed Generator int(3) bool(false) int(3) bool(true) -Cannot fetch information from a closed Generator +ReflectionException: Cannot fetch information from a closed Generator diff --git a/ext/reflection/tests/ReflectionGenerator_isClosed_002.phpt b/ext/reflection/tests/ReflectionGenerator_isClosed_002.phpt index 1676369c5038..cf16e1b1edc8 100644 --- a/ext/reflection/tests/ReflectionGenerator_isClosed_002.phpt +++ b/ext/reflection/tests/ReflectionGenerator_isClosed_002.phpt @@ -22,8 +22,8 @@ foreach ($gens as $gen) { var_dump($ref->isClosed()); try { var_dump($ref->getExecutingLine()); - } catch (\Exception $e) { - echo $e->getMessage(), PHP_EOL; + } catch (\Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } echo PHP_EOL; @@ -39,4 +39,4 @@ int(10) bool(false) bool(false) bool(true) -Cannot fetch information from a closed Generator +ReflectionException: Cannot fetch information from a closed Generator diff --git a/ext/reflection/tests/ReflectionMethod_006.phpt b/ext/reflection/tests/ReflectionMethod_006.phpt index 4f76e8c338f3..15c6466612a8 100644 --- a/ext/reflection/tests/ReflectionMethod_006.phpt +++ b/ext/reflection/tests/ReflectionMethod_006.phpt @@ -8,16 +8,16 @@ Steve Seear try { new ReflectionMethod(); -} catch (ArgumentCountError $re) { - echo "Ok - ".$re->getMessage().PHP_EOL; +} catch (Throwable $re) { + echo $re::class, ': ', $re->getMessage(), "\n"; } try { new ReflectionMethod('a', 'b', 'c'); -} catch (ArgumentCountError $re) { - echo "Ok - ".$re->getMessage().PHP_EOL; +} catch (Throwable $re) { + echo $re::class, ': ', $re->getMessage(), "\n"; } ?> --EXPECT-- -Ok - ReflectionMethod::__construct() expects at least 1 argument, 0 given -Ok - ReflectionMethod::__construct() expects at most 2 arguments, 3 given +ArgumentCountError: ReflectionMethod::__construct() expects at least 1 argument, 0 given +ArgumentCountError: ReflectionMethod::__construct() expects at most 2 arguments, 3 given diff --git a/ext/reflection/tests/ReflectionMethod_constructor_error2.phpt b/ext/reflection/tests/ReflectionMethod_constructor_error2.phpt index a7115893a5c8..71d3ee1d550b 100644 --- a/ext/reflection/tests/ReflectionMethod_constructor_error2.phpt +++ b/ext/reflection/tests/ReflectionMethod_constructor_error2.phpt @@ -16,46 +16,46 @@ class TestClass try { echo "Too few arguments:\n"; $methodInfo = new ReflectionMethod(); -} catch (ArgumentCountError $re) { - echo "Ok - ".$re->getMessage().PHP_EOL; +} catch (Throwable $re) { + echo $re::class, ': ', $re->getMessage(), "\n"; } try { echo "\nToo many arguments:\n"; $methodInfo = new ReflectionMethod("TestClass", "foo", true); -} catch (ArgumentCountError $re) { - echo "Ok - ".$re->getMessage().PHP_EOL; +} catch (Throwable $re) { + echo $re::class, ': ', $re->getMessage(), "\n"; } try { //invalid class $methodInfo = new ReflectionMethod("InvalidClassName", "foo"); -} catch (ReflectionException $re) { - echo "Ok - ".$re->getMessage().PHP_EOL; +} catch (Throwable $re) { + echo $re::class, ': ', $re->getMessage(), "\n"; } try { //invalid 1st param $methodInfo = new ReflectionMethod([], "foo"); -} catch (TypeError $re) { - echo "Ok - ".$re->getMessage().PHP_EOL; +} catch (Throwable $re) { + echo $re::class, ': ', $re->getMessage(), "\n"; } try{ //invalid 2nd param $methodInfo = new ReflectionMethod("TestClass", []); -} catch (TypeError $re) { - echo "Ok - ".$re->getMessage().PHP_EOL; +} catch (Throwable $re) { + echo $re::class, ': ', $re->getMessage(), "\n"; } ?> --EXPECT-- Too few arguments: -Ok - ReflectionMethod::__construct() expects at least 1 argument, 0 given +ArgumentCountError: ReflectionMethod::__construct() expects at least 1 argument, 0 given Too many arguments: -Ok - ReflectionMethod::__construct() expects at most 2 arguments, 3 given -Ok - Class "InvalidClassName" does not exist -Ok - ReflectionMethod::__construct(): Argument #1 ($objectOrMethod) must be of type object|string, array given -Ok - ReflectionMethod::__construct(): Argument #2 ($method) must be of type ?string, array given +ArgumentCountError: ReflectionMethod::__construct() expects at most 2 arguments, 3 given +ReflectionException: Class "InvalidClassName" does not exist +TypeError: ReflectionMethod::__construct(): Argument #1 ($objectOrMethod) must be of type object|string, array given +TypeError: ReflectionMethod::__construct(): Argument #2 ($method) must be of type ?string, array given diff --git a/ext/reflection/tests/ReflectionMethod_createFromMethodName.phpt b/ext/reflection/tests/ReflectionMethod_createFromMethodName.phpt index fb7de1400159..f8bc992a2e2a 100644 --- a/ext/reflection/tests/ReflectionMethod_createFromMethodName.phpt +++ b/ext/reflection/tests/ReflectionMethod_createFromMethodName.phpt @@ -15,8 +15,8 @@ var_dump($m); try { $m = MyReflectionMethod::createFromMethodName("Foo::baz"); -} catch (Exception $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> @@ -27,4 +27,4 @@ object(MyReflectionMethod)#%d (%d) { ["class"]=> string(3) "Foo" } -Method Foo::baz() does not exist +ReflectionException: Method Foo::baz() does not exist diff --git a/ext/reflection/tests/ReflectionMethod_getClosure_error.phpt b/ext/reflection/tests/ReflectionMethod_getClosure_error.phpt index 0dc24897a345..f00efd924a30 100644 --- a/ext/reflection/tests/ReflectionMethod_getClosure_error.phpt +++ b/ext/reflection/tests/ReflectionMethod_getClosure_error.phpt @@ -32,8 +32,8 @@ $fakeobj = new StdClass(); echo "\n-- Testing ReflectionMethod::getClosure() function with invalid object --\n"; try { var_dump( $method->getClosure( $fakeobj ) ); -} catch( Exception $e ) { - var_dump( $e->getMessage() ); +} catch( Throwable $e ) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> @@ -41,4 +41,4 @@ try { *** Testing ReflectionMethod::getClosure() : error conditions *** -- Testing ReflectionMethod::getClosure() function with invalid object -- -string(72) "Given object is not an instance of the class this method was declared in" +ReflectionException: Given object is not an instance of the class this method was declared in diff --git a/ext/reflection/tests/ReflectionMethod_invokeArgs_basic.phpt b/ext/reflection/tests/ReflectionMethod_invokeArgs_basic.phpt index bea2314b04f6..b436e205b443 100644 --- a/ext/reflection/tests/ReflectionMethod_invokeArgs_basic.phpt +++ b/ext/reflection/tests/ReflectionMethod_invokeArgs_basic.phpt @@ -43,8 +43,8 @@ var_dump($methodWithArgs->invokeArgs($testClassInstance, array(1, "arg2", 3))); echo "\nMethod that throws an exception:\n"; try { $methodThatThrows->invokeArgs($testClassInstance, array()); -} catch (Exception $e) { - var_dump($e->getMessage()); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> @@ -70,4 +70,4 @@ Called methodWithArgs(1, arg2) NULL Method that throws an exception: -string(18) "Called willThrow()" +Exception: Called willThrow() diff --git a/ext/reflection/tests/ReflectionMethod_invokeArgs_error2.phpt b/ext/reflection/tests/ReflectionMethod_invokeArgs_error2.phpt index 791bfe3f4358..d62f95500eaa 100644 --- a/ext/reflection/tests/ReflectionMethod_invokeArgs_error2.phpt +++ b/ext/reflection/tests/ReflectionMethod_invokeArgs_error2.phpt @@ -18,10 +18,10 @@ $testClassInstance = new TestClass(); try { var_dump($foo->invokeArgs($testClassInstance, true)); -} catch (Error $e) { - var_dump($e->getMessage()); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- -string(85) "ReflectionMethod::invokeArgs(): Argument #2 ($args) must be of type array, true given" +TypeError: ReflectionMethod::invokeArgs(): Argument #2 ($args) must be of type array, true given diff --git a/ext/reflection/tests/ReflectionMethod_invokeArgs_error3.phpt b/ext/reflection/tests/ReflectionMethod_invokeArgs_error3.phpt index 57f4702e07c0..968d0ac81cd6 100644 --- a/ext/reflection/tests/ReflectionMethod_invokeArgs_error3.phpt +++ b/ext/reflection/tests/ReflectionMethod_invokeArgs_error3.phpt @@ -17,7 +17,7 @@ class TestClass { try { var_dump($this); } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } } @@ -40,8 +40,8 @@ $privateMethod = new ReflectionMethod("TestClass", "privateMethod"); echo "\nNon-instance:\n"; try { var_dump($foo->invokeArgs(new stdClass(), array())); -} catch (ReflectionException $e) { - var_dump($e->getMessage()); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } echo "\nStatic method:\n"; @@ -55,23 +55,23 @@ echo "\nAbstract method:\n"; $abstractMethod = new ReflectionMethod("AbstractClass", "foo"); try { $abstractMethod->invokeArgs($testClassInstance, array()); -} catch (ReflectionException $e) { - var_dump($e->getMessage()); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { $abstractMethod->invokeArgs(true); -} catch (ReflectionException $e) { - var_dump($e->getMessage()); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECTF-- Non-instance: -string(72) "Given object is not an instance of the class this method was declared in" +ReflectionException: Given object is not an instance of the class this method was declared in Static method: Called staticMethod() -Exception: Using $this when not in object context +Error: Using $this when not in object context NULL Private method: @@ -81,5 +81,5 @@ Called privateMethod() NULL Abstract method: -string(53) "Trying to invoke abstract method AbstractClass::foo()" -string(53) "Trying to invoke abstract method AbstractClass::foo()" +ReflectionException: Trying to invoke abstract method AbstractClass::foo() +ReflectionException: Trying to invoke abstract method AbstractClass::foo() diff --git a/ext/reflection/tests/ReflectionMethod_invoke_basic.phpt b/ext/reflection/tests/ReflectionMethod_invoke_basic.phpt index 2d35451fa94e..fcfa0c323d90 100644 --- a/ext/reflection/tests/ReflectionMethod_invoke_basic.phpt +++ b/ext/reflection/tests/ReflectionMethod_invoke_basic.phpt @@ -25,7 +25,7 @@ class TestClass { try { var_dump($this); } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } } @@ -62,21 +62,21 @@ echo "\nStatic method:\n"; try { var_dump($staticMethod->invoke()); -} catch (TypeError $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump($staticMethod->invoke(true)); -} catch (TypeError $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } var_dump($staticMethod->invoke(new stdClass())); echo "\nMethod that throws an exception:\n"; try { var_dump($methodThatThrows->invoke($testClassInstance)); -} catch (Exception $exc) { - var_dump($exc->getMessage()); +} catch (Throwable $exc) { + echo $exc::class, ': ', $exc->getMessage(), "\n"; } ?> @@ -102,13 +102,13 @@ Called methodWithArgs(1, arg2) NULL Static method: -ReflectionMethod::invoke() expects at least 1 argument, 0 given -ReflectionMethod::invoke(): Argument #1 ($object) must be of type ?object, true given +ArgumentCountError: ReflectionMethod::invoke() expects at least 1 argument, 0 given +TypeError: ReflectionMethod::invoke(): Argument #1 ($object) must be of type ?object, true given Deprecated: Calling ReflectionMethod::invoke() for static method TestClass::staticMethod() does not need an object parameter in %s on line %d Called staticMethod() -Exception: Using $this when not in object context +Error: Using $this when not in object context NULL Method that throws an exception: -string(18) "Called willThrow()" +Exception: Called willThrow() diff --git a/ext/reflection/tests/ReflectionMethod_invoke_error1.phpt b/ext/reflection/tests/ReflectionMethod_invoke_error1.phpt index dd86baa91040..2527b325b1f3 100644 --- a/ext/reflection/tests/ReflectionMethod_invoke_error1.phpt +++ b/ext/reflection/tests/ReflectionMethod_invoke_error1.phpt @@ -30,15 +30,15 @@ $testClassInstance->prop = "Hello"; echo "invoke() on a non-object:\n"; try { var_dump($foo->invoke(true)); -} catch (TypeError $e) { - var_dump($e->getMessage()); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } echo "\ninvoke() on a non-instance:\n"; try { var_dump($foo->invoke(new stdClass())); -} catch (ReflectionException $e) { - var_dump($e->getMessage()); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } echo "\nPrivate method:\n"; @@ -48,17 +48,17 @@ echo "\nAbstract method:\n"; $abstractMethod = ReflectionMethod::createFromMethodName("AbstractClass::foo"); try { $abstractMethod->invoke(true); -} catch (ReflectionException $e) { - var_dump($e->getMessage()); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECTF-- invoke() on a non-object: -string(85) "ReflectionMethod::invoke(): Argument #1 ($object) must be of type ?object, true given" +TypeError: ReflectionMethod::invoke(): Argument #1 ($object) must be of type ?object, true given invoke() on a non-instance: -string(72) "Given object is not an instance of the class this method was declared in" +ReflectionException: Given object is not an instance of the class this method was declared in Private method: @@ -67,4 +67,4 @@ Called privateMethod() NULL Abstract method: -string(53) "Trying to invoke abstract method AbstractClass::foo()" +ReflectionException: Trying to invoke abstract method AbstractClass::foo() diff --git a/ext/reflection/tests/ReflectionMethod_invoke_on_abstract_method_after_setAccessible.phpt b/ext/reflection/tests/ReflectionMethod_invoke_on_abstract_method_after_setAccessible.phpt index 67f6fe5dca42..0d329891355c 100644 --- a/ext/reflection/tests/ReflectionMethod_invoke_on_abstract_method_after_setAccessible.phpt +++ b/ext/reflection/tests/ReflectionMethod_invoke_on_abstract_method_after_setAccessible.phpt @@ -10,10 +10,10 @@ abstract class Test { $rm = new ReflectionMethod('Test', 'foo'); try { var_dump($rm->invoke(null)); -} catch (ReflectionException $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- -Trying to invoke abstract method Test::foo() +ReflectionException: Trying to invoke abstract method Test::foo() diff --git a/ext/reflection/tests/ReflectionObject_isSubclassOf.002.phpt b/ext/reflection/tests/ReflectionObject_isSubclassOf.002.phpt index 03a4cfcc2250..f5648c1ba028 100644 --- a/ext/reflection/tests/ReflectionObject_isSubclassOf.002.phpt +++ b/ext/reflection/tests/ReflectionObject_isSubclassOf.002.phpt @@ -11,36 +11,36 @@ $ro = new ReflectionObject(new C); echo "\n\nTest bad arguments:\n"; try { $ro->isSubclassOf(); -} catch (ArgumentCountError $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { $ro->isSubclassOf('C', 'C'); -} catch (ArgumentCountError $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { $ro->isSubclassOf(null); -} catch (ReflectionException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { $ro->isSubclassOf('ThisClassDoesNotExist'); -} catch (ReflectionException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { $ro->isSubclassOf(2); -} catch (ReflectionException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECTF-- Test bad arguments: -ReflectionClass::isSubclassOf() expects exactly 1 argument, 0 given -ReflectionClass::isSubclassOf() expects exactly 1 argument, 2 given +ArgumentCountError: ReflectionClass::isSubclassOf() expects exactly 1 argument, 0 given +ArgumentCountError: ReflectionClass::isSubclassOf() expects exactly 1 argument, 2 given Deprecated: ReflectionClass::isSubclassOf(): Passing null to parameter #1 ($class) of type ReflectionClass|string is deprecated in %s on line %d -Class "" does not exist -Class "ThisClassDoesNotExist" does not exist -Class "2" does not exist +ReflectionException: Class "" does not exist +ReflectionException: Class "ThisClassDoesNotExist" does not exist +ReflectionException: Class "2" does not exist diff --git a/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_error.phpt b/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_error.phpt index 95551524047e..c51266bcb16a 100644 --- a/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_error.phpt +++ b/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_error.phpt @@ -12,11 +12,11 @@ $reflect = new ReflectionFunction('ReflectionParameterTest'); foreach($reflect->getParameters() as $param) { try { echo $param->getDefaultValueConstantName() . "\n"; - } catch(ReflectionException $e) { - echo $e->getMessage() . "\n"; + } catch(Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } } ?> --EXPECT-- -Internal error: Failed to retrieve the default value +ReflectionException: Internal error: Failed to retrieve the default value CONST_TEST_1 diff --git a/ext/reflection/tests/ReflectionParameter_ctor_cast.phpt b/ext/reflection/tests/ReflectionParameter_ctor_cast.phpt index 10f45647e6cb..dfa70e0497b6 100644 --- a/ext/reflection/tests/ReflectionParameter_ctor_cast.phpt +++ b/ext/reflection/tests/ReflectionParameter_ctor_cast.phpt @@ -9,10 +9,10 @@ try { A::class, new class { public function __toString() { return 'method'; } } ], 'param'); -} catch (ReflectionException $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- -Method A::method() does not exist +ReflectionException: Method A::method() does not exist diff --git a/ext/reflection/tests/ReflectionParameter_getClass_self_parent_closure.phpt b/ext/reflection/tests/ReflectionParameter_getClass_self_parent_closure.phpt index 59599e468b66..3e18f26ca292 100644 --- a/ext/reflection/tests/ReflectionParameter_getClass_self_parent_closure.phpt +++ b/ext/reflection/tests/ReflectionParameter_getClass_self_parent_closure.phpt @@ -6,32 +6,32 @@ Using invalid self/parent types in closure $fn1 = function(self $x) {}; try { (new ReflectionFunction($fn1))->getParameters()[0]->getClass(); -} catch (ReflectionException $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } $fn2 = function(parent $x) {}; try { (new ReflectionFunction($fn2))->getParameters()[0]->getClass(); -} catch (ReflectionException $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } class Test {} $fn3 = (function(parent $x) {})->bindTo(new Test, Test::class); try { (new ReflectionFunction($fn3))->getParameters()[0]->getClass(); -} catch (ReflectionException $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECTF-- Deprecated: Method ReflectionParameter::getClass() is deprecated since 8.0, use ReflectionParameter::getType() instead in %s on line %d -Parameter uses "self" as type but function is not a class member +ReflectionException: Parameter uses "self" as type but function is not a class member Deprecated: Method ReflectionParameter::getClass() is deprecated since 8.0, use ReflectionParameter::getType() instead in %s on line %d -Parameter uses "parent" as type but function is not a class member +ReflectionException: Parameter uses "parent" as type but function is not a class member Deprecated: Method ReflectionParameter::getClass() is deprecated since 8.0, use ReflectionParameter::getType() instead in %s on line %d -Parameter uses "parent" as type although class does not have a parent +ReflectionException: Parameter uses "parent" as type although class does not have a parent diff --git a/ext/reflection/tests/ReflectionParameter_getDocComment_basic.phpt b/ext/reflection/tests/ReflectionParameter_getDocComment_basic.phpt index 46e47bf60324..73395c145c4a 100644 --- a/ext/reflection/tests/ReflectionParameter_getDocComment_basic.phpt +++ b/ext/reflection/tests/ReflectionParameter_getDocComment_basic.phpt @@ -245,4 +245,3 @@ string(%d) "/** Doc comment for $h after parameter */" ---> Doc comment for property hook parameter $value: string(%d) "/** Doc Comment for property hook parameter $value */" - diff --git a/ext/reflection/tests/ReflectionParameter_invalidMethodInConstructor.phpt b/ext/reflection/tests/ReflectionParameter_invalidMethodInConstructor.phpt index aa88c45449e7..d60a35c5c2a6 100644 --- a/ext/reflection/tests/ReflectionParameter_invalidMethodInConstructor.phpt +++ b/ext/reflection/tests/ReflectionParameter_invalidMethodInConstructor.phpt @@ -6,17 +6,17 @@ ReflectionParameter::__construct(): Invalid method as constructor // Invalid class name try { new ReflectionParameter (array ('A', 'b'), 0); -} catch (ReflectionException $e) { echo $e->getMessage()."\n"; } +} catch (Throwable $e) { echo $e::class, ': ', $e->getMessage(), "\n"; } // Invalid class method try { new ReflectionParameter (array ('C', 'b'), 0); -} catch (ReflectionException $e) { echo $e->getMessage ()."\n"; } +} catch (Throwable $e) { echo $e::class, ': ', $e->getMessage(), "\n"; } // Invalid object method try { new ReflectionParameter (array (new C, 'b'), 0); -} catch (ReflectionException $e) { echo $e->getMessage ()."\n"; } +} catch (Throwable $e) { echo $e::class, ': ', $e->getMessage(), "\n"; } class C { @@ -40,9 +40,9 @@ echo "Done.\n"; ?> --EXPECT-- -Class "A" does not exist -Method C::b() does not exist -Method C::b() does not exist +ReflectionException: Class "A" does not exist +ReflectionException: Method C::b() does not exist +ReflectionException: Method C::b() does not exist Ok - ReflectionParameter::__construct() expects exactly 2 arguments, 1 given Ok - ReflectionParameter::__construct(): Argument #1 ($function) must be a string, an array(class, method), or a callable object, int given Done. diff --git a/ext/reflection/tests/ReflectionProperty_constructor_error.phpt b/ext/reflection/tests/ReflectionProperty_constructor_error.phpt index e7a850dd9777..f97f3db63af6 100644 --- a/ext/reflection/tests/ReflectionProperty_constructor_error.phpt +++ b/ext/reflection/tests/ReflectionProperty_constructor_error.phpt @@ -11,33 +11,33 @@ $a = 5; echo "Non-existent class:\n"; try { new ReflectionProperty("NonExistentClass", "prop"); -} catch (ReflectionException $e) { - echo $e->getMessage(); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } -echo "\n\nWrong property parameter type:\n"; +echo "\nWrong property parameter type:\n"; try { new ReflectionProperty($a, 'TestClass'); } -catch(ReflectionException $e) { - echo $e->getMessage(); +catch(Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } -echo "\n\nNon-existent property:\n"; +echo "\nNon-existent property:\n"; try { new ReflectionProperty('TestClass', "nonExistentProperty"); } -catch(ReflectionException $e) { - echo $e->getMessage(); +catch(Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- Non-existent class: -Class "NonExistentClass" does not exist +ReflectionException: Class "NonExistentClass" does not exist Wrong property parameter type: -Class "5" does not exist +ReflectionException: Class "5" does not exist Non-existent property: -Property TestClass::$nonExistentProperty does not exist +ReflectionException: Property TestClass::$nonExistentProperty does not exist diff --git a/ext/reflection/tests/ReflectionProperty_constructor_variation1.phpt b/ext/reflection/tests/ReflectionProperty_constructor_variation1.phpt index 4456960dc7eb..bf5be6398023 100644 --- a/ext/reflection/tests/ReflectionProperty_constructor_variation1.phpt +++ b/ext/reflection/tests/ReflectionProperty_constructor_variation1.phpt @@ -10,8 +10,8 @@ class C { try { $rp = new ReflectionProperty("D", "p"); var_dump($rp); - } catch (Exception $e) { - echo $e->getMessage(); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } } } @@ -21,8 +21,8 @@ class D extends C{ try { $rp = new ReflectionProperty("D", "p"); var_dump($rp); - } catch (Exception $e) { - echo $e->getMessage(); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } } } @@ -31,11 +31,11 @@ echo "--> Reflect inherited private from global scope:\n"; try { $rp = new ReflectionProperty("D", "p"); var_dump($rp); -} catch (Exception $e) { - echo $e->getMessage(); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } -echo "\n\n--> Reflect inherited private from declaring scope:\n"; +echo "\n--> Reflect inherited private from declaring scope:\n"; C::testFromC(); echo "\n\n--> Reflect inherited private from declaring scope via subclass:\n"; @@ -46,13 +46,15 @@ D::testFromD(); ?> --EXPECT-- --> Reflect inherited private from global scope: -Property D::$p does not exist +ReflectionException: Property D::$p does not exist --> Reflect inherited private from declaring scope: -Property D::$p does not exist +ReflectionException: Property D::$p does not exist + --> Reflect inherited private from declaring scope via subclass: -Property D::$p does not exist +ReflectionException: Property D::$p does not exist + --> Reflect inherited private from subclass: -Property D::$p does not exist +ReflectionException: Property D::$p does not exist diff --git a/ext/reflection/tests/ReflectionProperty_error.phpt b/ext/reflection/tests/ReflectionProperty_error.phpt index bb53599ce67d..28c38d66fa29 100644 --- a/ext/reflection/tests/ReflectionProperty_error.phpt +++ b/ext/reflection/tests/ReflectionProperty_error.phpt @@ -9,23 +9,23 @@ class C { try { new ReflectionProperty(); -} catch (TypeError $re) { - echo "Ok - ".$re->getMessage().PHP_EOL; +} catch (Throwable $re) { + echo $re::class, ': ', $re->getMessage(), "\n"; } try { new ReflectionProperty('C::p'); -} catch (TypeError $re) { - echo "Ok - ".$re->getMessage().PHP_EOL; +} catch (Throwable $re) { + echo $re::class, ': ', $re->getMessage(), "\n"; } try { new ReflectionProperty('C', 'p', 'x'); -} catch (TypeError $re) { - echo "Ok - ".$re->getMessage().PHP_EOL; +} catch (Throwable $re) { + echo $re::class, ': ', $re->getMessage(), "\n"; } ?> --EXPECT-- -Ok - ReflectionProperty::__construct() expects exactly 2 arguments, 0 given -Ok - ReflectionProperty::__construct() expects exactly 2 arguments, 1 given -Ok - ReflectionProperty::__construct() expects exactly 2 arguments, 3 given +ArgumentCountError: ReflectionProperty::__construct() expects exactly 2 arguments, 0 given +ArgumentCountError: ReflectionProperty::__construct() expects exactly 2 arguments, 1 given +ArgumentCountError: ReflectionProperty::__construct() expects exactly 2 arguments, 3 given diff --git a/ext/reflection/tests/ReflectionProperty_getMangledName_dynamic.phpt b/ext/reflection/tests/ReflectionProperty_getMangledName_dynamic.phpt index 271552ab46ae..df2bd34af00c 100644 --- a/ext/reflection/tests/ReflectionProperty_getMangledName_dynamic.phpt +++ b/ext/reflection/tests/ReflectionProperty_getMangledName_dynamic.phpt @@ -19,8 +19,8 @@ function testDynamicProperty($obj, $property, $description) { $array = (array) $obj; echo " Found in array cast: " . (array_key_exists($reflection->getMangledName(), $array) ? "yes" : "no") . "\n"; echo "\n"; - } catch (ReflectionException $e) { - echo "$description: EXCEPTION - " . $e->getMessage() . "\n\n"; + } catch (Throwable $e) { + echo "$description: ", $e::class, ': ', $e->getMessage(), "\n"; } } @@ -60,15 +60,15 @@ echo "\n=== Testing ReflectionProperty from class vs instance ===\n"; try { $reflection = new ReflectionProperty('TestClass', 'dynamic'); echo "This should not be reached\n"; -} catch (ReflectionException $e) { - echo "Expected exception for class-based reflection: " . $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo 'class-based reflection: ', $e::class, ': ', $e->getMessage(), "\n"; } try { $reflection = new ReflectionProperty($obj, 'dynamic'); echo "Instance-based reflection works: " . $reflection->getMangledName() . "\n"; -} catch (ReflectionException $e) { - echo "Unexpected exception: " . $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo 'unexpected: ', $e::class, ': ', $e->getMessage(), "\n"; } ?> @@ -121,5 +121,5 @@ Regular property: getMangledName(): existing === Testing ReflectionProperty from class vs instance === -Expected exception for class-based reflection: Property TestClass::$dynamic does not exist +class-based reflection: ReflectionException: Property TestClass::$dynamic does not exist Instance-based reflection works: dynamic diff --git a/ext/reflection/tests/ReflectionProperty_getMangledName_hooks.phpt b/ext/reflection/tests/ReflectionProperty_getMangledName_hooks.phpt index da00a0da2912..76cafcf8f015 100644 --- a/ext/reflection/tests/ReflectionProperty_getMangledName_hooks.phpt +++ b/ext/reflection/tests/ReflectionProperty_getMangledName_hooks.phpt @@ -31,8 +31,8 @@ function testHookedProperty($obj, $property, $description) { echo " Found in array cast: " . (array_key_exists($reflection->getMangledName(), $array) ? "yes" : "no") . "\n"; echo " Has hooks: " . ($reflection->hasHooks() ? "yes" : "no") . "\n"; echo "\n"; - } catch (ReflectionException $e) { - echo "$description: EXCEPTION - " . $e->getMessage() . "\n\n"; + } catch (Throwable $e) { + echo "$description: ", $e::class, ': ', $e->getMessage(), "\n"; } } diff --git a/ext/reflection/tests/ReflectionProperty_getMangledName_inheritance.phpt b/ext/reflection/tests/ReflectionProperty_getMangledName_inheritance.phpt index 301756c8cbf2..6072294880fa 100644 --- a/ext/reflection/tests/ReflectionProperty_getMangledName_inheritance.phpt +++ b/ext/reflection/tests/ReflectionProperty_getMangledName_inheritance.phpt @@ -40,16 +40,16 @@ echo "Access to parent's private property not in child:\n"; try { $reflection = new ReflectionProperty('ChildClass', 'parentOnly'); echo "ERROR: Should have failed\n"; -} catch (ReflectionException $e) { - echo "Instance-based creation failed as expected: " . $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo 'Instance-based creation failed as expected: ', $e::class, ': ', $e->getMessage(), "\n"; } try { $obj = new ChildClass(); $reflection = new ReflectionProperty($obj, 'parentOnly'); echo "ERROR: Should have failed\n"; -} catch (ReflectionException $e) { - echo "Object-based creation failed as expected: " . $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo 'Object-based creation failed as expected: ', $e::class, ': ', $e->getMessage(), "\n"; } ?> @@ -83,5 +83,5 @@ Mangled name: '%0ChildClass%0private' Key exists in array cast: yes Access to parent's private property not in child: -Instance-based creation failed as expected: Property ChildClass::$parentOnly does not exist -Object-based creation failed as expected: Property ChildClass::$parentOnly does not exist +Instance-based creation failed as expected: ReflectionException: Property ChildClass::$parentOnly does not exist +Object-based creation failed as expected: ReflectionException: Property ChildClass::$parentOnly does not exist diff --git a/ext/reflection/tests/ReflectionProperty_getMangledName_instance.phpt b/ext/reflection/tests/ReflectionProperty_getMangledName_instance.phpt index 7c24ce85f173..794d3a845ed2 100644 --- a/ext/reflection/tests/ReflectionProperty_getMangledName_instance.phpt +++ b/ext/reflection/tests/ReflectionProperty_getMangledName_instance.phpt @@ -22,8 +22,8 @@ function testFromClass($property) { echo " getName(): " . $reflection->getName() . "\n"; echo " getMangledName(): " . $reflection->getMangledName() . "\n"; echo "\n"; - } catch (ReflectionException $e) { - echo "Property $property from class: EXCEPTION - " . $e->getMessage() . "\n\n"; + } catch (Throwable $e) { + echo "Property $property from class: ", $e::class, ': ', $e->getMessage(), "\n"; } } @@ -44,8 +44,8 @@ function testFromInstance($obj, $property) { $array = (array) $obj; echo " Found in array cast: " . (array_key_exists($reflection->getMangledName(), $array) ? "yes" : "no") . "\n"; echo "\n"; - } catch (ReflectionException $e) { - echo "Property $property from instance: EXCEPTION - " . $e->getMessage() . "\n\n"; + } catch (Throwable $e) { + echo "Property $property from instance: ", $e::class, ': ', $e->getMessage(), "\n"; } } @@ -74,8 +74,7 @@ Property private from class: getName(): private getMangledName(): %0TestClass%0private -Property dynamic from class: EXCEPTION - Property TestClass::$dynamic does not exist - +Property dynamic from class: ReflectionException: Property TestClass::$dynamic does not exist === Testing ReflectionProperty from INSTANCE === Property public from instance: getName(): public diff --git a/ext/reflection/tests/ReflectionProperty_getValue_error.phpt b/ext/reflection/tests/ReflectionProperty_getValue_error.phpt index a898eea6bea0..d436a84e5990 100644 --- a/ext/reflection/tests/ReflectionProperty_getValue_error.phpt +++ b/ext/reflection/tests/ReflectionProperty_getValue_error.phpt @@ -24,8 +24,8 @@ $propInfo = new ReflectionProperty('TestClass', 'stat'); echo "\nStatic property / too many args:\n"; try { var_dump($propInfo->getValue($instance, true)); -} catch (TypeError $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } echo "\nProtected property:\n"; @@ -36,15 +36,15 @@ echo "\n\nInvalid instance:\n"; $propInfo = new ReflectionProperty('TestClass', 'pub2'); try { var_dump($propInfo->getValue($invalidInstance)); -} catch (ReflectionException $e) { - echo $e->getMessage(); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } -echo "\n\nMissing instance:\n"; +echo "\nMissing instance:\n"; try { var_dump($propInfo->getValue()); -} catch (TypeError $e) { - echo $e->getMessage(); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> @@ -52,14 +52,14 @@ try { Instance without property: Static property / too many args: -ReflectionProperty::getValue() expects at most 1 argument, 2 given +ArgumentCountError: ReflectionProperty::getValue() expects at most 1 argument, 2 given Protected property: int(4) Invalid instance: -Given object is not an instance of the class this property was declared in +ReflectionException: Given object is not an instance of the class this property was declared in Missing instance: -ReflectionProperty::getValue(): Argument #1 ($object) must be provided for instance properties +TypeError: ReflectionProperty::getValue(): Argument #1 ($object) must be provided for instance properties diff --git a/ext/reflection/tests/ReflectionProperty_isInitialized.phpt b/ext/reflection/tests/ReflectionProperty_isInitialized.phpt index 2ba6ff438bd1..05161572e8d8 100644 --- a/ext/reflection/tests/ReflectionProperty_isInitialized.phpt +++ b/ext/reflection/tests/ReflectionProperty_isInitialized.phpt @@ -54,14 +54,14 @@ var_dump($rp->isInitialized($a)); try { var_dump($rp->isInitialized(new stdClass)); -} catch (ReflectionException $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump($rp->isInitialized()); -} catch (TypeError $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } class WithMagic { @@ -109,8 +109,8 @@ bool(false) bool(false) Object type: bool(false) -Given object is not an instance of the class this property was declared in -ReflectionProperty::isInitialized(): Argument #1 ($object) must be provided for instance properties +ReflectionException: Given object is not an instance of the class this property was declared in +TypeError: ReflectionProperty::isInitialized(): Argument #1 ($object) must be provided for instance properties Class with __isset: bool(false) bool(false) diff --git a/ext/reflection/tests/ReflectionProperty_lazy_initialization_errors.phpt b/ext/reflection/tests/ReflectionProperty_lazy_initialization_errors.phpt index 8bd82ff64020..c30f832cef3a 100644 --- a/ext/reflection/tests/ReflectionProperty_lazy_initialization_errors.phpt +++ b/ext/reflection/tests/ReflectionProperty_lazy_initialization_errors.phpt @@ -16,13 +16,13 @@ function test(object $obj, string $propertyName) { $r = new ReflectionProperty($obj, $propertyName); try { $r->setRawValueWithoutLazyInitialization($obj, true); - } catch (ReflectionException $e) { - echo $e->getMessage() . "\n"; + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { $r->skipLazyInitialization($obj); - } catch (ReflectionException $e) { - echo $e->getMessage() . "\n\n"; + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } } @@ -38,14 +38,11 @@ test($obj, 'name'); ?> --EXPECT-- -Cannot use setRawValueWithoutLazyInitialization() on static property Demo::$myStatic -Cannot use skipLazyInitialization() on static property Demo::$myStatic - -Cannot use setRawValueWithoutLazyInitialization() on virtual property Demo::$myVirtual -Cannot use skipLazyInitialization() on virtual property Demo::$myVirtual - -Cannot use setRawValueWithoutLazyInitialization() on dynamic property Demo::$myDynamic -Cannot use skipLazyInitialization() on dynamic property Demo::$myDynamic - -Cannot use setRawValueWithoutLazyInitialization() on internal class ReflectionClass -Cannot use skipLazyInitialization() on internal class ReflectionClass +ReflectionException: Cannot use setRawValueWithoutLazyInitialization() on static property Demo::$myStatic +ReflectionException: Cannot use skipLazyInitialization() on static property Demo::$myStatic +ReflectionException: Cannot use setRawValueWithoutLazyInitialization() on virtual property Demo::$myVirtual +ReflectionException: Cannot use skipLazyInitialization() on virtual property Demo::$myVirtual +ReflectionException: Cannot use setRawValueWithoutLazyInitialization() on dynamic property Demo::$myDynamic +ReflectionException: Cannot use skipLazyInitialization() on dynamic property Demo::$myDynamic +ReflectionException: Cannot use setRawValueWithoutLazyInitialization() on internal class ReflectionClass +ReflectionException: Cannot use skipLazyInitialization() on internal class ReflectionClass diff --git a/ext/reflection/tests/ReflectionProperty_setValue_readonly.phpt b/ext/reflection/tests/ReflectionProperty_setValue_readonly.phpt index ddab2497a326..986f22bc78c1 100644 --- a/ext/reflection/tests/ReflectionProperty_setValue_readonly.phpt +++ b/ext/reflection/tests/ReflectionProperty_setValue_readonly.phpt @@ -11,13 +11,13 @@ $reflection = new ReflectionProperty(Foo::class, 'value'); try { $reflection->setValue(Foo::Bar, 1); -} catch (Error $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } var_dump(Foo::Bar->value); ?> --EXPECT-- -Cannot modify readonly property Foo::$value +Error: Cannot modify readonly property Foo::$value int(0) diff --git a/ext/reflection/tests/ReflectionProperty_typed_static.phpt b/ext/reflection/tests/ReflectionProperty_typed_static.phpt index 032f9b18ef30..6e24204d3902 100644 --- a/ext/reflection/tests/ReflectionProperty_typed_static.phpt +++ b/ext/reflection/tests/ReflectionProperty_typed_static.phpt @@ -15,8 +15,8 @@ var_dump($rp->getValue()); $rp = new ReflectionProperty('Test', 'y'); try { var_dump($rp->getValue()); -} catch (Error $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } $rp->setValue(null, "24"); @@ -24,8 +24,8 @@ var_dump($rp->getValue()); try { $rp->setValue(null, "foo"); -} catch (TypeError $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } var_dump($rp->getValue()); @@ -34,8 +34,8 @@ Test::$z =& Test::$y; $rp = new ReflectionProperty('Test', 'z'); try { $rp->setValue(null, "foo"); -} catch (TypeError $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } var_dump($rp->getValue()); @@ -43,9 +43,9 @@ var_dump($rp->getValue()); ?> --EXPECT-- int(42) -Typed static property Test::$y must not be accessed before initialization +Error: Typed static property Test::$y must not be accessed before initialization int(24) -Cannot assign string to property Test::$y of type int +TypeError: Cannot assign string to property Test::$y of type int int(24) -Cannot assign string to reference held by property Test::$y of type int +TypeError: Cannot assign string to reference held by property Test::$y of type int int(24) diff --git a/ext/reflection/tests/ReflectionReference_errors.phpt b/ext/reflection/tests/ReflectionReference_errors.phpt index 8ef69e718a9c..d30c697c9d10 100644 --- a/ext/reflection/tests/ReflectionReference_errors.phpt +++ b/ext/reflection/tests/ReflectionReference_errors.phpt @@ -5,47 +5,47 @@ Various error conditions for ReflectionReference try { new ReflectionReference(); -} catch (Error $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { ReflectionReference::fromArrayElement(new stdClass, "test"); -} catch (TypeError $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { ReflectionReference::fromArrayElement([], []); -} catch (TypeError $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { $ary = [0, 1, 2]; ReflectionReference::fromArrayElement($ary, 3); -} catch (ReflectionException $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { $ary = [&$ary]; $ref = ReflectionReference::fromArrayElement($ary, 0); var_dump(serialize($ref)); -} catch (Exception $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump(unserialize('O:19:"ReflectionReference":0:{}')); -} catch (Exception $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECTF-- -Call to private ReflectionReference::__construct() from global scope -ReflectionReference::fromArrayElement(): Argument #1 ($array) must be of type array, stdClass given -ReflectionReference::fromArrayElement(): Argument #2 ($key) must be of type string|int, array given -Array key not found -Serialization of 'ReflectionReference' is not allowed -Unserialization of 'ReflectionReference' is not allowed +Error: Call to private ReflectionReference::__construct() from global scope +TypeError: ReflectionReference::fromArrayElement(): Argument #1 ($array) must be of type array, stdClass given +TypeError: ReflectionReference::fromArrayElement(): Argument #2 ($key) must be of type string|int, array given +ReflectionException: Array key not found +Exception: Serialization of 'ReflectionReference' is not allowed +Exception: Unserialization of 'ReflectionReference' is not allowed diff --git a/ext/reflection/tests/ReflectionZendExtension_error.phpt b/ext/reflection/tests/ReflectionZendExtension_error.phpt index af716c43072c..d8c96907b8f8 100644 --- a/ext/reflection/tests/ReflectionZendExtension_error.phpt +++ b/ext/reflection/tests/ReflectionZendExtension_error.phpt @@ -8,10 +8,10 @@ opcache getMessage(); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- -Zend Extension "zend_opcache" does not exist +ReflectionException: Zend Extension "zend_opcache" does not exist diff --git a/ext/reflection/tests/attributes/ReflectionAttribute_constructor_001.phpt b/ext/reflection/tests/attributes/ReflectionAttribute_constructor_001.phpt index ad895dc42437..856b76bed69d 100644 --- a/ext/reflection/tests/attributes/ReflectionAttribute_constructor_001.phpt +++ b/ext/reflection/tests/attributes/ReflectionAttribute_constructor_001.phpt @@ -17,9 +17,9 @@ $rm = new ReflectionMethod($attribute, "__construct"); try { var_dump($rm->invoke($attribute, 0, 1, 2)); -} catch (ReflectionException $exception) { - echo $exception->getMessage(); +} catch (Throwable $exception) { + echo $exception::class, ': ', $exception->getMessage(), "\n"; } ?> --EXPECT-- -Cannot directly instantiate ReflectionAttribute +ReflectionException: Cannot directly instantiate ReflectionAttribute diff --git a/ext/reflection/tests/bug38217.phpt b/ext/reflection/tests/bug38217.phpt index cc7525c813e0..d1df38496387 100644 --- a/ext/reflection/tests/bug38217.phpt +++ b/ext/reflection/tests/bug38217.phpt @@ -21,7 +21,7 @@ $class= new ReflectionClass('ObjectTwo'); try { var_dump($class->newInstanceArgs()); } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } var_dump($class->newInstanceArgs(array('test'))); @@ -31,7 +31,7 @@ echo "Done\n"; --EXPECTF-- object(ObjectOne)#%d (0) { } -Exception: Too few arguments to function ObjectTwo::__construct(), 0 passed and exactly 1 expected +ArgumentCountError: Too few arguments to function ObjectTwo::__construct(), 0 passed and exactly 1 expected string(4) "test" object(ObjectTwo)#%d (0) { } diff --git a/ext/reflection/tests/bug41061.phpt b/ext/reflection/tests/bug41061.phpt index df807566dbb0..0d2b68b0a9a3 100644 --- a/ext/reflection/tests/bug41061.phpt +++ b/ext/reflection/tests/bug41061.phpt @@ -22,4 +22,3 @@ Function [ function foo ] { Method [ private method foo ] { @@ %sbug41061.php 7 - 8 } - diff --git a/ext/reflection/tests/bug46064.phpt b/ext/reflection/tests/bug46064.phpt index 49d3760941e2..be66d1091b8d 100644 --- a/ext/reflection/tests/bug46064.phpt +++ b/ext/reflection/tests/bug46064.phpt @@ -23,8 +23,8 @@ var_dump($h->getValue($o)); print "---------------------------\n"; try { var_dump(new reflectionproperty($o, 'zz')); -} catch (Exception $e) { - var_dump($e->getMessage()); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } var_dump(new reflectionproperty($o, 'zzz')); @@ -64,7 +64,7 @@ array(1) { } int(1000) --------------------------- -string(30) "Property x::$zz does not exist" +ReflectionException: Property x::$zz does not exist object(ReflectionProperty)#%d (2) { ["name"]=> string(3) "zzz" diff --git a/ext/reflection/tests/bug49719.phpt b/ext/reflection/tests/bug49719.phpt index 1a0ffca4bd2d..be1da1a56365 100644 --- a/ext/reflection/tests/bug49719.phpt +++ b/ext/reflection/tests/bug49719.phpt @@ -18,8 +18,8 @@ try { var_dump(property_exists($b, 'a')); var_dump($ref->hasProperty('a')); var_dump($ref->getProperty('a')); -} catch (Exception $e) { - var_dump($e->getMessage()); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } class A2 { @@ -39,5 +39,5 @@ var_dump($prop->getValue(new b2)); bool(false) bool(false) bool(false) -string(29) "Property B::$a does not exist" +ReflectionException: Property B::$a does not exist int(2) diff --git a/ext/reflection/tests/bug52854.phpt b/ext/reflection/tests/bug52854.phpt index 2d174bc11eba..b395d5b69c38 100644 --- a/ext/reflection/tests/bug52854.phpt +++ b/ext/reflection/tests/bug52854.phpt @@ -12,8 +12,8 @@ var_dump($c->newInstanceArgs(array())); try { var_dump($c->newInstanceArgs(array(1))); -} catch(ReflectionException $e) { - echo $e->getMessage()."\n"; +} catch(Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECTF-- @@ -25,4 +25,4 @@ object(Test)#%d (0) { } object(Test)#%d (0) { } -Class Test does not have a constructor, so you cannot pass any constructor arguments +ReflectionException: Class Test does not have a constructor, so you cannot pass any constructor arguments diff --git a/ext/reflection/tests/bug64007.phpt b/ext/reflection/tests/bug64007.phpt index a25beb6360d7..94603072f2d6 100644 --- a/ext/reflection/tests/bug64007.phpt +++ b/ext/reflection/tests/bug64007.phpt @@ -6,15 +6,15 @@ $reflection = new ReflectionClass('Generator'); try { $generator = $reflection->newInstanceWithoutConstructor(); var_dump($generator); -} catch (Exception $e) { - var_dump($e->getMessage()); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } $generator = $reflection->newInstance(); var_dump($generator); ?> --EXPECTF-- -string(%d) "Class Generator is an internal class marked as final that cannot be instantiated without invoking its constructor" +ReflectionException: Class Generator is an internal class marked as final that cannot be instantiated without invoking its constructor Fatal error: Uncaught Error: The "Generator" class is reserved for internal use and cannot be manually instantiated in %sbug64007.php:%d Stack trace: diff --git a/ext/reflection/tests/bug71018.phpt b/ext/reflection/tests/bug71018.phpt index cbbb7325e9f1..6c871fa59dd0 100644 --- a/ext/reflection/tests/bug71018.phpt +++ b/ext/reflection/tests/bug71018.phpt @@ -33,8 +33,8 @@ set_error_handler(function ($severity, $message, $file, $line) { }); try { $Prop2->setValue(\T2::class, 'hi'); -} catch (Exception $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } var_dump("T2::self = " . T2::getDataByStatic()); @@ -53,7 +53,7 @@ Deprecated: Calling ReflectionProperty::setValue() with a 1st argument which is Deprecated: Calling ReflectionProperty::setValue() with a 1st argument which is not null or an object is deprecated in %s on line %d string(16) "T2::self = hello" string(18) "T2::static = hello" -Calling ReflectionProperty::setValue() with a 1st argument which is not null or an object is deprecated +Exception: Calling ReflectionProperty::setValue() with a 1st argument which is not null or an object is deprecated string(16) "T2::self = hello" string(16) "T2::self = hello" string(18) "T2::static = hello" diff --git a/ext/reflection/tests/bug74454.phpt b/ext/reflection/tests/bug74454.phpt index 272409339c47..387b81d53078 100644 --- a/ext/reflection/tests/bug74454.phpt +++ b/ext/reflection/tests/bug74454.phpt @@ -6,7 +6,7 @@ spl_autoload_register('load_file'); try { $x = new ReflectionMethod('A', 'b'); } catch (\Throwable $e) { - echo get_class($e), ': ', $e->getMessage(), PHP_EOL; + echo $e::class, ': ', $e->getMessage(), "\n"; } function load_file() { diff --git a/ext/reflection/tests/bug74949.phpt b/ext/reflection/tests/bug74949.phpt index 858e766c0144..03db70822d61 100644 --- a/ext/reflection/tests/bug74949.phpt +++ b/ext/reflection/tests/bug74949.phpt @@ -13,12 +13,12 @@ echo $r, "\n"; try { echo $r->getPrototype(); -} catch (Exception $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- Method [ public method __invoke ] { } -Method Closure::__invoke() does not have a prototype +ReflectionException: Method Closure::__invoke() does not have a prototype diff --git a/ext/reflection/tests/bug76737.phpt b/ext/reflection/tests/bug76737.phpt index 3fe1c5443ba7..d5ef9ec56295 100644 --- a/ext/reflection/tests/bug76737.phpt +++ b/ext/reflection/tests/bug76737.phpt @@ -6,23 +6,23 @@ Bug #76737: Unserialized reflection objects are broken, they shouldn't be serial try { $r = new ReflectionClass('stdClass'); var_dump(serialize($r)); -} catch (Exception $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { $s = 'C:15:"ReflectionClass":0:{}'; var_dump(unserialize($s)); -} catch (Exception $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { $s = 'O:15:"ReflectionClass":0:{}'; var_dump(unserialize($s)); -} catch (Exception $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECTF-- -Serialization of 'ReflectionClass' is not allowed -Unserialization of 'ReflectionClass' is not allowed -Unserialization of 'ReflectionClass' is not allowed +Exception: Serialization of 'ReflectionClass' is not allowed +Exception: Unserialization of 'ReflectionClass' is not allowed +Exception: Unserialization of 'ReflectionClass' is not allowed diff --git a/ext/reflection/tests/bug78697.phpt b/ext/reflection/tests/bug78697.phpt index b35d0f4d4ef6..750f3aa06552 100644 --- a/ext/reflection/tests/bug78697.phpt +++ b/ext/reflection/tests/bug78697.phpt @@ -6,9 +6,9 @@ trait T {} try { (new ReflectionClass(new stdClass))->implementsInterface(T::class); -} catch (ReflectionException $e) { - echo $e->getMessage(); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- -T is not an interface +ReflectionException: T is not an interface diff --git a/ext/reflection/tests/bug78895.phpt b/ext/reflection/tests/bug78895.phpt index b5f84e2d02ba..c39c8bab2edd 100644 --- a/ext/reflection/tests/bug78895.phpt +++ b/ext/reflection/tests/bug78895.phpt @@ -35,4 +35,4 @@ array(0) { array(0) { } array(0) { -} \ No newline at end of file +} diff --git a/ext/reflection/tests/bug81208.phpt b/ext/reflection/tests/bug81208.phpt index 6b4753522d41..37610bd449f8 100644 --- a/ext/reflection/tests/bug81208.phpt +++ b/ext/reflection/tests/bug81208.phpt @@ -18,11 +18,11 @@ $z = new ReflectionClass(MyClass::class); foreach ($z->getProperty("property")->getAttributes() as $attribute) { try { $attribute->newInstance(); - } catch (Error $e) { - echo $e->getMessage(), "\n"; + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } } ?> --EXPECT-- -Undefined constant "asdasdasd" +Error: Undefined constant "asdasdasd" diff --git a/ext/reflection/tests/default_value_internal_userland_arginfo.phpt b/ext/reflection/tests/default_value_internal_userland_arginfo.phpt index b55a9463791b..1bb6a5c15ebe 100644 --- a/ext/reflection/tests/default_value_internal_userland_arginfo.phpt +++ b/ext/reflection/tests/default_value_internal_userland_arginfo.phpt @@ -11,8 +11,8 @@ $rp = $rm->getParameters()[0]; var_dump($rp->isDefaultValueAvailable()); try { var_dump($rp->getDefaultValue()); -} catch (ReflectionException $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- @@ -24,4 +24,4 @@ Method [ public method __invoke ] { } bool(false) -Internal error: Failed to retrieve the default value +ReflectionException: Internal error: Failed to retrieve the default value diff --git a/ext/reflection/tests/gh12856.phpt b/ext/reflection/tests/gh12856.phpt index 519a222ab0ed..4eae664f63ad 100644 --- a/ext/reflection/tests/gh12856.phpt +++ b/ext/reflection/tests/gh12856.phpt @@ -13,8 +13,8 @@ $rc = new ReflectionClass(Bug::class); var_dump($rc->getStaticPropertyValue('untyped')); try { var_dump($rc->getStaticPropertyValue('typed1')); -} catch (Error $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } var_dump($rc->getStaticPropertyValue('typed1', 1)); var_dump($rc->getStaticPropertyValue('typed2')); @@ -22,6 +22,6 @@ var_dump($rc->getStaticPropertyValue('typed2')); ?> --EXPECT-- NULL -Typed property Bug::$typed1 must not be accessed before initialization +Error: Typed property Bug::$typed1 must not be accessed before initialization int(1) int(3) diff --git a/ext/reflection/tests/gh21362.phpt b/ext/reflection/tests/gh21362.phpt index 1f5619ce779d..78cc7c0af580 100644 --- a/ext/reflection/tests/gh21362.phpt +++ b/ext/reflection/tests/gh21362.phpt @@ -20,16 +20,16 @@ $m->invokeArgs($c1, ['foo' => 'FOO', 'bar' => 'BAR']); try { $m->invokeArgs($c2, ['foo' => 'FOO', 'bar' => 'BAR']); echo "No exception thrown\n"; -} catch (ReflectionException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } // invoke with a different Closure should also throw try { $m->invoke($c2, 'FOO', 'BAR'); echo "No exception thrown\n"; -} catch (ReflectionException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } // Closures from the same source (e.g. loop) share the same op_array @@ -59,8 +59,8 @@ var_dump($m3->invoke($mf2, 'test')); try { $m3->invoke($of, 'test'); echo "No exception thrown\n"; -} catch (ReflectionException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } // Internal closures (first-class callable syntax) should also be validated @@ -78,38 +78,38 @@ $m4->invoke($vd2, 'cloned internal closure OK'); try { $m4->invoke($pr, 'should not print'); echo "No exception thrown\n"; -} catch (ReflectionException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } // Cross-type: userland Closure to internal Closure's invoke should throw try { $m4->invoke($c1, 'should not print'); echo "No exception thrown\n"; -} catch (ReflectionException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } // Cross-type: internal Closure to userland Closure's invoke should throw try { $m->invoke($vd, 'should not print'); echo "No exception thrown\n"; -} catch (ReflectionException $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- c1: foo=FOO, bar=BAR -Given Closure is not the same as the reflected Closure -Given Closure is not the same as the reflected Closure +ReflectionException: Given Closure is not the same as the reflected Closure +ReflectionException: Given Closure is not the same as the reflected Closure int(0) int(1) int(2) string(13) "my_func: test" string(13) "my_func: test" -Given Closure is not the same as the reflected Closure +ReflectionException: Given Closure is not the same as the reflected Closure string(19) "internal closure OK" string(26) "cloned internal closure OK" -Given Closure is not the same as the reflected Closure -Given Closure is not the same as the reflected Closure -Given Closure is not the same as the reflected Closure +ReflectionException: Given Closure is not the same as the reflected Closure +ReflectionException: Given Closure is not the same as the reflected Closure +ReflectionException: Given Closure is not the same as the reflected Closure diff --git a/ext/reflection/tests/gh8982.phpt b/ext/reflection/tests/gh8982.phpt index 0bbda8bfb915..1a06c107ec91 100644 --- a/ext/reflection/tests/gh8982.phpt +++ b/ext/reflection/tests/gh8982.phpt @@ -29,8 +29,8 @@ function f() {} function test(string $attributeClass, $value) { try { var_dump((new ReflectionFunction($value))->getAttributes($attributeClass)[0]->newInstance()); - } catch (Error $e) { - echo $e->getMessage(), "\n"; + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } } @@ -46,7 +46,7 @@ test(M::class, $m); --EXPECT-- object(F)#4 (0) { } -Attribute "M" cannot target function (allowed targets: method) -Attribute "F" cannot target method (allowed targets: function) +Error: Attribute "M" cannot target function (allowed targets: method) +Error: Attribute "F" cannot target method (allowed targets: function) object(M)#4 (0) { } diff --git a/ext/reflection/tests/internal_parameter_default_value/ReflectionParameter_getDefaultValueConstantName_Internal.phpt b/ext/reflection/tests/internal_parameter_default_value/ReflectionParameter_getDefaultValueConstantName_Internal.phpt index b6473b0a3abb..e5bc0c3ec505 100644 --- a/ext/reflection/tests/internal_parameter_default_value/ReflectionParameter_getDefaultValueConstantName_Internal.phpt +++ b/ext/reflection/tests/internal_parameter_default_value/ReflectionParameter_getDefaultValueConstantName_Internal.phpt @@ -8,8 +8,8 @@ $method = $class->getMethod('setTime'); foreach ($method->getParameters() as $parameter) { try { var_dump($parameter->getDefaultValueConstantName()); - } catch (ReflectionException $exception) { - echo $exception->getMessage() . "\n"; + } catch (Throwable $exception) { + echo $exception::class, ': ', $exception->getMessage(), "\n"; } } @@ -21,8 +21,8 @@ $method = $class->getMethod('getTransitions'); foreach ($method->getParameters() as $parameter) { try { var_dump($parameter->getDefaultValueConstantName()); - } catch (ReflectionException $exception) { - echo $exception->getMessage() . "\n"; + } catch (Throwable $exception) { + echo $exception::class, ': ', $exception->getMessage(), "\n"; } } @@ -34,15 +34,15 @@ $method = $class->getMethod('listIdentifiers'); foreach ($method->getParameters() as $parameter) { try { var_dump($parameter->getDefaultValueConstantName()); - } catch (ReflectionException $exception) { - echo $exception->getMessage() . "\n"; + } catch (Throwable $exception) { + echo $exception::class, ': ', $exception->getMessage(), "\n"; } } ?> --EXPECT-- -Internal error: Failed to retrieve the default value -Internal error: Failed to retrieve the default value +ReflectionException: Internal error: Failed to retrieve the default value +ReflectionException: Internal error: Failed to retrieve the default value NULL NULL ---------- diff --git a/ext/reflection/tests/internal_parameter_default_value/ReflectionParameter_getDefaultValue_Internal.phpt b/ext/reflection/tests/internal_parameter_default_value/ReflectionParameter_getDefaultValue_Internal.phpt index c1e1a14b279b..036cc7ab905c 100644 --- a/ext/reflection/tests/internal_parameter_default_value/ReflectionParameter_getDefaultValue_Internal.phpt +++ b/ext/reflection/tests/internal_parameter_default_value/ReflectionParameter_getDefaultValue_Internal.phpt @@ -8,8 +8,8 @@ $method = $class->getMethod('setTime'); foreach ($method->getParameters() as $k => $parameter) { try { var_dump($parameter->getDefaultValue()); - } catch (ReflectionException $exception) { - echo $exception->getMessage() . "\n"; + } catch (Throwable $exception) { + echo $exception::class, ': ', $exception->getMessage(), "\n"; } } @@ -21,15 +21,15 @@ $method = $class->getMethod('listIdentifiers'); foreach ($method->getParameters() as $parameter) { try { var_dump($parameter->getDefaultValue()); - } catch (ReflectionException $exception) { - echo $exception->getMessage() . "\n"; + } catch (Throwable $exception) { + echo $exception::class, ': ', $exception->getMessage(), "\n"; } } ?> --EXPECT-- -Internal error: Failed to retrieve the default value -Internal error: Failed to retrieve the default value +ReflectionException: Internal error: Failed to retrieve the default value +ReflectionException: Internal error: Failed to retrieve the default value int(0) int(0) ---------- diff --git a/ext/reflection/tests/internal_parameter_default_value/ReflectionParameter_isDefaultValueConstant_Internal.phpt b/ext/reflection/tests/internal_parameter_default_value/ReflectionParameter_isDefaultValueConstant_Internal.phpt index 35c554807492..02936c6a0bb4 100644 --- a/ext/reflection/tests/internal_parameter_default_value/ReflectionParameter_isDefaultValueConstant_Internal.phpt +++ b/ext/reflection/tests/internal_parameter_default_value/ReflectionParameter_isDefaultValueConstant_Internal.phpt @@ -8,8 +8,8 @@ $method = $class->getMethod('setTime'); foreach ($method->getParameters() as $parameter) { try { var_dump($parameter->isDefaultValueConstant()); - } catch (ReflectionException $exception) { - echo $exception->getMessage() . "\n"; + } catch (Throwable $exception) { + echo $exception::class, ': ', $exception->getMessage(), "\n"; } } @@ -21,14 +21,14 @@ $method = $class->getMethod('listIdentifiers'); foreach ($method->getParameters() as $parameter) { try { var_dump($parameter->isDefaultValueConstant()); - } catch (ReflectionException $exception) { - echo $exception->getMessage() . "\n"; + } catch (Throwable $exception) { + echo $exception::class, ': ', $exception->getMessage(), "\n"; } } ?> --EXPECT-- -Internal error: Failed to retrieve the default value -Internal error: Failed to retrieve the default value +ReflectionException: Internal error: Failed to retrieve the default value +ReflectionException: Internal error: Failed to retrieve the default value bool(false) bool(false) ---------- diff --git a/ext/reflection/tests/internal_parameter_default_value/check_all.phpt b/ext/reflection/tests/internal_parameter_default_value/check_all.phpt index 241dea449b61..a9cf98007e8b 100644 --- a/ext/reflection/tests/internal_parameter_default_value/check_all.phpt +++ b/ext/reflection/tests/internal_parameter_default_value/check_all.phpt @@ -8,8 +8,8 @@ function checkDefaults(ReflectionFunctionAbstract $rf) { if ($param->isDefaultValueAvailable()) { try { $param->getDefaultValue(); - } catch (Error $e) { - echo "{$rf->getName()}: {$e->getMessage()}\n"; + } catch (Throwable $e) { + echo $rf->getName(), ': ', $e::class, ': ', $e->getMessage(), "\n"; } } } diff --git a/ext/reflection/tests/parameters_001.phpt b/ext/reflection/tests/parameters_001.phpt index d50d1a1e720f..05a4fcb4bf95 100644 --- a/ext/reflection/tests/parameters_001.phpt +++ b/ext/reflection/tests/parameters_001.phpt @@ -22,14 +22,14 @@ var_dump($p->isOptional()); try { $p = new ReflectionParameter(array('Test', 'func'), 'z'); var_dump($p->isOptional()); -} catch (Exception $e) { - var_dump($e->getMessage()); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { $p = new ReflectionParameter(array('Test', 'func'), -1); var_dump($p->isOptional()); -} catch (\ValueError $e) { - var_dump($e->getMessage()); +} catch (\Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> @@ -38,5 +38,5 @@ int(2) int(1) bool(false) bool(true) -string(54) "The parameter specified by its name could not be found" -string(91) "ReflectionParameter::__construct(): Argument #2 ($param) must be greater than or equal to 0" +ReflectionException: The parameter specified by its name could not be found +ValueError: ReflectionParameter::__construct(): Argument #2 ($param) must be greater than or equal to 0 diff --git a/ext/reflection/tests/parameters_002.phpt b/ext/reflection/tests/parameters_002.phpt index 2ef0ca4c0cc8..4868bc32826d 100644 --- a/ext/reflection/tests/parameters_002.phpt +++ b/ext/reflection/tests/parameters_002.phpt @@ -50,9 +50,9 @@ function check_params($r) { check_params_decl_class($p, 'getClass'); } - catch(ReflectionException $e) + catch(Throwable $e) { - echo $e->getMessage() . "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } check_params_decl_class($p, 'getDeclaringClass'); // check_params_decl_func($p, 'getDeclaringFunction'); @@ -132,7 +132,7 @@ getName: string(2) "na" isPassedByReference: bool(false) Deprecated: Method ReflectionParameter::getClass() is deprecated since 8.0, use ReflectionParameter::getType() instead in %s on line %d -Class "NonExistingClass" does not exist +ReflectionException: Class "NonExistingClass" does not exist getDeclaringClass: NULL isArray: Deprecated: Method ReflectionParameter::isArray() is deprecated since 8.0, use ReflectionParameter::getType() instead in %s on line %d @@ -226,7 +226,7 @@ getName: string(2) "na" isPassedByReference: bool(false) Deprecated: Method ReflectionParameter::getClass() is deprecated since 8.0, use ReflectionParameter::getType() instead in %s on line %d -Class "NonExistingClass" does not exist +ReflectionException: Class "NonExistingClass" does not exist getDeclaringClass: test isArray: Deprecated: Method ReflectionParameter::isArray() is deprecated since 8.0, use ReflectionParameter::getType() instead in %s on line %d diff --git a/ext/reflection/tests/property_exists.phpt b/ext/reflection/tests/property_exists.phpt index 879b9c4a585b..439aecdca31d 100644 --- a/ext/reflection/tests/property_exists.phpt +++ b/ext/reflection/tests/property_exists.phpt @@ -81,13 +81,13 @@ foreach($pc as $p1) { echo "===PROBLEMS===\n"; try { var_dump(property_exists(NULL, 'empty')); -} catch (\TypeError $e) { - echo $e->getMessage() . \PHP_EOL; +} catch (\Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump(property_exists(25,'empty')); -} catch (\TypeError $e) { - echo $e->getMessage() . \PHP_EOL; +} catch (\Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } var_dump(property_exists('','')); var_dump(property_exists('A','')); @@ -211,8 +211,8 @@ bool(true) obj(C)::$e bool(false) ===PROBLEMS=== -property_exists(): Argument #1 ($object_or_class) must be of type object|string, null given -property_exists(): Argument #1 ($object_or_class) must be of type object|string, int given +TypeError: property_exists(): Argument #1 ($object_or_class) must be of type object|string, null given +TypeError: property_exists(): Argument #1 ($object_or_class) must be of type object|string, int given bool(false) bool(false) bool(false) diff --git a/ext/reflection/tests/property_hooks/ReflectionProperty_getSetRawValue.phpt b/ext/reflection/tests/property_hooks/ReflectionProperty_getSetRawValue.phpt index bae5608bb44b..505a885908b0 100644 --- a/ext/reflection/tests/property_hooks/ReflectionProperty_getSetRawValue.phpt +++ b/ext/reflection/tests/property_hooks/ReflectionProperty_getSetRawValue.phpt @@ -50,13 +50,13 @@ function test($class, $prop) { $object = new $class(); try { $propertyReflection->setRawValue($object, 42); - } catch (Error $e) { - echo $e->getMessage(), "\n"; + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump($propertyReflection->getRawValue($object)); - } catch (Error $e) { - echo $e->getMessage(), "\n"; + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } } @@ -70,7 +70,7 @@ test(Unguarded::class, 'plainProp'); --EXPECT-- int(42) int(42) -Must not write to virtual property Test::$virtualProp -Must not read from virtual property Test::$virtualProp +Error: Must not write to virtual property Test::$virtualProp +Error: Must not read from virtual property Test::$virtualProp int(42) int(42) diff --git a/ext/reflection/tests/property_hooks/basics.phpt b/ext/reflection/tests/property_hooks/basics.phpt index 6011018c64cf..636c3a9f874c 100644 --- a/ext/reflection/tests/property_hooks/basics.phpt +++ b/ext/reflection/tests/property_hooks/basics.phpt @@ -44,8 +44,8 @@ var_dump($s = $rp2->getHook(PropertyHookType::Set)); var_dump($g->invoke($test)); try { $s->invoke($test, 42); -} catch (ReflectionException $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } $s->invoke($test, 42); var_dump($test->prop2); diff --git a/ext/reflection/tests/property_hooks/gh17713.phpt b/ext/reflection/tests/property_hooks/gh17713.phpt index edd0e1204658..e184a92dffe7 100644 --- a/ext/reflection/tests/property_hooks/gh17713.phpt +++ b/ext/reflection/tests/property_hooks/gh17713.phpt @@ -95,23 +95,23 @@ function test($scope, $class, $prop) { try { $propertyReflection->setRawValue($object, 42); } catch (Throwable $e) { - echo $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump($propertyReflection->getRawValue($object)); } catch (Throwable $e) { - echo $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } try { $propertyReflection->setRawValueWithoutLazyInitialization($object, 43); } catch (Throwable $e) { - echo $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump($propertyReflection->getRawValue($object)); } catch (Throwable $e) { - echo $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } if ($prop === 'privateProp') { printf( @@ -155,15 +155,15 @@ int(43) int(42) int(43) # Accessing Base->virtualProp from scope Base -Must not write to virtual property Base::$virtualProp -Must not read from virtual property Base::$virtualProp -Cannot use setRawValueWithoutLazyInitialization() on virtual property Base::$virtualProp -Must not read from virtual property Base::$virtualProp +Error: Must not write to virtual property Base::$virtualProp +Error: Must not read from virtual property Base::$virtualProp +ReflectionException: Cannot use setRawValueWithoutLazyInitialization() on virtual property Base::$virtualProp +Error: Must not read from virtual property Base::$virtualProp # Accessing Test->dynamicProp from scope Base int(42) int(43) # Accessing Test->changedProp from scope Base -May not use setRawValue on static properties -May not use getRawValue on static properties -Cannot use setRawValueWithoutLazyInitialization() on static property Test::$changedProp -May not use getRawValue on static properties +ReflectionException: May not use setRawValue on static properties +ReflectionException: May not use getRawValue on static properties +ReflectionException: Cannot use setRawValueWithoutLazyInitialization() on static property Test::$changedProp +ReflectionException: May not use getRawValue on static properties diff --git a/ext/reflection/tests/request38992.phpt b/ext/reflection/tests/request38992.phpt index 547b2d252313..fce71f864878 100644 --- a/ext/reflection/tests/request38992.phpt +++ b/ext/reflection/tests/request38992.phpt @@ -13,15 +13,15 @@ class MyClass $r = new ReflectionMethod('MyClass', 'doSomething'); try { $r->invoke('WTF?'); -} catch (TypeError $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { $r->invokeArgs('WTF?', array()); -} catch (TypeError $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- -ReflectionMethod::invoke(): Argument #1 ($object) must be of type ?object, string given -ReflectionMethod::invokeArgs(): Argument #1 ($object) must be of type ?object, string given +TypeError: ReflectionMethod::invoke(): Argument #1 ($object) must be of type ?object, string given +TypeError: ReflectionMethod::invokeArgs(): Argument #1 ($object) must be of type ?object, string given diff --git a/ext/reflection/tests/static_properties_with_typed_class_constants1.phpt b/ext/reflection/tests/static_properties_with_typed_class_constants1.phpt index cebfa1dddd3e..a03ae7f08a5d 100644 --- a/ext/reflection/tests/static_properties_with_typed_class_constants1.phpt +++ b/ext/reflection/tests/static_properties_with_typed_class_constants1.phpt @@ -15,10 +15,10 @@ $foo = new ReflectionClass(Foo::class); try { $foo->getStaticProperties(); -} catch (TypeError $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- -Cannot assign string to class constant Foo::CONST1 of type int +TypeError: Cannot assign string to class constant Foo::CONST1 of type int