Skip to content

Commit

Permalink
Make examples generate output.
Browse files Browse the repository at this point in the history
  • Loading branch information
Crell committed Dec 14, 2024
1 parent 56a73e5 commit a204b11
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 33 deletions.
4 changes: 2 additions & 2 deletions reference/reflection/reflectionproperty/gethook.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class Example
$rClass = new \ReflectionClass(Example::class);
$rProp = $rClass->getProperty('name');
$rProp->getHook(PropertyHookType::Get); // Returns an instance of \ReflectionMethod.
$rProp->getHook(PropertyHookType::Set); // Returns null.
var_dump($rProp->getHook(PropertyHookType::Get));
var_dump($rProp->getHook(PropertyHookType::Set));
?>
]]>
</programlisting>
Expand Down
7 changes: 3 additions & 4 deletions reference/reflection/reflectionproperty/gethooks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,12 @@ class Example
}
$rClass = new \ReflectionClass(Example::class);
$rProp = $rClass->getProperty('name');
// Returns ['get' => ReflectionMethod()]
$rProp->getHooks();
var_dump($rProp->getHooks());
$rProp = $rClass->getProperty('count');
// Returns []
$rProp->getHooks();
var_dump($rProp->getHooks());
?>
]]>
</programlisting>
Expand Down
20 changes: 4 additions & 16 deletions reference/reflection/reflectionproperty/getsettabletype.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,26 +70,14 @@ class Example
}
$rClass = new \ReflectionClass(Example::class);
// No set-type defined, so returns ReflectionType('string')
$rType = $rClass->getProperty('basic')->getSettableType();
// A set-type is defined, so returns ReflectionUnionType('string|Sstringable')
$rType = $rClass->getProperty('wider')->getSettableType();
// Virtual property, so returns ReflectionUnionType('never')
$rType = $rClass->getProperty('virtual')->getSettableType();
// Untyped property, so returns null
$rType = $rClass->getProperty('untyped')->getSettableType();
var_dump($rClass->getProperty('basic')->getSettableType());
var_dump($rClass->getProperty('wider')->getSettableType());
var_dump($rClass->getProperty('virtual')->getSettableType());
var_dump($rClass->getProperty('untyped')->getSettableType());
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Code example
]]>
</screen>
</example>
</refsect1>

Expand Down
4 changes: 2 additions & 2 deletions reference/reflection/reflectionproperty/hashook.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ class Example
$rClass = new \ReflectionClass(Example::class);
$rProp = $rClass->getProperty('name');
$rProp->hasHook(PropertyHookType::Get); // Returns true
$rProp->hasHook(PropertyHookType::Set); // Returns false
var_dump($rProp->hasHook(PropertyHookType::Get));
var_dump($rProp->hasHook(PropertyHookType::Set));
?>
]]>
</programlisting>
Expand Down
4 changes: 2 additions & 2 deletions reference/reflection/reflectionproperty/hashooks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ class Example
}
$rClass = new \ReflectionClass(Example::class);
$rClass->getProperty('name')->hasHooks(); // Returns true
$rClass->getProperty('none')->hasHooks(); // Returns false
var_dump($rClass->getProperty('name')->hasHooks());
var_dump($rClass->getProperty('none')->hasHooks());
?>
]]>
</programlisting>
Expand Down
7 changes: 4 additions & 3 deletions reference/reflection/reflectionproperty/isfinal.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ class Example
}
$rClass = new \ReflectionClass(Example::class);
$rType = $rClass->getProperty('name')->isFinal(); // False
$rType = $rClass->getProperty('age')->isFinal(); // True
$rType = $rClass->getProperty('job')->isFinal(); // True, implicitly.
var_dump($rClass->getProperty('name')->isFinal());
var_dump($rClass->getProperty('age')->isFinal());
var_dump($rClass->getProperty('job')->isFinal());
?>
]]>
</programlisting>
Expand Down
1 change: 0 additions & 1 deletion reference/reflection/reflectionproperty/isprotectedset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<modifier>public</modifier> <type>bool</type><methodname>ReflectionProperty::isProtectedSet</methodname>
<void/>
</methodsynopsis>
&warn.undocumented.func;
<simpara>
Checks whether the property is protected for writing.
</simpara>
Expand Down
6 changes: 3 additions & 3 deletions reference/reflection/reflectionproperty/isvirtual.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ class Example
$rClass = new \ReflectionClass(Example::class);
$rClass->getProperty('name')->isVirtual(); // True
$rClass->getProperty('age')->isVirtual(); // False
$rClass->getProperty('job')->isVirtual(); // False
var_dump($rClass->getProperty('name')->isVirtual());
var_dump($rClass->getProperty('age')->isVirtual());
var_dump($rClass->getProperty('job')->isVirtual());
?>
]]>
</programlisting>
Expand Down

0 comments on commit a204b11

Please sign in to comment.