Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions ext/reflection/tests/002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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"
Expand Down
16 changes: 8 additions & 8 deletions ext/reflection/tests/004.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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
26 changes: 13 additions & 13 deletions ext/reflection/tests/007.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -21,33 +21,33 @@ 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";
try
{
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";
try
{
var_dump($ref->newInstance(25, 42));
}
catch (ReflectionException $e)
catch (Throwable $e)
{
var_dump($e->getMessage());
echo $e::class, ': ', $e->getMessage(), "\n";
}

echo "\n";
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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) {
Expand Down
42 changes: 21 additions & 21 deletions ext/reflection/tests/008.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}

Expand All @@ -25,38 +25,38 @@ $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";
}
}

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
6 changes: 3 additions & 3 deletions ext/reflection/tests/027.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ 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";
}

?>
--EXPECT--
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
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 6 additions & 6 deletions ext/reflection/tests/ReflectionClassConstant_unset_name.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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
42 changes: 21 additions & 21 deletions ext/reflection/tests/ReflectionClass_constructor_002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,54 +4,54 @@ ReflectionClass::__constructor() - bad arguments
<?php
try {
var_dump(new ReflectionClass());
} catch (TypeError $e) {
echo $e->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
6 changes: 3 additions & 3 deletions ext/reflection/tests/ReflectionClass_getConstant_typed.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading
Loading