Skip to content

Document Dom\TokenList #4306

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 21, 2024
Merged
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
21 changes: 21 additions & 0 deletions language-snippets.ent
Original file line number Diff line number Diff line change
Expand Up @@ -1677,6 +1677,27 @@ it is inserted with (e.g.) <function xmlns="http://docbook.org/ns/docbook">DOMNo
resulting HTML.
</simpara>
</warning>'>
<!ENTITY dom.tokenlist.errors '<itemizedlist xmlns="http://docbook.org/ns/docbook">
<listitem>
<simpara>
Throws a <exceptionname>ValueError</exceptionname> if
a token contains any null bytes.
</simpara>
</listitem>
<listitem>
<simpara>
Throws a <exceptionname>Dom\DOMException</exceptionname> with code
<constant>Dom\SYNTAX_ERR</constant> if a token is the empty string.
</simpara>
</listitem>
<listitem>
<simpara>
Throws a <exceptionname>Dom\DOMException</exceptionname> with code
<constant>Dom\INVALID_CHARACTER_ERR</constant> if a token contains any
ASCII whitespace.
</simpara>
</listitem>
</itemizedlist>'>



Expand Down
13 changes: 7 additions & 6 deletions reference/dom/dom/dom-tokenlist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,9 @@
</fieldsynopsis>

<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
<classsynopsisinfo role="comment">Not documented yet</classsynopsisinfo>
<!--<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.dom-tokenlist')/db:refentry/db:refsect1[@role='description']/descendant::db:constructorsynopsis[@role='Dom\\TokenList'])">
<xi:fallback/>
</xi:include>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.dom-tokenlist')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[@role='Dom\\TokenList'])">
<xi:fallback/>
</xi:include>-->
</xi:include>
</classsynopsis>
</section>

Expand All @@ -76,10 +72,15 @@
<section role="notes">
&reftitle.notes;
&dom.note.modern.utf8;
<note>
<simpara>
Tokens in the list can be accessed by array syntax.
</simpara>
</note>
</section>

</partintro>

<!-- &reference.dom.dom.entities.tokenlist; -->
&reference.dom.dom.entities.tokenlist;

</reference>
94 changes: 94 additions & 0 deletions reference/dom/dom/tokenlist/add.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?xml version="1.0" encoding="utf-8"?>
<refentry xml:id="dom-tokenlist.add" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>Dom\TokenList::add</refname>
<refpurpose>Adds the given tokens to the list</refpurpose>
</refnamediv>

<refsect1 role="description">
&reftitle.description;
<methodsynopsis role="Dom\\TokenList">
<modifier>public</modifier> <type>void</type><methodname>Dom\TokenList::add</methodname>
<methodparam rep="repeat"><type>string</type><parameter>tokens</parameter></methodparam>
</methodsynopsis>
<simpara>
Adds the given <parameter>tokens</parameter> to the list, but not any that
were already present.
</simpara>
</refsect1>

<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>tokens</parameter></term>
<listitem>
<simpara>
The tokens to add.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</refsect1>

<refsect1 role="returnvalues">
&reftitle.returnvalues;
<simpara>
&return.void;
</simpara>
</refsect1>

<refsect1 role="errors">
&reftitle.errors;
&dom.tokenlist.errors;
</refsect1>

<refsect1 role="examples">
&reftitle.examples;
<example xml:id="dom-tokenlist.add.example.basic">
<title><methodname>Dom\TokenList::add</methodname> example</title>
<simpara>
Adds two classes to a newly created paragraph element.
</simpara>
<programlisting role="php">
<![CDATA[
<?php
$dom = Dom\HTMLDocument::createEmpty();
$p = $dom->createElement('p');

$classList = $p->classList;
$classList->add('font-bold', 'important');

echo $dom->saveHtml($p);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
<p class="font-bold important"></p>
]]>
</screen>
</example>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
91 changes: 91 additions & 0 deletions reference/dom/dom/tokenlist/contains.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="utf-8"?>
<refentry xml:id="dom-tokenlist.contains" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>Dom\TokenList::contains</refname>
<refpurpose>Returns whether the list contains a given token</refpurpose>
</refnamediv>

<refsect1 role="description">
&reftitle.description;
<methodsynopsis role="Dom\\TokenList">
<modifier>public</modifier> <type>bool</type><methodname>Dom\TokenList::contains</methodname>
<methodparam><type>string</type><parameter>token</parameter></methodparam>
</methodsynopsis>
<simpara>
Returns whether the list contains <parameter>token</parameter>.
</simpara>
</refsect1>

<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>token</parameter></term>
<listitem>
<simpara>
The token.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</refsect1>

<refsect1 role="returnvalues">
&reftitle.returnvalues;
<simpara>
Returns &true; if the list contains <parameter>token</parameter>,
&false; otherwise.
</simpara>
</refsect1>

<refsect1 role="examples">
&reftitle.examples;
<example xml:id="dom-tokenlist.contains.example.basic">
<title><methodname>Dom\TokenList::contains</methodname> example</title>
<simpara>
Checks whether two classes are present on the paragraph.
</simpara>
<programlisting role="php">
<![CDATA[
<?php
$dom = Dom\HTMLDocument::createFromString('<p class="font-bold important"></p>', LIBXML_NOERROR);
$p = $dom->body->firstChild;

$classList = $p->classList;
var_dump(
$classList->contains('important'),
$classList->contains('font-small'),
);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
bool(true)
bool(false)
]]>
</screen>
</example>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
50 changes: 50 additions & 0 deletions reference/dom/dom/tokenlist/count.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<refentry xml:id="dom-tokenlist.count" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>Dom\TokenList::count</refname>
<refpurpose>Returns the number of tokens in the list</refpurpose>
</refnamediv>

<refsect1 role="description">
&reftitle.description;
<methodsynopsis role="Dom\\TokenList">
<modifier>public</modifier> <type>int</type><methodname>Dom\TokenList::count</methodname>
<void/>
</methodsynopsis>
<simpara>
Returns the number of tokens in the list.
</simpara>
</refsect1>

<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>

<refsect1 role="returnvalues">
&reftitle.returnvalues;
<simpara>
The number of tokens in the list.
</simpara>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
50 changes: 50 additions & 0 deletions reference/dom/dom/tokenlist/getiterator.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<refentry xml:id="dom-tokenlist.getiterator" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>Dom\TokenList::getIterator</refname>
<refpurpose>Returns an iterator over the token list</refpurpose>
</refnamediv>

<refsect1 role="description">
&reftitle.description;
<methodsynopsis role="Dom\\TokenList">
<modifier>public</modifier> <type>Iterator</type><methodname>Dom\TokenList::getIterator</methodname>
<void/>
</methodsynopsis>
<simpara>
Returns an iterator over the token list.
</simpara>
</refsect1>

<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>

<refsect1 role="returnvalues">
&reftitle.returnvalues;
<simpara>
An iterator over the token list.
</simpara>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
Loading
Loading