original_string: protected function getObject($item, $memory) {
      $result = new \stdClass();
      $result->properties = array();
  
      // Add itemtype.
      if ($itemtype = $item->itemType()) {
        $result->type = $itemtype;
      }
      // Add itemid. 
      if ($itemid = $item->itemid()) {
        $result->id = $itemid;
      }
      // Add properties.
      foreach ($item->properties() as $elem) {
        if ($elem->itemScope()) {
          // Cannot use in_array() for comparison when values are arrays, so
          // iterate and check for equality with each item in memory.
          foreach ($memory as $memory_item) {
            if ($memory_item === $elem) {
              $value = 'ERROR';
            }
          }
          // If the item is not in memory, there are no cycles, and thus no error.
          // Recurse into the item to build out its properties.
          if (!isset($value)) {
            $memory[] = $item;
            $value = $this->getObject($elem, $memory);
            array_pop($memory);
          }
        }
        else {
          $value = $elem->itemValue();
        }
        foreach ($elem->itemProp() as $prop) {
          $result->properties[$prop][] = $value;
        }
  
        $value = NULL;
      }
      return $result;
    }
code: protected function getObject($item, $memory) {
      $result = new \stdClass();
      $result->properties = array();
  
      // Add itemtype.
      if ($itemtype = $item->itemType()) {
        $result->type = $itemtype;
      }
      // Add itemid. 
      if ($itemid = $item->itemid()) {
        $result->id = $itemid;
      }
      // Add properties.
      foreach ($item->properties() as $elem) {
        if ($elem->itemScope()) {
          // Cannot use in_array() for comparison when values are arrays, so
          // iterate and check for equality with each item in memory.
          foreach ($memory as $memory_item) {
            if ($memory_item === $elem) {
              $value = 'ERROR';
            }
          }
          // If the item is not in memory, there are no cycles, and thus no error.
          // Recurse into the item to build out its properties.
          if (!isset($value)) {
            $memory[] = $item;
            $value = $this->getObject($elem, $memory);
            array_pop($memory);
          }
        }
        else {
          $value = $elem->itemValue();
        }
        foreach ($elem->itemProp() as $prop) {
          $result->properties[$prop][] = $value;
        }
  
        $value = NULL;
      }
      return $result;
    }
code_tokens: protected function getObject ( $ item , $ memory ) { $ result = new \ stdClass ( ) ; $ result -> properties = array ( ) ; // Add itemtype. if ( $ itemtype = $ item -> itemType ( ) ) { $ result -> type = $ itemtype ; } // Add itemid.  if ( $ itemid = $ item -> itemid ( ) ) { $ result -> id = $ itemid ; } // Add properties. foreach ( $ item -> properties ( ) as $ elem ) { if ( $ elem -> itemScope ( ) ) { // Cannot use in_array() for comparison when values are arrays, so // iterate and check for equality with each item in memory. foreach ( $ memory as $ memory_item ) { if ( $ memory_item === $ elem ) { $ value = 'ERROR' ; } } // If the item is not in memory, there are no cycles, and thus no error. // Recurse into the item to build out its properties. if ( ! isset ( $ value ) ) { $ memory [ ] = $ item ; $ value = $ this -> getObject ( $ elem , $ memory ) ; array_pop ( $ memory ) ; } } else { $ value = $ elem -> itemValue ( ) ; } foreach ( $ elem -> itemProp ( ) as $ prop ) { $ result -> properties [ $ prop ] [ ] = $ value ; } $ value = NULL ; } return $ result ; }
docstring: Helper function.
  
  In MicrodataJS, this is handled using a closure. PHP 5.3 allows closures,
  but cannot use $this within the closure. PHP 5.4 reintroduces support for
  $this. When PHP 5.3/5.4 are more widely supported on shared hosting,
  this function could be handled with a closure.
docstring_tokens: Helper function .