Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 27 additions & 10 deletions language/attributes.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<chapter xml:id="language.attributes" xmlns="http://docbook.org/ns/docbook">
<chapter xml:id="language.attributes" xmlns="http://docbook.org/ns/docbook" annotations="interactive">
<title>Attributes</title>
<sect1 xml:id="language.attributes.overview">
<title>Attributes overview</title>
Expand Down Expand Up @@ -30,7 +30,7 @@

<example>
<title>Implementing optional methods of an interface with Attributes</title>
<programlisting role="php">
<programlisting role="php" annotations="non-interactive">
<![CDATA[
<?php
interface ActionHandler
Expand Down Expand Up @@ -121,7 +121,7 @@ executeAction($copyAction);
<example>
<title>Attribute Syntax</title>

<programlisting role="php">
<programlisting role="php" annotations="non-interactive">
<![CDATA[
<?php
// a.php
Expand Down Expand Up @@ -222,7 +222,11 @@ function dumpAttributeData($reflection) {
}

dumpAttributeData(new ReflectionClass(Thing::class));
/*
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
string(11) "MyAttribute"
array(1) {
["value"]=>
Expand All @@ -232,10 +236,8 @@ object(MyAttribute)#3 (1) {
["value"]=>
int(1234)
}
*/

]]>
</programlisting>
</screen>
</example>

<para>
Expand All @@ -250,6 +252,21 @@ object(MyAttribute)#3 (1) {
<programlisting role="php">
<![CDATA[
<?php
#[Attribute]
class MyAttribute
{
public $value;

public function __construct($value)
{
$this->value = $value;
}
}

#[MyAttribute(value: 1234)]
class Thing
{
}

function dumpMyAttributeData($reflection) {
$attributes = $reflection->getAttributes(MyAttribute::class);
Expand Down Expand Up @@ -280,7 +297,7 @@ dumpMyAttributeData(new ReflectionClass(Thing::class));
<example>
<title>Simple Attribute Class</title>

<programlisting role="php">
<programlisting role="php" annotations="non-interactive">
<![CDATA[
<?php

Expand All @@ -305,7 +322,7 @@ class MyAttribute
<example>
<title>Using target specification to restrict where attributes can be used</title>

<programlisting role="php">
<programlisting role="php" annotations="non-interactive">
<![CDATA[
<?php

Expand Down Expand Up @@ -348,7 +365,7 @@ class MyAttribute
<example>
<title>Using IS_REPEATABLE to allow attribute on a declaration multiple times</title>

<programlisting role="php">
<programlisting role="php" annotations="non-interactive">
<![CDATA[
<?php

Expand Down
13 changes: 2 additions & 11 deletions language/generators.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<chapter xml:id="language.generators" xmlns="http://docbook.org/ns/docbook">
<chapter xml:id="language.generators" xmlns="http://docbook.org/ns/docbook" annotations="interactive">
<title>Generators</title>

<sect1 xml:id="language.generators.overview">
Expand Down Expand Up @@ -84,7 +84,6 @@ echo 'Single digit odd numbers from xrange(): ';
foreach (xrange(1, 9, 2) as $number) {
echo "$number ";
}
?>
]]>
</programlisting>
&example.outputs;
Expand Down Expand Up @@ -166,7 +165,6 @@ $generator = gen_one_to_three();
foreach ($generator as $value) {
echo "$value\n";
}
?>
]]>
</programlisting>
&example.outputs;
Expand Down Expand Up @@ -230,7 +228,6 @@ foreach (input_parser($input) as $id => $fields) {
echo " $fields[0]\n";
echo " $fields[1]\n";
}
?>
]]>
</programlisting>
&example.outputs;
Expand Down Expand Up @@ -270,7 +267,6 @@ function gen_three_nulls() {
}

var_dump(iterator_to_array(gen_three_nulls()));
?>
]]>
</programlisting>
&example.outputs;
Expand Down Expand Up @@ -320,7 +316,6 @@ function &gen_reference() {
foreach (gen_reference() as &$number) {
echo (--$number).'... ';
}
?>
]]>
</programlisting>
&example.outputs;
Expand Down Expand Up @@ -386,7 +381,6 @@ function gen() {
}
// pass false as second parameter to get an array [0, 1, 2, 3, 4]
var_dump(iterator_to_array(gen()));
?>
]]>
</programlisting>
&example.outputs;
Expand Down Expand Up @@ -432,7 +426,6 @@ function eight() {
foreach (count_to_ten() as $num) {
echo "$num ";
}
?>
]]>
</programlisting>
&example.outputs;
Expand Down Expand Up @@ -476,7 +469,6 @@ foreach ($gen as $num) {
echo "$num ";
}
echo $gen->getReturn();
?>
]]>
</programlisting>
&example.outputs;
Expand All @@ -501,7 +493,7 @@ echo $gen->getReturn();
</para>

<informalexample>
<programlisting role="php">
<programlisting role="php" annotations="non-interactive">
<![CDATA[
<?php
function getLinesFromFile($fileName) {
Expand Down Expand Up @@ -559,7 +551,6 @@ class LineIterator implements Iterator {
fclose($this->fileHandle);
}
}
?>
]]>
</programlisting>
</informalexample>
Expand Down
Loading