Skip to content

Commit a16ad38

Browse files
ADmadGirgias
authored andcommitted
Add output for examples of ReflectionProperty methods.
1 parent 5677887 commit a16ad38

File tree

9 files changed

+100
-3
lines changed

9 files changed

+100
-3
lines changed

reference/reflection/reflectionproperty/gethook.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,18 @@ var_dump($rProp->getHook(PropertyHookType::Set));
5757
?>
5858
]]>
5959
</programlisting>
60+
&example.outputs;
61+
<screen>
62+
<![CDATA[
63+
object(ReflectionMethod)#4 (2) {
64+
["name"]=>
65+
string(10) "$name::get"
66+
["class"]=>
67+
string(7) "Example"
68+
}
69+
NULL
70+
]]>
71+
</screen>
6072
</example>
6173
</refsect1>
6274

reference/reflection/reflectionproperty/gethooks.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,22 @@ var_dump($rProp->getHooks());
5757
?>
5858
]]>
5959
</programlisting>
60+
&example.outputs;
61+
<screen>
62+
<![CDATA[
63+
array(1) {
64+
["get"]=>
65+
object(ReflectionMethod)#3 (2) {
66+
["name"]=>
67+
string(10) "$name::get"
68+
["class"]=>
69+
string(7) "Example"
70+
}
71+
}
72+
array(0) {
73+
}
74+
]]>
75+
</screen>
6076
</example>
6177
</refsect1>
6278

reference/reflection/reflectionproperty/getrawvalue.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,23 @@ $rProp = $rClass->getProperty('tag');
6868
6969
// These would go through the get hook, so would produce "php".
7070
print $example->tag;
71+
print "\n";
7172
print $rProp->getValue($example);
73+
print "\n";
7274
7375
// But this would bypass the hook and produce "PHP".
74-
print $rProp->setRawValue($example);
76+
print $rProp->getRawValue($example);
7577
?>
7678
]]>
7779
</programlisting>
80+
&example.outputs;
81+
<screen>
82+
<![CDATA[
83+
php
84+
php
85+
PHP
86+
]]>
87+
</screen>
7888
</example>
7989
</refsect1>
8090

reference/reflection/reflectionproperty/getsettabletype.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,18 @@ var_dump($rClass->getProperty('untyped')->getSettableType());
7878
?>
7979
]]>
8080
</programlisting>
81+
&example.outputs;
82+
<screen>
83+
<![CDATA[
84+
object(ReflectionNamedType)#3 (0) {
85+
}
86+
object(ReflectionUnionType)#2 (0) {
87+
}
88+
object(ReflectionNamedType)#3 (0) {
89+
}
90+
NULL
91+
]]>
92+
</screen>
8193
</example>
8294
</refsect1>
8395

reference/reflection/reflectionproperty/hashook.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ var_dump($rProp->hasHook(PropertyHookType::Set));
5656
?>
5757
]]>
5858
</programlisting>
59+
&example.outputs;
60+
<screen>
61+
<![CDATA[
62+
bool(true)
63+
bool(false)
64+
]]>
65+
</screen>
5966
</example>
6067
</refsect1>
6168

reference/reflection/reflectionproperty/hashooks.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ var_dump($rClass->getProperty('none')->hasHooks());
4949
?>
5050
]]>
5151
</programlisting>
52+
&example.outputs;
53+
<screen>
54+
<![CDATA[
55+
bool(true)
56+
bool(false)
57+
]]>
58+
</screen>
5259
</example>
5360
</refsect1>
5461

reference/reflection/reflectionproperty/isfinal.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ var_dump($rClass->getProperty('job')->isFinal());
5858
?>
5959
]]>
6060
</programlisting>
61+
&example.outputs;
62+
<screen>
63+
<![CDATA[
64+
bool(false)
65+
bool(true)
66+
bool(true)
67+
]]>
68+
</screen>
6169
</example>
6270
</refsect1>
6371

reference/reflection/reflectionproperty/isvirtual.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ var_dump($rClass->getProperty('job')->isVirtual());
6464
?>
6565
]]>
6666
</programlisting>
67+
&example.outputs;
68+
<screen>
69+
<![CDATA[
70+
bool(true)
71+
bool(false)
72+
bool(false)
73+
]]>
74+
</screen>
6775
</example>
6876
</refsect1>
6977

reference/reflection/reflectionproperty/setrawvalue.xml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,31 @@ $rClass = new \ReflectionClass(Example::class);
7979
$rProp = $rClass->getProperty('age');
8080
8181
// These would go through the set hook, and throw an exception.
82-
$example->age = -2;
83-
$rProp->setValue($example, -2);
82+
try {
83+
$example->age = -2;
84+
} catch (InvalidArgumentException) {
85+
print "InvalidArgumentException for setting property to -2\n";
86+
}
87+
try {
88+
$rProp->setValue($example, -2);
89+
} catch (InvalidArgumentException) {
90+
print "InvalidArgumentException for using ReflectionProperty::setValue() with -2\n";
91+
}
8492
8593
// But this would set the $age to -2 without error.
8694
$rProp->setRawValue($example, -2);
95+
print $example->age;
8796
?>
8897
]]>
8998
</programlisting>
99+
&example.outputs;
100+
<screen>
101+
<![CDATA[
102+
InvalidArgumentException for setting property to -2
103+
InvalidArgumentException for using ReflectionProperty::setValue() with -2
104+
-2
105+
]]>
106+
</screen>
90107
</example>
91108
</refsect1>
92109

0 commit comments

Comments
 (0)