Skip to content

Commit 73de76c

Browse files
committed
Reflection fixes
1 parent 2f2ee46 commit 73de76c

29 files changed

+98
-552
lines changed

ext/reflection/tests/ReflectionClass_constructor_002.phpt

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ReflectionClass::__constructor() - bad arguments
44
<?php
55
try {
66
var_dump(new ReflectionClass());
7-
} catch (Exception $e) {
7+
} catch (TypeError $e) {
88
echo $e->getMessage() . "\n";
99
}
1010

@@ -34,7 +34,7 @@ try {
3434

3535
try {
3636
var_dump(new ReflectionClass("stdClass", 1));
37-
} catch (Exception $e) {
37+
} catch (TypeError $e) {
3838
echo $e->getMessage() . "\n";
3939
}
4040

@@ -46,21 +46,12 @@ try {
4646

4747
?>
4848
--EXPECTF--
49-
Warning: ReflectionClass::__construct() expects exactly 1 parameter, 0 given in %s on line 3
50-
object(ReflectionClass)#%d (1) {
51-
["name"]=>
52-
string(0) ""
53-
}
49+
ReflectionClass::__construct() expects exactly 1 parameter, 0 given
5450
Class does not exist
5551
Class 1 does not exist
5652
Class 1 does not exist
5753

5854
Notice: Array to string conversion in %s on line 27
5955
Class Array does not exist
60-
61-
Warning: ReflectionClass::__construct() expects exactly 1 parameter, 2 given in %s on line 33
62-
object(ReflectionClass)#%d (1) {
63-
["name"]=>
64-
string(0) ""
65-
}
56+
ReflectionClass::__construct() expects exactly 1 parameter, 2 given
6657
Class X does not exist

