original_string: private function readIndex($zval, $index)
      {
          if (!$zval[self::VALUE] instanceof \ArrayAccess && !\is_array($zval[self::VALUE])) {
              throw new NoSuchIndexException(sprintf('Cannot read index "%s" from object of type "%s" because it doesn\'t implement \ArrayAccess.', $index, \get_class($zval[self::VALUE])));
          }
  
          $result = self::$resultProto;
  
          if (isset($zval[self::VALUE][$index])) {
              $result[self::VALUE] = $zval[self::VALUE][$index];
  
              if (!isset($zval[self::REF])) {
                  // Save creating references when doing read-only lookups
              } elseif (\is_array($zval[self::VALUE])) {
                  $result[self::REF] = &$zval[self::REF][$index];
              } elseif (\is_object($result[self::VALUE])) {
                  $result[self::REF] = $result[self::VALUE];
              }
          }
  
          return $result;
      }
code: private function readIndex($zval, $index)
      {
          if (!$zval[self::VALUE] instanceof \ArrayAccess && !\is_array($zval[self::VALUE])) {
              throw new NoSuchIndexException(sprintf('Cannot read index "%s" from object of type "%s" because it doesn\'t implement \ArrayAccess.', $index, \get_class($zval[self::VALUE])));
          }
  
          $result = self::$resultProto;
  
          if (isset($zval[self::VALUE][$index])) {
              $result[self::VALUE] = $zval[self::VALUE][$index];
  
              if (!isset($zval[self::REF])) {
                  // Save creating references when doing read-only lookups
              } elseif (\is_array($zval[self::VALUE])) {
                  $result[self::REF] = &$zval[self::REF][$index];
              } elseif (\is_object($result[self::VALUE])) {
                  $result[self::REF] = $result[self::VALUE];
              }
          }
  
          return $result;
      }
code_tokens: private function readIndex ( $ zval , $ index ) { if ( ! $ zval [ self :: VALUE ] instanceof \ ArrayAccess && ! \ is_array ( $ zval [ self :: VALUE ] ) ) { throw new NoSuchIndexException ( sprintf ( 'Cannot read index "%s" from object of type "%s" because it doesn\'t implement \ArrayAccess.' , $ index , \ get_class ( $ zval [ self :: VALUE ] ) ) ) ; } $ result = self :: $ resultProto ; if ( isset ( $ zval [ self :: VALUE ] [ $ index ] ) ) { $ result [ self :: VALUE ] = $ zval [ self :: VALUE ] [ $ index ] ; if ( ! isset ( $ zval [ self :: REF ] ) ) { // Save creating references when doing read-only lookups } elseif ( \ is_array ( $ zval [ self :: VALUE ] ) ) { $ result [ self :: REF ] = & $ zval [ self :: REF ] [ $ index ] ; } elseif ( \ is_object ( $ result [ self :: VALUE ] ) ) { $ result [ self :: REF ] = $ result [ self :: VALUE ] ; } } return $ result ; }
docstring: Reads a key from an array-like structure.
  
  @param array      $zval  The array containing the array or \ArrayAccess object to read from
  @param string|int $index The key to read
  
  @return array The array containing the value of the key
  
  @throws NoSuchIndexException If the array does not implement \ArrayAccess or it is not an array
docstring_tokens: Reads a key from an array - like structure .