Annotation of embedaddon/php/ext/reflection/tests/ReflectionClass_getProperty_002.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: ReflectionClass::getProperty() - error cases
3: --CREDITS--
4: Robin Fernandes <robinf@php.net>
5: Steve Seear <stevseea@php.net>
6: --FILE--
7: <?php
8: class C {
9: public $a;
10: }
11:
12: $rc = new ReflectionClass("C");
13: echo "Check invalid params:\n";
14: try {
15: var_dump($rc->getProperty());
16: } catch (exception $e) {
17: echo $e->getMessage() . "\n";
18: }
19: try {
20: var_dump($rc->getProperty("a", "a"));
21: } catch (exception $e) {
22: echo $e->getMessage() . "\n";
23: }
24: try {
25: var_dump($rc->getProperty(null));
26: } catch (exception $e) {
27: echo $e->getMessage() . "\n";
28: }
29: try {
30: var_dump($rc->getProperty(1));
31: } catch (exception $e) {
32: echo $e->getMessage() . "\n";
33: }
34: try {
35: var_dump($rc->getProperty(1.5));
36: } catch (exception $e) {
37: echo $e->getMessage() . "\n";
38: }
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 (exception $e) {
47: echo $e->getMessage() . "\n";
48: }
49: try {
50: var_dump($rc->getProperty(new C));
51: } catch (exception $e) {
52: echo $e->getMessage() . "\n";
53: }
54: ?>
55: --EXPECTF--
56: 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
63: Property does not exist
64: Property 1 does not exist
65: Property 1.5 does not exist
66: 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
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>