<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->

<refentry xml:id="function.mongodb.bson-tophp" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
 <refnamediv>
  <refname>MongoDB\BSON\toPHP</refname>
  <refpurpose>Returns the PHP representation of a BSON value</refpurpose>
 </refnamediv>

 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis>
   <type class="union"><type>array</type><type>object</type></type><methodname>MongoDB\BSON\toPHP</methodname>
   <methodparam><type>string</type><parameter>bson</parameter></methodparam>
   <methodparam choice="opt"><type>array</type><parameter>typeMap</parameter><initializer>array()</initializer></methodparam>
  </methodsynopsis>
  <para>
   Unserializes a BSON document (i.e. binary string) to its PHP representation.
   The <parameter>typeMap</parameter> paramater may be used to control the PHP
   types used for converting BSON arrays and documents (both root and embedded).
  </para>
  &mongodb.warning.duplicate-keys;
 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  <variablelist>
   <varlistentry>
    <term><parameter>bson</parameter> (<type>string</type>)</term>
    <listitem>
     <para>
      BSON value to be unserialized.
     </para>
    </listitem>
   </varlistentry>
   &mongodb.parameter.typeMap;
  </variablelist>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   The unserialized PHP value.
  </para>
 </refsect1>

 <refsect1 role="errors">
  &reftitle.errors;
  <simplelist>
   <member>
    Throws
    <classname>MongoDB\Driver\Exception\InvalidArgumentException</classname> if
    a class in the type map cannot be instantiated or does not implement
    <interfacename>MongoDB\BSON\Unserializable</interfacename>.
   </member>
   &mongodb.throws.bson.unexpected;
  </simplelist>
 </refsect1>

 <refsect1 role="changelog">
  &reftitle.changelog;
  <para>
   <informaltable>
    <tgroup cols="2">
     <thead>
      <row>
       <entry>&Version;</entry>
       <entry>&Description;</entry>
      </row>
     </thead>
     <tbody>
      <row>
       <entry>PECL mongodb 1.4.0</entry>
       <entry>
        <para>
         If the input contains an unsupported, deprecated BSON type, the
         driver will now no longer log a warning to the debug log, but instead
         will create an object representing this type.
        </para>
       </entry>
      </row>
      <row>
       <entry>PECL mongodb 1.3.2</entry>
       <entry>
        <para>
         <classname>MongoDB\Driver\Exception\UnexpectedValueException</classname>
         is no longer thrown if the input contains an unsupported, deprecated
         BSON type. Such types will be ignored (as they were in versions before
         1.3.0), although the driver will now log a warning to the debug log
         (see: <link linkend="ini.mongodb.debug">mongodb.debug</link>).
        </para>
       </entry>
      </row>
      <row>
       <entry>PECL mongodb 1.3.0</entry>
       <entry>
        <para>
         <classname>MongoDB\Driver\Exception\UnexpectedValueException</classname>
         is thrown if the input contains an unsupported, deprecated BSON type.
         Previously, such types were ignored.
        </para>
       </entry>
      </row>
     </tbody>
    </tgroup>
   </informaltable>
  </para>
 </refsect1>

 <refsect1 role="examples">
  &reftitle.examples;
  <example>
   <title><function>MongoDB\BSON\toPHP</function> example</title>
   <programlisting role="php">
<![CDATA[
<?php

$bson = hex2bin('0e00000010666f6f000100000000');
$value = MongoDB\BSON\toPHP($bson);
var_dump($value);

?>
]]>
   </programlisting>
   &example.outputs;
   <screen>
<![CDATA[
object(stdClass)#1 (1) {
  ["foo"]=>
  int(1)
}
]]>
   </screen>
  </example>
 </refsect1>


 <refsect1 role="seealso">
  &reftitle.seealso;
  <simplelist>
   <member><methodname>MongoDB\BSON\Document::toPHP</methodname></member>
   <member><function>MongoDB\BSON\fromPHP</function></member>
   <member><link xlink:href="&url.mongodb.docs.bson;">MongoDB BSON</link></member>
   <member><xref linkend="mongodb.persistence"/></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
-->
