Skip to content

Commit

Permalink
Sync reflectionproperty hooks with EN
Browse files Browse the repository at this point in the history
  • Loading branch information
Fan2Shrek committed Feb 22, 2025
1 parent 2fba1af commit 62702cd
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 13 deletions.
14 changes: 13 additions & 1 deletion reference/reflection/reflectionproperty/gethook.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: e0e74c05cb704b614ff6925552884fbffb26bb53 Maintainer: Fan2Shrek Status: ready -->
<!-- EN-Revision: 366a10b130d66855054ea80d3b30e50124926a35 Maintainer: Fan2Shrek Status: ready -->
<!-- Reviewed: yes -->
<refentry xml:id="reflectionproperty.gethook" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
Expand Down Expand Up @@ -59,6 +59,18 @@ var_dump($rProp->getHook(PropertyHookType::Set));
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
object(ReflectionMethod)#4 (2) {
["name"]=>
string(10) "$name::get"
["class"]=>
string(7) "Example"
}
NULL
]]>
</screen>
</example>
</refsect1>

Expand Down
18 changes: 17 additions & 1 deletion reference/reflection/reflectionproperty/gethooks.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: e0e74c05cb704b614ff6925552884fbffb26bb53 Maintainer: Fan2Shrek Status: ready -->
<!-- EN-Revision: a16ad380e58039833f84dac4ad95893104868338 Maintainer: Fan2Shrek Status: ready -->
<!-- Reviewed: yes -->
<refentry xml:id="reflectionproperty.gethooks" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
Expand Down Expand Up @@ -59,6 +59,22 @@ var_dump($rProp->getHooks());
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
array(1) {
["get"]=>
object(ReflectionMethod)#3 (2) {
["name"]=>
string(10) "$name::get"
["class"]=>
string(7) "Example"
}
}
array(0) {
}
]]>
</screen>
</example>
</refsect1>

Expand Down
18 changes: 14 additions & 4 deletions reference/reflection/reflectionproperty/getrawvalue.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: e0e74c05cb704b614ff6925552884fbffb26bb53 Maintainer: Fan2Shrek Status: ready -->
<!-- EN-Revision: 49ef347a18b037370b6bd8e690096270f1780153 Maintainer: Fan2Shrek Status: ready -->
<!-- Reviewed: yes -->
<refentry xml:id="reflectionproperty.getrawvalue" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
Expand Down Expand Up @@ -69,14 +69,24 @@ $rClass = new \ReflectionClass(Example::class);
$rProp = $rClass->getProperty('tag');
// Ceci passerait par le hook get, produisant donc "php".
print $example->tag;
print $rProp->getValue($example);
echo $example->tag;
echo "\n";
echo $rProp->getValue($example);
echo "\n";
// Mais ceci contournerait le hook et produirait "PHP".
print $rProp->setRawValue($example);
echo $rProp->getRawValue($example);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
php
php
PHP
]]>
</screen>
</example>
</refsect1>

Expand Down
14 changes: 13 additions & 1 deletion reference/reflection/reflectionproperty/getsettabletype.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: e0e74c05cb704b614ff6925552884fbffb26bb53 Maintainer: Fan2Shrek Status: ready -->
<!-- EN-Revision: a16ad380e58039833f84dac4ad95893104868338 Maintainer: Fan2Shrek Status: ready -->
<!-- Reviewed: yes -->
<refentry xml:id="reflectionproperty.getsettabletype" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
Expand Down Expand Up @@ -80,6 +80,18 @@ var_dump($rClass->getProperty('untyped')->getSettableType());
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
object(ReflectionNamedType)#3 (0) {
}
object(ReflectionUnionType)#2 (0) {
}
object(ReflectionNamedType)#3 (0) {
}
NULL
]]>
</screen>
</example>
</refsect1>

