ExportXMLWordPrintableJSON

    • Type: Task
    • Resolution: Unresolved
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • PHP Drivers
    • None
    • None
    • None
    • None
    • None
    • None

      Creating a dynamic property through a reference, assigning through that reference, and then removing both the property and reference breaks subsequent foreach iteration over `MongoDB\BSON\ObjectId`.

       

       

      <?php
       
      error_reporting(E_ALL & ~E_DEPRECATED);
      function iterationKeys(object $object): array {
          $keys = [];
          foreach ($object as $key => $value) {
              $keys[] = $key;
          }
       
          return $keys;
      }
       
      $oid = new MongoDB\BSON\ObjectId('507f1f77bcf86cd799439011');
      echo json_encode(iterationKeys($oid)), "\n";
      $ref = &$oid->foo;
      $ref = 'x';
      unset($oid->foo, $ref);
      echo json_encode(iterationKeys($oid)), "\n";
      echo (string) $oid, "\n";
      

       

            Assignee:
            Unassigned
            Reporter:
            Seifeddine Gmati
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: