Differences Between: [Versions 311 and 401]
1 <?php 2 /* 3 * Copyright 2016-present MongoDB, Inc. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 namespace MongoDB\Model; 19 20 use ArrayObject; 21 use JsonSerializable; 22 use MongoDB\BSON\Serializable; 23 use MongoDB\BSON\Unserializable; 24 use function array_values; 25 use function MongoDB\recursive_copy; 26 27 /** 28 * Model class for a BSON array. 29 * 30 * The internal data will be filtered through array_values() during BSON 31 * serialization to ensure that it becomes a BSON array. 32 * 33 * @api 34 */ 35 class BSONArray extends ArrayObject implements JsonSerializable, Serializable, Unserializable 36 { 37 /** 38 * Clone this BSONArray. 39 */ 40 public function __clone() 41 { 42 foreach ($this as $key => $value) { 43 $this[$key] = recursive_copy($value); 44 } 45 } 46 47 /** 48 * Factory method for var_export(). 49 * 50 * @see http://php.net/oop5.magic#object.set-state 51 * @see http://php.net/var-export 52 * @param array $properties 53 * @return self 54 */ 55 public static function __set_state(array $properties) 56 { 57 $array = new static(); 58 $array->exchangeArray($properties); 59 60 return $array; 61 } 62 63 /** 64 * Serialize the array to BSON. 65 * 66 * The array data will be numerically reindexed to ensure that it is stored 67 * as a BSON array. 68 * 69 * @see http://php.net/mongodb-bson-serializable.bsonserialize 70 * @return array 71 */ 72 public function bsonSerialize() 73 { 74 return array_values($this->getArrayCopy()); 75 } 76 77 /** 78 * Unserialize the document to BSON. 79 * 80 * @see http://php.net/mongodb-bson-unserializable.bsonunserialize 81 * @param array $data Array data 82 */ 83 public function bsonUnserialize(array $data) 84 { 85 self::__construct($data); 86 } 87 88 /** 89 * Serialize the array to JSON. 90 * 91 * The array data will be numerically reindexed to ensure that it is stored 92 * as a JSON array. 93 * 94 * @see http://php.net/jsonserializable.jsonserialize 95 * @return array 96 */ 97 public function jsonSerialize() 98 { 99 return array_values($this->getArrayCopy()); 100 } 101 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body