Expand Down
9 changes: 8 additions & 1 deletion reference/reflection/reflectionproperty/hashook.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: e0e74c05cb704b614ff6925552884fbffb26bb53 Maintainer: Fan2Shrek Status: ready -->
<!-- EN-Revision: a16ad380e58039833f84dac4ad95893104868338 Maintainer: Fan2Shrek Status: ready -->
<!-- Reviewed: yes -->
<refentry xml:id="reflectionproperty.hashook" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
Expand Down Expand Up @@ -58,6 +58,13 @@ var_dump($rProp->hasHook(PropertyHookType::Set));
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
bool(true)
bool(false)
]]>
</screen>
</example>
</refsect1>

Expand Down
9 changes: 8 additions & 1 deletion reference/reflection/reflectionproperty/hashooks.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: e0e74c05cb704b614ff6925552884fbffb26bb53 Maintainer: Fan2Shrek Status: ready -->
<!-- EN-Revision: a16ad380e58039833f84dac4ad95893104868338 Maintainer: Fan2Shrek Status: ready -->
<!-- Reviewed: yes -->
<refentry xml:id="reflectionproperty.hashooks" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
Expand Down Expand Up @@ -51,6 +51,13 @@ var_dump($rClass->getProperty('none')->hasHooks());
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
bool(true)
bool(false)
]]>
</screen>
</example>
</refsect1>

Expand Down
10 changes: 9 additions & 1 deletion reference/reflection/reflectionproperty/isfinal.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: e0e74c05cb704b614ff6925552884fbffb26bb53 Maintainer: Fan2Shrek Status: ready -->
<!-- EN-Revision: a16ad380e58039833f84dac4ad95893104868338 Maintainer: Fan2Shrek Status: ready -->
<!-- Reviewed: yes -->
<refentry xml:id="reflectionproperty.isfinal" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
Expand Down Expand Up @@ -60,6 +60,14 @@ var_dump($rClass->getProperty('job')->isFinal());
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
bool(false)
bool(true)
bool(true)
]]>
</screen>
</example>
</refsect1>

Expand Down
10 changes: 9 additions & 1 deletion reference/reflection/reflectionproperty/isvirtual.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: e0e74c05cb704b614ff6925552884fbffb26bb53 Maintainer: Fan2Shrek Status: ready -->
<!-- EN-Revision: a16ad380e58039833f84dac4ad95893104868338 Maintainer: Fan2Shrek Status: ready -->
<!-- Reviewed: yes -->
<refentry xml:id="reflectionproperty.isvirtual" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
Expand Down Expand Up @@ -66,6 +66,14 @@ var_dump($rClass->getProperty('job')->isVirtual());
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
bool(true)
bool(false)
bool(false)
]]>
</screen>
</example>
</refsect1>

Expand Down
22 changes: 20 additions & 2 deletions reference/reflection/reflectionproperty/setrawvalue.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: e0e74c05cb704b614ff6925552884fbffb26bb53 Maintainer: Fan2Shrek Status: ready -->
<!-- EN-Revision: 49ef347a18b037370b6bd8e690096270f1780153 Maintainer: Fan2Shrek Status: ready -->
<!-- Reviewed: yes -->
<refentry xml:id="reflectionproperty.setrawvalue" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
Expand Down Expand Up @@ -82,13 +82,31 @@ $rProp = $rClass->getProperty('age');
// Ceci passerait par le hook set, et lancerait une exception.
$example->age = -2;
$rProp->setValue($example, -2);
try {
$example->age = -2;
} catch (InvalidArgumentException) {
print "InvalidArgumentException for setting property to -2\n";
}
try {
$rProp->setValue($example, -2);
} catch (InvalidArgumentException) {
print "InvalidArgumentException for using ReflectionProperty::setValue() with -2\n";
}
// Mais cela définirait $age à -2 sans erreur.
$rProp->setRawValue($example, -2);
echo $example->age;
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
InvalidArgumentException for setting property to -2
InvalidArgumentException for using ReflectionProperty::setValue() with -2
-2
]]>
</screen>
</example>
</refsect1>

Expand Down

0 comments on commit 62702cd

Please sign in to comment.