public static function _readInt(InputStream $stream, $length) { $result = 0; for ($i = 0; $i != $length; ++$i) { $b = $stream->readByte(); if ($b == -1) { throw new EOFException(); } $result |= $b << $i * 8; } return $result; }