Skip to content

PHP 8.4: Document SplObjectStorage::seek() #4048

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 7 commits into from
Nov 12, 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
14 changes: 12 additions & 2 deletions reference/spl/arrayiterator/seek.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<refentry xml:id="arrayiterator.seek" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>ArrayIterator::seek</refname>
<refpurpose>Seek to position</refpurpose>
<refpurpose>Seeks to a position</refpurpose>
</refnamediv>

<refsect1 role="description">
Expand All @@ -13,7 +13,9 @@
<methodparam><type>int</type><parameter>offset</parameter></methodparam>
</methodsynopsis>

&warn.undocumented.func;
<simpara>
Seeks to a given position in the iterator.
</simpara>
</refsect1>

<refsect1 role="parameters">
Expand All @@ -39,6 +41,14 @@
</para>
</refsect1>

<refsect1 role="errors">
&reftitle.errors;
<simpara>
Throws an <classname>OutOfBoundsException</classname>
if the <parameter>offset</parameter> is not seekable.
</simpara>
</refsect1>

</refentry>
<!-- Keep this comment at the end of the file
Local variables:
Expand Down
4 changes: 2 additions & 2 deletions reference/spl/seekableiterator/seek.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@

<refsect1 role="errors">
&reftitle.errors;
<para>
<simpara>
Implementations should throw an <classname>OutOfBoundsException</classname>
if the <parameter>offset</parameter> is not seekable.
</para>
</simpara>
</refsect1>

<refsect1 role="examples">
Expand Down
118 changes: 118 additions & 0 deletions reference/spl/splobjectstorage/seek.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<?xml version="1.0" encoding="utf-8"?>
<refentry xml:id="splobjectstorage.seek" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>SplObjectStorage::seek</refname>
<refpurpose>Seeks iterator to a position</refpurpose>
</refnamediv>

<refsect1 role="description">
&reftitle.description;
<methodsynopsis role="SplObjectStorage">
<modifier>public</modifier> <type>void</type><methodname>SplObjectStorage::seek</methodname>
<methodparam><type>int</type><parameter>offset</parameter></methodparam>
</methodsynopsis>

<simpara>
Seeks to a given position in the iterator.
</simpara>
</refsect1>

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

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

<refsect1 role="errors">
&reftitle.errors;
<simpara>
Throws an <classname>OutOfBoundsException</classname>
if the <parameter>offset</parameter> is not seekable.
</simpara>
</refsect1>

<refsect1 role="examples">
&reftitle.examples;
<example xml:id="splobjectstorage.seek.example.basic">
<title><methodname>SplObjectStorage::seek</methodname> example</title>
<simpara>
Seeks to item position 2 in the iterator.
</simpara>
<programlisting role="php">
<![CDATA[
<?php
class Test {
public function __construct(public string $marker) {}
}

$a = new Test("a");
$b = new Test("b");
$c = new Test("c");

$storage = new SplObjectStorage();
$storage[$a] = "first";
$storage[$b] = "second";
$storage[$c] = "third";

$storage->seek(2);
var_dump($storage->key());
var_dump($storage->current());
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
int(2)
object(Test)#3 (1) {
["marker"]=>
string(1) "c"
}
]]>
</screen>
</example>
</refsect1>

<refsect1 role="seealso">
&reftitle.seealso;
<simplelist>
<member><classname>SeekableIterator</classname></member>
</simplelist>
</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
-->
1 change: 1 addition & 0 deletions reference/spl/versions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,7 @@
<function name="splobjectstorage::removeall" from="PHP 5 &gt;= 5.3.0, PHP 7, PHP 8"/>
<function name="splobjectstorage::removeallexcept" from="PHP 5 &gt;= 5.3.6, PHP 7, PHP 8"/>
<function name="splobjectstorage::rewind" from="PHP 5 &gt;= 5.1.0, PHP 7, PHP 8"/>
<function name="splobjectstorage::seek" from="PHP 8 &gt;= 8.4.0"/>
<function name="splobjectstorage::serialize" from="PHP 5 &gt;= 5.2.2, PHP 7, PHP 8"/>
<function name="splobjectstorage::setinfo" from="PHP 5 &gt;= 5.3.0, PHP 7, PHP 8"/>
<function name="splobjectstorage::unserialize" from="PHP 5 &gt;= 5.2.2, PHP 7, PHP 8"/>
Expand Down