svn: /phpdoc/en/trunk/reference/mongodb/ architecture.xml
| From: | Jeremy Mikola | Date: | Thu, 23 Jun 2016 21:54:22 +0000 |
| Subject: | svn: /phpdoc/en/trunk/reference/mongodb/ architecture.xml | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-14240@lists.php.net to get a copy of this message | ||
jmikola Thu, 23 Jun 2016 21:54:22 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=339468
Log:
Add syntax highlighting to BSON persistence articles
https://jira.mongodb.org/browse/PHPC-486
Changed paths:
U phpdoc/en/trunk/reference/mongodb/architecture.xml
Modified: phpdoc/en/trunk/reference/mongodb/architecture.xml
===================================================================
--- phpdoc/en/trunk/reference/mongodb/architecture.xml 2016-06-23 21:37:47 UTC (rev 339467)
+++ phpdoc/en/trunk/reference/mongodb/architecture.xml 2016-06-23 21:54:22 UTC (rev 339468)
@@ -171,19 +171,23 @@
These serialize as a BSON array:
</para>
- <programlisting>
+ <programlisting role="text">
+<![CDATA[
[ 8, 5, 2, 3 ] => [ 8, 5, 2, 3 ]
[ 0 => 4, 1 => 9 ] => [ 4, 9 ]
+]]>
</programlisting>
<para>
These serialize as a BSON document:
</para>
- <programlisting>
+ <programlisting role="text">
+<![CDATA[
[ 0 => 1, 2 => 8, 3 => 12 ] => { "0" : 1, "2" : 8, "3" :
12 }
[ "foo" => 42 ] => { "foo" : 42 }
[ 1 => 9, 0 => 10 ] => { "1" : 9, "0" : 10 }
+]]>
</programlisting>
<para>
@@ -299,41 +303,44 @@
<section>
<title>Examples</title>
- <programlisting>
-stdClass {
+ <programlisting role="php">
+<![CDATA[
+<?php
+
+class stdClass {
public $foo = 42;
-} => { "foo" : 42 }
+} // => { "foo" : 42 }
-MyClass {
+class MyClass {
public $foo = 42;
protected $prot = "wine";
private $fpr = "cheese";
-} => { "foo" : 42 }
+} // => { "foo" : 42 }
-AnotherClass1 implements MongoDB\BSON\Serializable {
+class AnotherClass1 implements MongoDB\BSON\Serializable {
public $foo = 42;
protected $prot = "wine";
private $fpr = "cheese";
function bsonSerialize() {
return [ 'foo' => $this->foo, 'prot' => $this->prot ];
}
-} => { "foo" : 42, "prot" : "wine" }
+} // => { "foo" : 42, "prot" : "wine" }
-AnotherClass2 implements MongoDB\BSON\Serializable {
+class AnotherClass2 implements MongoDB\BSON\Serializable {
public $foo = 42;
function bsonSerialize() {
return $this;
}
-} => MongoDB\Driver\Exception\UnexpectedValueException("bsonSerialize() did not return an
array or stdClass")
+} // => MongoDB\Driver\Exception\UnexpectedValueException("bsonSerialize() did not return
an array or stdClass")
-AnotherClass3 implements MongoDB\BSON\Serializable {
+class AnotherClass3 implements MongoDB\BSON\Serializable {
private $elements = [ 'foo', 'bar' ];
function bsonSerialize() {
return $this->elements;
}
-} => { "0" : "foo", "1" : "bar" }
+} // => { "0" : "foo", "1" : "bar" }
-ContainerClass implements MongoDB\BSON\Serializable {
+class ContainerClass implements MongoDB\BSON\Serializable {
public $things = AnotherClass4 implements MongoDB\BSON\Serializable {
private $elements = [ 0 => 'foo', 2 => 'bar' ];
function bsonSerialize() {
@@ -343,9 +350,9 @@
function bsonSerialize() {
return [ 'things' => $this->things ];
}
-} => { "things" : { "0" : "foo", "2" : "bar" }
}
+} // => { "things" : { "0" : "foo", "2" :
"bar" } }
-ContainerClass implements MongoDB\BSON\Serializable {
+class ContainerClass implements MongoDB\BSON\Serializable {
public $things = AnotherClass5 implements MongoDB\BSON\Serializable {
private $elements = [ 0 => 'foo', 2 => 'bar' ];
function bsonSerialize() {
@@ -355,9 +362,9 @@
function bsonSerialize() {
return [ 'things' => $this->things ];
}
-} => { "things" : [ "foo", "bar" ] }
+} // => { "things" : [ "foo", "bar" ] }
-ContainerClass implements MongoDB\BSON\Serializable {
+class ContainerClass implements MongoDB\BSON\Serializable {
public $things = AnotherClass6 implements MongoDB\BSON\Serializable {
private $elements = [ 'foo', 'bar' ];
function bsonSerialize() {
@@ -367,16 +374,17 @@
function bsonSerialize() {
return [ 'things' => $this->things ];
}
-} => { "things" : { "0" : "foo", "1" : "bar" }
}
+} // => { "things" : { "0" : "foo", "1" :
"bar" } }
-UpperClass implements MongoDB\BSON\Persistable {
+class UpperClass implements MongoDB\BSON\Persistable {
public $foo = 42;
protected $prot = "wine";
private $fpr = "cheese";
function bsonSerialize() {
return [ 'foo' => $this->foo, 'prot' => $this->prot ];
}
-} => { "foo" : 42, "prot" : "wine", "__pclass" : {
"$type" : "80", "$binary" : "VXBwZXJDbGFzcw==" } }
+} // => { "foo" : 42, "prot" : "wine", "__pclass" : {
"$type" : "80", "$binary" : "VXBwZXJDbGFzcw==" } }
+]]>
</programlisting>
</section>
</section>
@@ -614,7 +622,10 @@
the properties without modifications. It <emphasis>also</emphasis> sets
the <literal>$unserialized</literal> property to
<literal>true</literal>:
- <programlisting>
+ <programlisting role="php">
+<![CDATA[
+<?php
+
function bsonUnserialize( array $map )
{
foreach ( $map as $k => $value )
@@ -623,11 +634,13 @@
}
$this->unserialized = true;
}
+]]>
</programlisting>
</para>
<para>
- <programlisting>
+ <programlisting role="text">
+<![CDATA[
/* typemap: [] (all defaults) */
{ "foo": "yes", "bar" : false }
-> stdClass { $foo => 'yes', $bar => false }
@@ -652,11 +665,13 @@
{ "foo": "yes", "__pclass": { "$type" : "44",
"$binary" : "YourClass") }
-> stdClass { $foo => 'yes', $__pclass => Binary(0x44, 'YourClass')
}
+]]>
</programlisting>
</para>
<para>
- <programlisting>
+ <programlisting role="text">
+<![CDATA[
/* typemap: [ "root" => "MissingClass" ] */
{ "foo": "yes" }
-> MongoDB\Driver\Exception\InvalidArgumentException("MissingClass does not exist")
@@ -688,19 +703,23 @@
/* typemap: [ "root" => "OurClass" ] */
{ foo: "yes", "__pclass" : { "$type": "80",
"$binary": "TheirClass" } }
-> TheirClass { $foo => "yes", $__pclass => Binary(0x80,
"TheirClass"), $unserialized => true }
+]]>
</programlisting>
</para>
<para>
- <programlisting>
+ <programlisting role="text">
+<![CDATA[
/* typemap: [ 'root' => 'YourClass' ] */
{ foo: "yes", "__pclass" : { "$type": "80",
"$binary": "YourClass" } }
-> YourClass { $foo => 'yes', $__pclass => Binary(0x80,
'YourClass'), $unserialized => true }
+]]>
</programlisting>
</para>
<para>
- <programlisting>
+ <programlisting role="text">
+<![CDATA[
/* typemap: [ 'root' => 'array', 'document' =>
'array' ] */
{ "foo": "yes", "bar" : false }
-> [ "foo" => "yes", "bar" => false ]
@@ -719,14 +738,17 @@
{ "foo": "yes", "__pclass" : { "$type": "80",
"$binary": "OurClass" } }
-> [ "foo" => "yes", "__pclass" => Binary(0x80,
"OurClass") ]
+]]>
</programlisting>
</para>
<para>
- <programlisting>
+ <programlisting role="text">
+<![CDATA[
/* typemap: [ 'root' => 'object', 'document' =>
'object' ] */
{ "foo": "yes", "__pclass": { "$type": "80",
"$binary": "MyClass" } }
-> stdClass { $foo => "yes", "__pclass" => Binary(0x80,
"MyClass") }
+]]>
</programlisting>
</para>