diff --git a/reference/spl/splobjectstorage.xml b/reference/spl/splobjectstorage.xml new file mode 100644 index 0000000000..67335c092e --- /dev/null +++ b/reference/spl/splobjectstorage.xml @@ -0,0 +1,171 @@ + + + + + + The SplObjectStorage class + SplObjectStorage + + + + +
+ &reftitle.intro; + + The SplObjectStorage class provides a map from objects to data or, by + ignoring data, an object set. This dual purpose can be useful in many + cases involving the need to uniquely identify objects. + +
+ + +
+ &reftitle.classsynopsis; + + + + SplObjectStorage + + + + + SplObjectStorage + + + + Countable + + + + Iterator + + + + Traversable + + + + Serializable + + + + ArrayAccess + + + + + Methods + + + + +
+ + +
+ &reftitle.examples; + + + <classname>SplObjectStorage</classname> as a set + +attach($o1); +$s->attach($o2); + +var_dump($s->contains($o1)); +var_dump($s->contains($o2)); +var_dump($s->contains($o3)); + +$s->detach($o2); + +var_dump($s->contains($o1)); +var_dump($s->contains($o2)); +var_dump($s->contains($o3)); +?> +]]> + + &example.outputs; + + + + + + <classname>SplObjectStorage</classname> as a map + + +]]> + + &example.outputs; + + + int(1) + [1]=> + int(2) + [2]=> + int(3) +} +]]> + + + +
+ + +
+ + &reference.spl.entities.splobjectstorage; + +
+ + diff --git a/reference/spl/splobjectstorage/addall.xml b/reference/spl/splobjectstorage/addall.xml new file mode 100644 index 0000000000..c248b9c04b --- /dev/null +++ b/reference/spl/splobjectstorage/addall.xml @@ -0,0 +1,102 @@ + + + + + + SplObjectStorage::addAll + Adds all objects from another storage + + + + &reftitle.description; + + public voidSplObjectStorage::addAll + SplObjectStoragestorage + + + Adds all objects-data pairs from a different storage in the current storage. + + + + + &reftitle.parameters; + + + + storage + + + The storage you want to import. + + + + + + + + + &reftitle.returnvalues; + + &return.void; + + + + + &reftitle.examples; + + + <function>SplObjectStorage::addAll</function> example + +addAll($a); +echo $b[$o]."\n"; +?> +]]> + + &example.outputs.similar; + + + + + + + + + &reftitle.seealso; + + + SplObjectStorage::removeAll + + + + + + + diff --git a/reference/spl/splobjectstorage/attach.xml b/reference/spl/splobjectstorage/attach.xml new file mode 100644 index 0000000000..624a70b593 --- /dev/null +++ b/reference/spl/splobjectstorage/attach.xml @@ -0,0 +1,115 @@ + + + + + + SplObjectStorage::attach + Adds an object in the storage + + + + &reftitle.description; + + public voidSplObjectStorage::attach + objectobject + mixeddata + + + Adds an object inside the storage, and optionaly associate it to some data. + + + + + &reftitle.parameters; + + + + object + + + The object to add. + + + + + data + + + The data to associate with the object. Defaults to &null;. + + + + + + + + + &reftitle.returnvalues; + + &return.void; + + + + + &reftitle.examples; + + + <function>SplObjectStorage::attach</function> example + +attach($o1); // similar to $s[$o1] = NULL; +$s->attach($o2, "hello"); // similar to $s[$o2] = "hello"; + +var_dump($s[$o1]); +var_dump($s[$o2]); + +?> +]]> + + &example.outputs.similar; + + + + + + + + + &reftitle.seealso; + + + SplObjectStorage::detach + SplObjectStorage::offsetSet + + + + + + + diff --git a/reference/spl/splobjectstorage/contains.xml b/reference/spl/splobjectstorage/contains.xml new file mode 100644 index 0000000000..11d710b877 --- /dev/null +++ b/reference/spl/splobjectstorage/contains.xml @@ -0,0 +1,104 @@ + + + + + + SplObjectStorage::contains + Checks if the storage contains a specific object + + + + &reftitle.description; + + public booleanSplObjectStorage::contains + objectobject + + + Checks if the storage contains the object provided. + + + + + &reftitle.parameters; + + + + object + + + The object to look for. + + + + + + + + + &reftitle.returnvalues; + + Returns &true; if the object is in the storage, &false; otherwise. + + + + + &reftitle.examples; + + + <function>SplObjectStorage::contains</function> example + +contains($o1)); +var_dump($s->contains($o2)); +?> +]]> + + &example.outputs.similar; + + + + + + + + + &reftitle.seealso; + + + SplObjectStorage::offsetExists + + + + + + + diff --git a/reference/spl/splobjectstorage/count.xml b/reference/spl/splobjectstorage/count.xml new file mode 100644 index 0000000000..57402ca2bc --- /dev/null +++ b/reference/spl/splobjectstorage/count.xml @@ -0,0 +1,95 @@ + + + + + + SplObjectStorage::count + Returns the number of objects in the storage + + + + &reftitle.description; + + public intSplObjectStorage::count + + + + Counts the number of objects in the storage. + + + + + &reftitle.parameters; + &no.function.parameters; + + + + &reftitle.returnvalues; + + The number of objects in the storage. + + + + + &reftitle.examples; + + + <function>SplObjectStorage::count</function> example + +attach($o1); +$s->attach($o2); +$s->attach($o1); +var_dump($s->count()); +var_dump(count($s)); +?> +]]> + + &example.outputs.similar; + + + + + + + + + &reftitle.seealso; + + + SplObjectStorage::attach + SplObjectStorage::detach + + + + + + + diff --git a/reference/spl/splobjectstorage/current.xml b/reference/spl/splobjectstorage/current.xml new file mode 100644 index 0000000000..2357c3b00d --- /dev/null +++ b/reference/spl/splobjectstorage/current.xml @@ -0,0 +1,111 @@ + + + + + + SplObjectStorage::current + Returns the current storage entry + + + + &reftitle.description; + + public objectSplObjectStorage::current + + + + Returns the current storage entry. + + + + + &reftitle.parameters; + &no.function.parameters; + + + + &reftitle.returnvalues; + + The object at the current iterator position. + + + + + &reftitle.examples; + + + <function>SplObjectStorage::current</function> example + +attach($o1, "d1"); +$s->attach($o2, "d2"); + +$s->rewind(); +while($s->valid()) { + $index = $s->key(); + $object = $s->current(); // similar to current($s) + $data = $s->getInfo(); + + var_dump($object); + var_dump($data); + $s->next(); +} +?> +]]> + + &example.outputs.similar; + + + + + + + + + &reftitle.seealso; + + + SplObjectStorage::rewind + SplObjectStorage::key + SplObjectStorage::next + SplObjectStorage::valid + SplObjectStorage::getInfo + + + + + + + diff --git a/reference/spl/splobjectstorage/detach.xml b/reference/spl/splobjectstorage/detach.xml new file mode 100644 index 0000000000..237706039f --- /dev/null +++ b/reference/spl/splobjectstorage/detach.xml @@ -0,0 +1,103 @@ + + + + + + SplObjectStorage::detach + Removes an object from the storage + + + + &reftitle.description; + + public voidSplObjectStorage::detach + objectobject + + + Removes the object from the storage. + + + + + &reftitle.parameters; + + + + object + + + The object to remove. + + + + + + + + + &reftitle.returnvalues; + + &return.void; + + + + + &reftitle.examples; + + + <function>SplObjectStorage::detach</function> example + +attach($o); +var_dump(count($s)); +$s->detach($o); +var_dump(count($s)); +?> +]]> + + &example.outputs.similar; + + + + + + + + + &reftitle.seealso; + + + SplObjectStorage::attach + SplObjectStorage::removeAll + + + + + + + diff --git a/reference/spl/splobjectstorage/getinfo.xml b/reference/spl/splobjectstorage/getinfo.xml new file mode 100644 index 0000000000..9e7e909136 --- /dev/null +++ b/reference/spl/splobjectstorage/getinfo.xml @@ -0,0 +1,112 @@ + + + + + + SplObjectStorage::getInfo + Returns the data associated with the current iterator entry + + + + &reftitle.description; + + public mixedSplObjectStorage::getInfo + + + + Returns the data, or info, associated with the object pointed by the current iterator position. + + + + + &reftitle.parameters; + &no.function.parameters; + + + + &reftitle.returnvalues; + + The data associated with the current iterator position. + + + + + &reftitle.examples; + + + <function>SplObjectStorage::getInfo</function> example + +attach($o1, "d1"); +$s->attach($o2, "d2"); + +$s->rewind(); +while($s->valid()) { + $index = $s->key(); + $object = $s->current(); // similar to current($s) + $data = $s->getInfo(); + + var_dump($object); + var_dump($data); + $s->next(); +} +?> +]]> + + &example.outputs.similar; + + + + + + + + + &reftitle.seealso; + + + SplObjectStorage::current + SplObjectStorage::rewind + SplObjectStorage::key + SplObjectStorage::next + SplObjectStorage::valid + SplObjectStorage::setInfo + + + + + + + diff --git a/reference/spl/splobjectstorage/key.xml b/reference/spl/splobjectstorage/key.xml new file mode 100644 index 0000000000..1670b8f6f6 --- /dev/null +++ b/reference/spl/splobjectstorage/key.xml @@ -0,0 +1,109 @@ + + + + + + SplObjectStorage::key + Returns the index at which the iterator currently is + + + + &reftitle.description; + + public intSplObjectStorage::key + + + + Returns the index at which the iterator currently is. + + + + + &reftitle.parameters; + &no.function.parameters; + + + + &reftitle.returnvalues; + + The index corresponding to the position of the iterator. + + + + + &reftitle.examples; + + + <function>SplObjectStorage::key</function> example + +attach($o1, "d1"); +$s->attach($o2, "d2"); + +$s->rewind(); +while($s->valid()) { + $index = $s->key(); + $object = $s->current(); // similar to current($s) + + var_dump($index); + var_dump($object); + $s->next(); +} +?> +]]> + + &example.outputs.similar; + + + + + + + + + &reftitle.seealso; + + + SplObjectStorage::rewind + SplObjectStorage::current + SplObjectStorage::next + SplObjectStorage::valid + + + + + + + diff --git a/reference/spl/splobjectstorage/next.xml b/reference/spl/splobjectstorage/next.xml new file mode 100644 index 0000000000..3b969cf7e5 --- /dev/null +++ b/reference/spl/splobjectstorage/next.xml @@ -0,0 +1,106 @@ + + + + + + SplObjectStorage::next + Move to the next entry. + + + + &reftitle.description; + + public voidSplObjectStorage::next + + + + Moves the iterator to the next object in the storage. + + + + + &reftitle.parameters; + &no.function.parameters; + + + + &reftitle.returnvalues; + + &return.void; + + + + + &reftitle.examples; + + + <function>SplObjectStorage::next</function> example + +attach($o1, "d1"); +$s->attach($o2, "d2"); + +$s->rewind(); +while($s->valid()) { + $index = $s->key(); + $object = $s->current(); // similar to current($s) + + var_dump($index); + var_dump($object); + $s->next(); +} +?> +]]> + + &example.outputs.similar; + + + + + + + + + &reftitle.seealso; + + + Classname::Method + + + + + + + diff --git a/reference/spl/splobjectstorage/offsetexists.xml b/reference/spl/splobjectstorage/offsetexists.xml new file mode 100644 index 0000000000..4eb5521047 --- /dev/null +++ b/reference/spl/splobjectstorage/offsetexists.xml @@ -0,0 +1,106 @@ + + + + + + SplObjectStorage::offsetExists + Checks whether an object exists in the storage + + + + &reftitle.description; + + public booleanSplObjectStorage::offsetExists + objectobject + + + Checks whether an object exists in the storage. + + + + + &reftitle.parameters; + + + + object + + + The object to look for. + + + + + + + + + &reftitle.returnvalues; + + Returns whether the object exists in the storage. + + + + + &reftitle.examples; + + + <function>SplObjectStorage::offsetExists</function> example + +attach($o1); + +var_dump($s->offsetExists($o1)); // Similar to isset($s[$o1]) +var_dump($s->offsetExists($o2)); // Similar to isset($s[$o2]) +?> +]]> + + &example.outputs.similar; + + + + + + + + + &reftitle.seealso; + + + SplObjectStorage::offsetSet + SplObjectStorage::offsetGet + SplObjectStorage::offsetUnset + + + + + + + diff --git a/reference/spl/splobjectstorage/offsetget.xml b/reference/spl/splobjectstorage/offsetget.xml new file mode 100644 index 0000000000..e09efdaf05 --- /dev/null +++ b/reference/spl/splobjectstorage/offsetget.xml @@ -0,0 +1,109 @@ + + + + + + SplObjectStorage::offsetGet + Returns the data associated with an object + + + + &reftitle.description; + + public mixedSplObjectStorage::offsetGet + objectobject + + + Returns the data associated with an object in the storage. + + + + + &reftitle.parameters; + + + + object + + + The object to look for. + + + + + + + + + &reftitle.returnvalues; + + The data previously associated with the object in the storage. + + + + + &reftitle.examples; + + + <function>SplObjectStorage::offsetGet</function> example + +attach($o2); + + +var_dump($s->offsetGet($o1)); // Similar to $s[$o1] +var_dump($s->offsetGet($o2)); // Similar to $s[$o2] +?> +]]> + + &example.outputs.similar; + + + + + + + + + &reftitle.seealso; + + + SplObjectStorage::offsetSet + SplObjectStorage::offsetExists + SplObjectStorage::offsetUnset + + + + + + + diff --git a/reference/spl/splobjectstorage/offsetset.xml b/reference/spl/splobjectstorage/offsetset.xml new file mode 100644 index 0000000000..929bceb01f --- /dev/null +++ b/reference/spl/splobjectstorage/offsetset.xml @@ -0,0 +1,118 @@ + + + + + + SplObjectStorage::offsetSet + Associates data to an object in the storage + + + + &reftitle.description; + + public voidSplObjectStorage::offsetSet + objectobject + mixedinfo + + + Associate data to an object in the storage. + + + + SplObjectStorage::offsetSet is an alias of SplObjectStorage::attach. + + + + + + &reftitle.parameters; + + + + object + + + The object to associate data with. + + + + + info + + + The data to associate with the object. + + + + + + + + + &reftitle.returnvalues; + + &return.void; + + + + + &reftitle.examples; + + + <function>SplObjectStorage::offsetSet</function> example + +offsetSet($o1, "hello"); // Similar to $s[$o1] = "hello"; + +var_dump($s[$o1]); +?> +]]> + + &example.outputs.similar; + + + + + + + + + &reftitle.seealso; + + + SplObjectStorage::offsetGet + SplObjectStorage::offsetExists + SplObjectStorage::offsetUnset + + + + + + + diff --git a/reference/spl/splobjectstorage/offsetunset.xml b/reference/spl/splobjectstorage/offsetunset.xml new file mode 100644 index 0000000000..7a88d1be76 --- /dev/null +++ b/reference/spl/splobjectstorage/offsetunset.xml @@ -0,0 +1,109 @@ + + + + + + SplObjectStorage::offsetUnset + Removes an object from the storage + + + + &reftitle.description; + + public voidSplObjectStorage::offsetUnset + objectobject + + + Removes an object from the storage. + + + + SplObjectStorage::offsetUnset is an alias of SplObjectStorage::detach. + + + + + + &reftitle.parameters; + + + + object + + + The object to remove. + + + + + + + + + &reftitle.returnvalues; + + &return.void; + + + + + &reftitle.examples; + + + <function>SplObjectStorage::offsetUnset</function> example + +attach($o); +var_dump(count($s)); +$s->offsetUnset($o); // Similar to unset($s[$o]) +var_dump(count($s)); +?> +]]> + + &example.outputs.similar; + + + + + + + + + &reftitle.seealso; + + + SplObjectStorage::offsetGet + SplObjectStorage::offsetSet + SplObjectStorage::offsetExists + + + + + + + diff --git a/reference/spl/splobjectstorage/removeall.xml b/reference/spl/splobjectstorage/removeall.xml new file mode 100644 index 0000000000..ea7168d85b --- /dev/null +++ b/reference/spl/splobjectstorage/removeall.xml @@ -0,0 +1,108 @@ + + + + + + SplObjectStorage::removeAll + Removes objects contained in another storage from the current storage + + + + &reftitle.description; + + public voidSplObjectStorage::removeAll + SplObjectStoragestorage + + + Removes objects contained in another storage from the current storage. + + + + + &reftitle.parameters; + + + + storage + + + The storage containing the elements to remove. + + + + + + + + + &reftitle.returnvalues; + + &return.void; + + + + + &reftitle.examples; + + + <function>SplObjectStorage::removeAll</function> example + +removeAll($a); +var_dump(count($b)); +?> +]]> + + &example.outputs.similar; + + + + + + + + + &reftitle.seealso; + + + SplObjectStorage::addAll + + + + + + + diff --git a/reference/spl/splobjectstorage/rewind.xml b/reference/spl/splobjectstorage/rewind.xml new file mode 100644 index 0000000000..cfc62ad10e --- /dev/null +++ b/reference/spl/splobjectstorage/rewind.xml @@ -0,0 +1,103 @@ + + + + + + SplObjectStorage::rewind + Rewind the iterator to the first storage element + + + + &reftitle.description; + + public voidSplObjectStorage::rewind + + + + Rewind the iterator to the first storage element. + + + + + &reftitle.parameters; + &no.function.parameters; + + + + &reftitle.returnvalues; + + &return.void; + + + + + &reftitle.examples; + + + <function>SplObjectStorage::rewind</function> example + +attach($o1, "d1"); +$s->attach($o2, "d2"); + +$s->rewind(); +while($s->valid()) { + $index = $s->key(); + $object = $s->current(); // similar to current($s) + $data = $s->getInfo(); + + var_dump($object); + var_dump($data); + $s->next(); +} +?> +]]> + + &example.outputs.similar; + + + + + + + + + &reftitle.seealso; + + + Classname::Method + + + + + + + diff --git a/reference/spl/splobjectstorage/serialize.xml b/reference/spl/splobjectstorage/serialize.xml new file mode 100644 index 0000000000..b130df5358 --- /dev/null +++ b/reference/spl/splobjectstorage/serialize.xml @@ -0,0 +1,89 @@ + + + + + + SplObjectStorage::serialize + Serializes the storage + + + + &reftitle.description; + + public stringSplObjectStorage::serialize + + + + Returns a string representation of the storage. + + + + + &reftitle.parameters; + &no.function.parameters; + + + + &reftitle.returnvalues; + + A string representing the storage. + + + + + &reftitle.examples; + + + <function>SplObjectStorage::serialize</function> example + +serialize()."\n"; +?> +]]> + + &example.outputs.similar; + + + + + + + + + &reftitle.seealso; + + + SplObjectStorage::unserialize + + + + + + + diff --git a/reference/spl/splobjectstorage/setinfo.xml b/reference/spl/splobjectstorage/setinfo.xml new file mode 100644 index 0000000000..6f57c43672 --- /dev/null +++ b/reference/spl/splobjectstorage/setinfo.xml @@ -0,0 +1,116 @@ + + + + + + SplObjectStorage::setInfo + Sets the data associated with the current iterator entry + + + + &reftitle.description; + + public voidSplObjectStorage::setInfo + mixeddata + + + Associates data, or info, with the object currently pointed to by the iterator. + + + + + &reftitle.parameters; + + + + data + + + The data to associate with the current iterator entry. + + + + + + + + + &reftitle.returnvalues; + + &return.void; + + + + + &reftitle.examples; + + + <function>SplObjectStorage::setInfo</function> example + +attach($o1, "d1"); +$s->attach($o2, "d2"); + +$s->rewind(); +while($s->valid()) { + $s->setInfo("new"); + $s->next(); +} +var_dump($s[$o1]); +var_dump($s[$o2]); +?> +]]> + + &example.outputs.similar; + + + + + + + + + &reftitle.seealso; + + + SplObjectStorage::current + SplObjectStorage::rewind + SplObjectStorage::key + SplObjectStorage::next + SplObjectStorage::valid + SplObjectStorage::getInfo + + + + + + + diff --git a/reference/spl/splobjectstorage/unserialize.xml b/reference/spl/splobjectstorage/unserialize.xml new file mode 100644 index 0000000000..d06ba07ee7 --- /dev/null +++ b/reference/spl/splobjectstorage/unserialize.xml @@ -0,0 +1,103 @@ + + + + + + SplObjectStorage::unserialize + Unserializes a storage from its string representation + + + + &reftitle.description; + + public voidSplObjectStorage::unserialize + stringserialized + + + Unserializes storage entries and attach them to the current storage. + + + + + &reftitle.parameters; + + + + serialized + + + The serialized representation of a storage. + + + + + + + + + &reftitle.returnvalues; + + &return.void; + + + + + &reftitle.examples; + + + <function>SplObjectStorage::unserialize</function> example + +unserialize($s1->serialize()); + +var_dump(count($s2)); +?> +]]> + + &example.outputs.similar; + + + + + + + + + &reftitle.seealso; + + + SplObjectStorage::serialize + + + + + + + diff --git a/reference/spl/splobjectstorage/valid.xml b/reference/spl/splobjectstorage/valid.xml new file mode 100644 index 0000000000..eeec5b2acf --- /dev/null +++ b/reference/spl/splobjectstorage/valid.xml @@ -0,0 +1,98 @@ + + + + + + SplObjectStorage::valid + Returns if the current iterator entry is valid + + + + &reftitle.description; + + public booleanSplObjectStorage::valid + + + + Returns if the current iterator entry is valid. + + + + + &reftitle.parameters; + &no.function.parameters; + + + + &reftitle.returnvalues; + + Returns &true; if the iterator entry is valid, &false; otherwise. + + + + + &reftitle.examples; + + + <function>SplObjectStorage::valid</function> example + +attach($o1, "d1"); +$s->attach($o2, "d2"); + +$s->rewind(); +while($s->valid()) { + echo $s->key()."\n"; + $s->next(); +} +?> +]]> + + &example.outputs.similar; + + + + + + + + + &reftitle.seealso; + + + Classname::Method + + + + + + +