original_string: private function entityToReference(&$item, $key) {
      if ($this->isASleepingReference) {
        $this->referenceWake();
      }
      if ((is_a($item, '\Nymph\Entity') || is_a($item, '\SciActive\HookOverride'))
          && isset($item->guid) && is_callable([$item, 'toReference'])) {
        // This is an entity, so we should put it in the entity cache.
        if (!isset($this->entityCache["referenceGuid__{$item->guid}"])) {
          $this->entityCache["referenceGuid__{$item->guid}"] = clone $item;
        }
        // Make a reference to the entity (its GUID and the class the entity was
        // loaded as).
        $item = $item->toReference();
      }
    }
code: private function entityToReference(&$item, $key) {
      if ($this->isASleepingReference) {
        $this->referenceWake();
      }
      if ((is_a($item, '\Nymph\Entity') || is_a($item, '\SciActive\HookOverride'))
          && isset($item->guid) && is_callable([$item, 'toReference'])) {
        // This is an entity, so we should put it in the entity cache.
        if (!isset($this->entityCache["referenceGuid__{$item->guid}"])) {
          $this->entityCache["referenceGuid__{$item->guid}"] = clone $item;
        }
        // Make a reference to the entity (its GUID and the class the entity was
        // loaded as).
        $item = $item->toReference();
      }
    }
code_tokens: private function entityToReference ( & $ item , $ key ) { if ( $ this -> isASleepingReference ) { $ this -> referenceWake ( ) ; } if ( ( is_a ( $ item , '\Nymph\Entity' ) || is_a ( $ item , '\SciActive\HookOverride' ) ) && isset ( $ item -> guid ) && is_callable ( [ $ item , 'toReference' ] ) ) { // This is an entity, so we should put it in the entity cache. if ( ! isset ( $ this -> entityCache [ "referenceGuid__{$item->guid}" ] ) ) { $ this -> entityCache [ "referenceGuid__{$item->guid}" ] = clone $ item ; } // Make a reference to the entity (its GUID and the class the entity was // loaded as). $ item = $ item -> toReference ( ) ; } }
docstring: Check if an item is an entity, and if it is, convert it to a reference.
  
  @param mixed &$item The item to check.
  @param mixed $key Unused, but can't be removed because array_walk_recursive
  will fail.
  @access private
docstring_tokens: Check if an item is an entity and if it is convert it to a reference .