ext/reflection/tests/ReflectionClass_getConstant_error.phpt

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,14 @@ class C {
88

99
$rc = new ReflectionClass("C");
1010
echo "Check invalid params:\n";
11-
var_dump($rc->getConstant());
12-
var_dump($rc->getConstant("myConst", "myConst"));
1311
var_dump($rc->getConstant(null));
1412
var_dump($rc->getConstant(1));
1513
var_dump($rc->getConstant(1.5));
1614
var_dump($rc->getConstant(true));
17-
var_dump($rc->getConstant(array(1,2,3)));
18-
var_dump($rc->getConstant(new C));
1915
?>
20-
--EXPECTF--
16+
--EXPECT--
2117
Check invalid params:
22-
23-
Warning: ReflectionClass::getConstant() expects exactly 1 parameter, 0 given in %s on line 8
24-
NULL
25-
26-
Warning: ReflectionClass::getConstant() expects exactly 1 parameter, 2 given in %s on line 9
27-
NULL
2818
bool(false)
2919
bool(false)
3020
bool(false)
3121
bool(false)
32-
33-
Warning: ReflectionClass::getConstant() expects parameter 1 to be string, array given in %s on line 14
34-
NULL
35-
36-
Warning: ReflectionClass::getConstant() expects parameter 1 to be string, object given in %s on line 15
37-
NULL

ext/reflection/tests/ReflectionClass_getMethod_002.phpt

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ $rc = new ReflectionClass("C");
1313
echo "Check invalid params:\n";
1414
try {
1515
var_dump($rc->getMethod());
16-
} catch (Exception $e) {
16+
} catch (TypeError $e) {
1717
echo $e->getMessage() . "\n";
1818
}
1919
try {
2020
var_dump($rc->getMethod("f", "f"));
21-
} catch (Exception $e) {
21+
} catch (TypeError $e) {
2222
echo $e->getMessage() . "\n";
2323
}
2424
try {
@@ -43,32 +43,24 @@ try {
4343
}
4444
try {
4545
var_dump($rc->getMethod(array(1,2,3)));
46-
} catch (Exception $e) {
46+
} catch (TypeError $e) {
4747
echo $e->getMessage() . "\n";
4848
}
4949
try {
5050
var_dump($rc->getMethod(new C));
51-
} catch (Exception $e) {
51+
} catch (TypeError $e) {
5252
echo $e->getMessage() . "\n";
5353
}
5454

5555

5656
?>
57-
--EXPECTF--
57+
--EXPECT--
5858
Check invalid params:
59-
60-
Warning: ReflectionClass::getMethod() expects exactly 1 parameter, 0 given in %s on line 9
61-
NULL
62-
63-
Warning: ReflectionClass::getMethod() expects exactly 1 parameter, 2 given in %s on line 14
64-
NULL
59+
ReflectionClass::getMethod() expects exactly 1 parameter, 0 given
60+
ReflectionClass::getMethod() expects exactly 1 parameter, 2 given
6561
Method does not exist
6662
Method 1 does not exist
6763
Method 1.5 does not exist
6864
Method 1 does not exist
69-
70-
Warning: ReflectionClass::getMethod() expects parameter 1 to be string, array given in %s on line 39
71-
NULL
72-
73-
Warning: ReflectionClass::getMethod() expects parameter 1 to be string, object given in %s on line 44
74-
NULL
65+
ReflectionClass::getMethod() expects parameter 1 to be string, array given
66+
ReflectionClass::getMethod() expects parameter 1 to be string, object given

ext/reflection/tests/ReflectionClass_getParentClass.phpt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@ class Foo {}
1010

1111
class Bar extends Foo {}
1212

13-
$rc1 = new ReflectionClass("Bar");
14-
var_dump($rc1->getParentClass());
13+
$rc = new ReflectionClass("Bar");
14+
$parent = $rc->getParentClass();
15+
$grandParent = $parent->getParentClass();
16+
var_dump($parent, $grandParent);
1517
?>
1618
--EXPECTF--
1719
object(ReflectionClass)#%d (1) {
1820
["name"]=>
1921
string(3) "Foo"
2022
}
23+
bool(false)

ext/reflection/tests/ReflectionClass_getParentClass_001.phpt

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

ext/reflection/tests/ReflectionClass_getProperty_002.phpt

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ $rc = new ReflectionClass("C");
1313
echo "Check invalid params:\n";
1414
try {
1515
var_dump($rc->getProperty());
16-
} catch (exception $e) {
16+
} catch (TypeError $e) {
1717
echo $e->getMessage() . "\n";
1818
}
1919
try {
2020
var_dump($rc->getProperty("a", "a"));
21-
} catch (exception $e) {
21+
} catch (TypeError $e) {
2222
echo $e->getMessage() . "\n";
2323
}
2424
try {
@@ -43,30 +43,22 @@ try {
4343
}
4444
try {
4545
var_dump($rc->getProperty(array(1,2,3)));
46-
} catch (exception $e) {
46+
} catch (TypeError $e) {
4747
echo $e->getMessage() . "\n";
4848
}
4949
try {
5050
var_dump($rc->getProperty(new C));
51-
} catch (exception $e) {
51+
} catch (TypeError $e) {
5252
echo $e->getMessage() . "\n";
5353
}
5454
?>
55-
--EXPECTF--
55+
--EXPECT--
5656
Check invalid params:
57-
58-
Warning: ReflectionClass::getProperty() expects exactly 1 parameter, 0 given in %s on line 9
59-
NULL
60-
61-
Warning: ReflectionClass::getProperty() expects exactly 1 parameter, 2 given in %s on line 14
62-
NULL
57+
ReflectionClass::getProperty() expects exactly 1 parameter, 0 given
58+
ReflectionClass::getProperty() expects exactly 1 parameter, 2 given
6359
Property does not exist
6460
Property 1 does not exist
6561
Property 1.5 does not exist
6662
Property 1 does not exist
67-
68-
Warning: ReflectionClass::getProperty() expects parameter 1 to be string, array given in %s on line 39
69-
NULL
70-
71-
Warning: ReflectionClass::getProperty() expects parameter 1 to be string, object given in %s on line 44
72-
NULL
63+
ReflectionClass::getProperty() expects parameter 1 to be string, array given
64+
ReflectionClass::getProperty() expects parameter 1 to be string, object given

ext/reflection/tests/ReflectionClass_getStaticPropertyValue_002.phpt

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ class C {
1212
$rc = new ReflectionClass('C');
1313
try {
1414
var_dump($rc->getStaticPropertyValue("x", "default value", 'blah'));
15-
} catch (Exception $e) {
15+
} catch (TypeError $e) {
1616
echo $e->getMessage() . "\n";
1717
}
1818
try {
1919
var_dump($rc->getStaticPropertyValue());
20-
} catch (Exception $e) {
20+
} catch (TypeError $e) {
2121
echo $e->getMessage() . "\n";
2222
}
2323
try {
@@ -32,20 +32,15 @@ try {
3232
}
3333
try {
3434
var_dump($rc->getStaticPropertyValue(array(1,2,3)));
35-
} catch (Exception $e) {
35+
} catch (TypeError $e) {
3636
echo $e->getMessage() . "\n";
3737
}
3838

3939

4040
?>
41-
--EXPECTF--
42-
Warning: ReflectionClass::getStaticPropertyValue() expects at most 2 parameters, 3 given in %s on line 8
43-
NULL
44-
45-
Warning: ReflectionClass::getStaticPropertyValue() expects at least 1 parameter, 0 given in %s on line 13
46-
NULL
41+
--EXPECT--
42+
ReflectionClass::getStaticPropertyValue() expects at most 2 parameters, 3 given
43+
ReflectionClass::getStaticPropertyValue() expects at least 1 parameter, 0 given
4744
Class C does not have a property named
4845
string(3) "def"
49-
50-
Warning: ReflectionClass::getStaticPropertyValue() expects parameter 1 to be string, array given in %s on line 28
51-
NULL
46+
ReflectionClass::getStaticPropertyValue() expects parameter 1 to be string, array given

ext/reflection/tests/ReflectionClass_hasConstant_002.phpt

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,14 @@ class C {
1111

1212
$rc = new ReflectionClass("C");
1313
echo "Check invalid params:\n";
14-
var_dump($rc->hasConstant());
15-
var_dump($rc->hasConstant("myConst", "myConst"));
1614
var_dump($rc->hasConstant(null));
1715
var_dump($rc->hasConstant(1));
1816
var_dump($rc->hasConstant(1.5));
1917
var_dump($rc->hasConstant(true));
20-
var_dump($rc->hasConstant(array(1,2,3)));
21-
var_dump($rc->hasConstant(new C));
2218
?>
23-
--EXPECTF--
19+
--EXPECT--
2420
Check invalid params:
25-
26-
Warning: ReflectionClass::hasConstant() expects exactly 1 parameter, 0 given in %s on line 8
27-
NULL
28-
29-
Warning: ReflectionClass::hasConstant() expects exactly 1 parameter, 2 given in %s on line 9
30-
NULL
3121
bool(false)
3222
bool(false)
3323
bool(false)
3424
bool(false)
35-
36-
Warning: ReflectionClass::hasConstant() expects parameter 1 to be string, array given in %s on line 14
37-
NULL
38-
39-
Warning: ReflectionClass::hasConstant() expects parameter 1 to be string, object given in %s on line 15
40-
NULL

ext/reflection/tests/ReflectionClass_hasMethod_002.phpt

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,14 @@ class C {
1111

1212
$rc = new ReflectionClass("C");
1313
echo "Check invalid params:\n";
14-
var_dump($rc->hasMethod());
15-
var_dump($rc->hasMethod("f", "f"));
1614
var_dump($rc->hasMethod(null));
1715
var_dump($rc->hasMethod(1));
1816
var_dump($rc->hasMethod(1.5));
1917
var_dump($rc->hasMethod(true));
20-
var_dump($rc->hasMethod(array(1,2,3)));
21-
var_dump($rc->hasMethod(new C));
2218
?>
23-
--EXPECTF--
19+
--EXPECT--
2420
Check invalid params:
25-
26-
Warning: ReflectionClass::hasMethod() expects exactly 1 parameter, 0 given in %s on line 8
27-
NULL
28-
29-
Warning: ReflectionClass::hasMethod() expects exactly 1 parameter, 2 given in %s on line 9
30-
NULL
3121
bool(false)
3222
bool(false)
3323
bool(false)
3424
bool(false)
35-
36-
Warning: ReflectionClass::hasMethod() expects parameter 1 to be string, array given in %s on line 14
37-
NULL
38-
39-
Warning: ReflectionClass::hasMethod() expects parameter 1 to be string, object given in %s on line 15
40-
NULL

ext/reflection/tests/ReflectionClass_hasProperty_002.phpt

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,14 @@ class C {
1111

1212
$rc = new ReflectionClass("C");
1313
echo "Check invalid params:\n";
14-
var_dump($rc->hasProperty());
15-
var_dump($rc->hasProperty("a", "a"));
1614
var_dump($rc->hasProperty(null));
1715
var_dump($rc->hasProperty(1));
1816
var_dump($rc->hasProperty(1.5));
1917
var_dump($rc->hasProperty(true));
20-
var_dump($rc->hasProperty(array(1,2,3)));
21-
var_dump($rc->hasProperty(new C));
2218
?>
2319
--EXPECTF--
2420
Check invalid params:
25-
26-
Warning: ReflectionClass::hasProperty() expects exactly 1 parameter, 0 given in %s on line 8
27-
NULL
28-
29-
Warning: ReflectionClass::hasProperty() expects exactly 1 parameter, 2 given in %s on line 9
30-
NULL
3121
bool(false)
3222
bool(false)
3323
bool(false)
3424
bool(false)
35-
36-
Warning: ReflectionClass::hasProperty() expects parameter 1 to be string, array given in %s on line 14
37-
NULL
38-
39-
Warning: ReflectionClass::hasProperty() expects parameter 1 to be string, object given in %s on line 15
40-
NULL

0 commit comments

Comments
 (0)