BSON encoding should ignore protected/private properties

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • 1.0.0-beta2
    • Affects Version/s: 1.0.0-alpha2
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      derick' BSON serialization document says protected/private properties should be discarded

      If an object is of any other class, without implementing any special interface, serialize as a BSON document. Keep only public properties, and ignore protected and private properties.

      Currently that is not the case:

      <?php
      class special {
        public $public = "public";
        protected $protected = "protected";
        private $private = "private";
      }
      $special = new Special;
      $ret = MongoDB\BSON\toPHP(MongoDB\BSON\fromPHP($special))
      var_dump($ret);
      ?>
      
      object(stdClass)#2 (3) {
        ["public"]=>
        string(6) "public"
        ["protected"]=>
        string(9) "protected"
        ["private"]=>
        string(7) "private"
      }
      

            Assignee:
            Jeremy Mikola
            Reporter:
            Hannes Magnusson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: