Skip to content

Commit 7e107b7

Browse files
committed
ext/reflection: Remove ZPP tests and use bool
1 parent 38a2b8e commit 7e107b7

12 files changed

+42
-236
lines changed

ext/reflection/tests/005.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ opcache.save_comments=1
77

88
function strip_doc_comment($c)
99
{
10-
if (!strlen($c) || $c === false) return $c;
10+
if ($c === false || !strlen($c)) return $c;
1111
return trim(substr($c, 3, -2));
1212
}
1313

ext/reflection/tests/ReflectionClass_constructor_002.phpt

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,13 @@
22
ReflectionClass::__constructor() - bad arguments
33
--FILE--
44
<?php
5-
try {
6-
var_dump(new ReflectionClass());
7-
} catch (TypeError $e) {
8-
echo $e->getMessage() . "\n";
9-
}
10-
11-
try {
12-
var_dump(new ReflectionClass(null));
13-
} catch (Exception $e) {
14-
echo $e->getMessage() . "\n";
15-
}
16-
17-
try {
18-
var_dump(new ReflectionClass(true));
19-
} catch (Exception $e) {
20-
echo $e->getMessage() . "\n";
21-
}
225

236
try {
247
var_dump(new ReflectionClass(1));
258
} catch (Exception $e) {
269
echo $e->getMessage() . "\n";
2710
}
2811

29-
try {
30-
var_dump(new ReflectionClass(array(1,2,3)));
31-
} catch (TypeError $e) {
32-
echo $e->getMessage() . "\n";
33-
}
34-
35-
try {
36-
var_dump(new ReflectionClass("stdClass", 1));
37-
} catch (TypeError $e) {
38-
echo $e->getMessage() . "\n";
39-
}
40-
4112
try {
4213
var_dump(new ReflectionClass("X"));
4314
} catch (Exception $e) {
@@ -46,12 +17,5 @@ try {
4617

4718
?>
4819
--EXPECTF--
49-
ReflectionClass::__construct() expects exactly 1 argument, 0 given
50-
51-
Deprecated: ReflectionClass::__construct(): Passing null to parameter #1 ($objectOrClass) of type object|string is deprecated in %s on line %d
52-
Class "" does not exist
53-
Class "1" does not exist
5420
Class "1" does not exist
55-
ReflectionClass::__construct(): Argument #1 ($objectOrClass) must be of type object|string, array given
56-
ReflectionClass::__construct() expects exactly 1 argument, 2 given
5721
Class "X" does not exist

ext/reflection/tests/ReflectionClass_getConstant_error.phpt

Lines changed: 0 additions & 19 deletions
This file was deleted.

ext/reflection/tests/ReflectionClass_getMethod_002.phpt

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,7 @@ class C {
1212
$rc = new ReflectionClass("C");
1313
echo "Check invalid params:\n";
1414
try {
15-
var_dump($rc->getMethod());
16-
} catch (TypeError $e) {
17-
echo $e->getMessage() . "\n";
18-
}
19-
try {
20-
var_dump($rc->getMethod("f", "f"));
21-
} catch (TypeError $e) {
22-
echo $e->getMessage() . "\n";
23-
}
24-
try {
25-
var_dump($rc->getMethod(null));
15+
var_dump($rc->getMethod(''));
2616
} catch (Exception $e) {
2717
echo $e->getMessage() . "\n";
2818
}
@@ -36,33 +26,10 @@ try {
3626
} catch (Exception $e) {
3727
echo $e->getMessage() . "\n";
3828
}
39-
try {
40-
var_dump($rc->getMethod(true));
41-
} catch (Exception $e) {
42-
echo $e->getMessage() . "\n";
43-
}
44-
try {
45-
var_dump($rc->getMethod(array(1,2,3)));
46-
} catch (TypeError $e) {
47-
echo $e->getMessage() . "\n";
48-
}
49-
try {
50-
var_dump($rc->getMethod(new C));
51-
} catch (TypeError $e) {
52-
echo $e->getMessage() . "\n";
53-
}
54-
5529

5630
?>
5731
--EXPECTF--
5832
Check invalid params:
59-
ReflectionClass::getMethod() expects exactly 1 argument, 0 given
60-
ReflectionClass::getMethod() expects exactly 1 argument, 2 given
61-
62-
Deprecated: ReflectionClass::getMethod(): Passing null to parameter #1 ($name) of type string is deprecated in %s on line %d
6333
Method C::() does not exist
6434
Method C::1() does not exist
6535
Method C::1.5() does not exist
66-
Method C::1() does not exist
67-
ReflectionClass::getMethod(): Argument #1 ($name) must be of type string, array given
68-
ReflectionClass::getMethod(): Argument #1 ($name) must be of type string, C given

ext/reflection/tests/ReflectionClass_getProperty_002.phpt

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,7 @@ class C {
1212
$rc = new ReflectionClass("C");
1313
echo "Check invalid params:\n";
1414
try {
15-
var_dump($rc->getProperty());
16-
} catch (TypeError $e) {
17-
echo $e->getMessage() . "\n";
18-
}
19-
try {
20-
var_dump($rc->getProperty("a", "a"));
21-
} catch (TypeError $e) {
22-
echo $e->getMessage() . "\n";
23-
}
24-
try {
25-
var_dump($rc->getProperty(null));
15+
var_dump($rc->getProperty(''));
2616
} catch (exception $e) {
2717
echo $e->getMessage() . "\n";
2818
}
@@ -36,31 +26,9 @@ try {
3626
} catch (exception $e) {
3727
echo $e->getMessage() . "\n";
3828
}
39-
try {
40-
var_dump($rc->getProperty(true));
41-
} catch (exception $e) {
42-
echo $e->getMessage() . "\n";
43-
}
44-
try {
45-
var_dump($rc->getProperty(array(1,2,3)));
46-
} catch (TypeError $e) {
47-
echo $e->getMessage() . "\n";
48-
}
49-
try {
50-
var_dump($rc->getProperty(new C));
51-
} catch (TypeError $e) {
52-
echo $e->getMessage() . "\n";
53-
}
5429
?>
5530
--EXPECTF--
5631
Check invalid params:
57-
ReflectionClass::getProperty() expects exactly 1 argument, 0 given
58-
ReflectionClass::getProperty() expects exactly 1 argument, 2 given
59-
60-
Deprecated: ReflectionClass::getProperty(): Passing null to parameter #1 ($name) of type string is deprecated in %s on line %d
6132
Property C::$ does not exist
6233
Property C::$1 does not exist
6334
Property C::$1.5 does not exist
64-
Property C::$1 does not exist
65-
ReflectionClass::getProperty(): Argument #1 ($name) must be of type string, array given
66-
ReflectionClass::getProperty(): Argument #1 ($name) must be of type string, C given

ext/reflection/tests/ReflectionClass_hasConstant_002.phpt

Lines changed: 0 additions & 22 deletions
This file was deleted.

ext/reflection/tests/ReflectionClass_hasMethod_002.phpt

Lines changed: 0 additions & 22 deletions
This file was deleted.

ext/reflection/tests/ReflectionClass_hasProperty_002.phpt

Lines changed: 0 additions & 22 deletions
This file was deleted.

ext/reflection/tests/ReflectionMethod_constructor_error1.phpt

Lines changed: 36 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -16,99 +16,91 @@ class TestClass
1616
try {
1717
echo "\nWrong type of argument (bool):\n";
1818
$methodInfo = new ReflectionMethod(true);
19-
} catch (Exception $e) {
20-
print $e->__toString();
19+
} catch (Throwable $e) {
20+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
2121
}
2222
try {
2323
echo "\nWrong type of argument (int):\n";
2424
$methodInfo = new ReflectionMethod(3);
25-
} catch (Exception $e) {
26-
print $e->__toString();
25+
} catch (Throwable $e) {
26+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
2727
}
2828
try {
2929
echo "\nWrong type of argument (bool, string):\n";
3030
$methodInfo = new ReflectionMethod(true, "foo");
31-
} catch (Exception $e) {
32-
print $e->__toString();
31+
} catch (Throwable $e) {
32+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
3333
}
3434
try {
3535
echo "\nWrong type of argument (string, bool):\n";
3636
$methodInfo = new ReflectionMethod('TestClass', true);
37-
} catch (Exception $e) {
38-
print $e->__toString();
37+
} catch (Throwable $e) {
38+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
3939
}
4040
try {
4141
echo "\nNo method given:\n";
4242
$methodInfo = new ReflectionMethod("TestClass");
43-
} catch (Exception $e) {
44-
print $e->__toString();
43+
} catch (Throwable $e) {
44+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
4545
}
4646
try {
4747
echo "\nClass and Method in same string, bad method name:\n";
4848
$methodInfo = new ReflectionMethod("TestClass::foop::dedoop");
49-
} catch (Exception $e) {
50-
print $e->__toString();
49+
} catch (Throwable $e) {
50+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
5151
}
5252
try {
5353
echo "\nClass and Method in same string, bad class name:\n";
5454
$methodInfo = new ReflectionMethod("TestCla::foo");
55-
} catch (Exception $e) {
56-
print $e->__toString();
55+
} catch (Throwable $e) {
56+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
5757
}
5858
try {
5959
echo "\nClass and Method in same string (ok):\n";
6060
$methodInfo = new ReflectionMethod("TestClass::foo");
61-
} catch (Exception $e) {
62-
print $e->__toString();
61+
} catch (Throwable $e) {
62+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
6363
}
6464

6565
?>
6666
--EXPECTF--
6767
Wrong type of argument (bool):
6868

6969
Deprecated: Calling ReflectionMethod::__construct() with 1 argument is deprecated, use ReflectionMethod::createFromMethodName() instead in %s on line %d
70-
ReflectionException: ReflectionMethod::__construct(): Argument #1 ($objectOrMethod) must be a valid method name in %s:%d
71-
Stack trace:
72-
#0 %s ReflectionMethod->__construct('1')
73-
#1 {main}
70+
71+
Deprecated: ReflectionMethod::__construct(): Passing bool to parameter #1 ($objectOrMethod) of type object|string is deprecated in %s on line %d
72+
ReflectionException: ReflectionMethod::__construct(): Argument #1 ($objectOrMethod) must be a valid method name
73+
7474
Wrong type of argument (int):
7575

7676
Deprecated: Calling ReflectionMethod::__construct() with 1 argument is deprecated, use ReflectionMethod::createFromMethodName() instead in %s on line %d
77-
ReflectionException: ReflectionMethod::__construct(): Argument #1 ($objectOrMethod) must be a valid method name in %s:%d
78-
Stack trace:
79-
#0 %s ReflectionMethod->__construct('3')
80-
#1 {main}
77+
ReflectionException: ReflectionMethod::__construct(): Argument #1 ($objectOrMethod) must be a valid method name
78+
8179
Wrong type of argument (bool, string):
82-
ReflectionException: Class "1" does not exist in %s:%d
83-
Stack trace:
84-
#0 %s ReflectionMethod->__construct('1', 'foo')
85-
#1 {main}
80+
81+
Deprecated: ReflectionMethod::__construct(): Passing bool to parameter #1 ($objectOrMethod) of type object|string is deprecated in %s on line %d
82+
ReflectionException: Class "1" does not exist
83+
8684
Wrong type of argument (string, bool):
87-
ReflectionException: Method TestClass::1() does not exist in %s:%d
88-
Stack trace:
89-
#0 %s ReflectionMethod->__construct('TestClass', '1')
90-
#1 {main}
85+
86+
Deprecated: ReflectionMethod::__construct(): Passing bool to parameter #2 ($method) of type ?string is deprecated in %s on line %d
87+
ReflectionException: Method TestClass::1() does not exist
88+
9189
No method given:
9290

9391
Deprecated: Calling ReflectionMethod::__construct() with 1 argument is deprecated, use ReflectionMethod::createFromMethodName() instead in %s on line %d
94-
ReflectionException: ReflectionMethod::__construct(): Argument #1 ($objectOrMethod) must be a valid method name in %s:%d
95-
Stack trace:
96-
#0 %s ReflectionMethod->__construct('TestClass')
97-
#1 {main}
92+
ReflectionException: ReflectionMethod::__construct(): Argument #1 ($objectOrMethod) must be a valid method name
93+
9894
Class and Method in same string, bad method name:
9995

10096
Deprecated: Calling ReflectionMethod::__construct() with 1 argument is deprecated, use ReflectionMethod::createFromMethodName() instead in %s on line %d
101-
ReflectionException: Method TestClass::foop::dedoop() does not exist in %s:%d
102-
Stack trace:
103-
#0 %s ReflectionMethod->__construct('TestClass::foop...')
104-
#1 {main}
97+
ReflectionException: Method TestClass::foop::dedoop() does not exist
98+
10599
Class and Method in same string, bad class name:
106100

107101
Deprecated: Calling ReflectionMethod::__construct() with 1 argument is deprecated, use ReflectionMethod::createFromMethodName() instead in %s on line %d
108-
ReflectionException: Class "TestCla" does not exist in %s:%d
109-
Stack trace:
110-
#0 %s ReflectionMethod->__construct('TestCla::foo')
111-
#1 {main}
102+
ReflectionException: Class "TestCla" does not exist
103+
112104
Class and Method in same string (ok):
113105

114106
Deprecated: Calling ReflectionMethod::__construct() with 1 argument is deprecated, use ReflectionMethod::createFromMethodName() instead in %s on line %d

0 commit comments

Comments
 (0)