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

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Minor - P4
    • 1.16.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • 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
            Reporter:
            Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: