Uploaded image for project: 'PHP Driver: Extension'
  1. PHP Driver: Extension
  2. PHPC-2222

PackedArray::fromPHP returns Document for root=bson type map

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 1.16.0
    • Affects Version/s: None
    • Component/s: None
    • None

      $packedArray = MongoDB\BSON\PackedArray::fromPHP([1, 2, 3]);
      var_dump($packedArray->toPHP(['root' => 'bson']));
      

      This produces the following output:

      object(MongoDB\BSON\Document)#2 (1) {
        ["data"]=>
        string(36) "GgAAABAwAAEAAAAQMQACAAAAEDIAAwAAAAA="
      }
      

      I'll concede that the type map doesn't make much sense on its own, although the above "root" option could certainly accompany a more complex type map and the output would be the same.

      I would have expected the result to be a PackedArray, although this may be intentional since we're interpreting the PackedArray as a root document. In that case, this behavior may be closely related to PHPC-2219.

            Assignee:
            andreas.braun@mongodb.com Andreas Braun
            Reporter:
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: