Byte array with an `_io` member: PHP parsing library

Helper type to work around Kaitai Struct not providing an _io member for plain byte arrays.

KS implementation details

License: MIT

This page hosts a formal specification of Byte array with an `_io` member using Kaitai Struct. This specification can be automatically translated into a variety of programming languages to get a parsing library.

PHP source code to parse Byte array with an `_io` member

BytesWithIo.php

<?php
// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild

/**
 * Helper type to work around Kaitai Struct not providing an `_io` member for plain byte arrays.
 */

namespace {
    class BytesWithIo extends \Kaitai\Struct\Struct {
        public function __construct(\Kaitai\Struct\Stream $_io, \Kaitai\Struct\Struct $_parent = null, \BytesWithIo $_root = null) {
            parent::__construct($_io, $_parent, $_root);
            $this->_read();
        }

        private function _read() {
            $this->_m_data = $this->_io->readBytesFull();
        }
        protected $_m_data;

        /**
         * The actual data.
         */
        public function data() { return $this->_m_data; }
    }
}