Sets the buffer.

@param Buffer $buffer The buffer to set.

@return self
422947
public function setBuffer($buffer)
    {
        $this->buffer = $buffer;

        $this->seq       = $this->buffer->readShort(self::SEQ_INDEX);
        $this->timestamp = $this->buffer->readInt(self::TIMESTAMP_INDEX);
        $this->ssrc      = $this->buffer->readInt(self::SSRC_INDEX);

        return $this;
    }
1289395
private function _createResult($buffer)
    {
        $result             = new \stdClass();
        $result->buffer     = $buffer;
        $result->stmt       = '';
        $result->state      = null;
        $result->states     = array();
        $result->statements = array();
        $result->stop       = false;
        
        return $result;
    }
1329553
protected function compileInitialization(Buffer $buffer)
    {
        $configurationLoader = new Configuration\ConfigurationLoader(
            $this->staticConfig,
            new FileLocator(array(getcwd())),
            new Configuration\FileLoader(
                new Configuration\PathDefaultFileLocator(
                    'ZPLUGINPATH',
                    $this->staticPluginPaths
                )
            )
        );

        $compiler = new ContainerCompiler($configurationLoader->processConfiguration(), array());
        $this->phar['container.php'] = $compiler->compileContainerCode();
        $buffer->writeln('$container = require_once \'phar://z.phar/container.php\';');

        foreach ($configurationLoader->getPlugins() as $name => $plugin) {
            $className = get_class($plugin);
            $embeddedFilename = 'plugins/' . $name . '.php';

            $class = new \ReflectionClass($className);

            $this->phar[$embeddedFilename] = file_get_contents($class->getFileName());
            $buffer->write('require_once ')->asPhp('phar://z.phar/' . $embeddedFilename)->raw(';')->eol();
            $buffer->write('$p = new ')->write($className)->raw('();')->eol();
            $buffer->writeln('$p->setContainer($container);');
        }
        $buffer
            ->writeln('Zicht\Tool\Application::$HEADER = \'\';')
            ->write('$app = new Zicht\Tool\Application(')
            ->asPhp($this->appName)
            ->raw(', Zicht\Version\Version::fromString(')
            ->asPhp($this->appVersion)
            ->raw(') ?: new Zicht\Version\Version());')
            ->eol()
        ;
        $buffer->writeln('$app->setContainer($container);');
    }
654075
protected function createSortableBuffer(&$buffer)
    {
        $query = static::query()
            ->select([
                'parent' => $this->getRoleField('tree-parent'),
                'max_value' => QueryExpression::max($this->getRoleField('sort-index'))
            ])->groupBy([
                $this->getRoleField('tree-parent'),
            ])->execute();
        while ($row = $query->fetch()) {
            $buffer['rows'][$row['parent']] = $row['max_value'];
        }
    }
1324029
public function loadRequest($buffer)
    {
        $this->requestAt = microtime(true);
        
        
        list($this->_rawHeader, $this->_rawBody) = explode("\r\n\r\n", $buffer, 2);
        
        $headers = explode("\r\n", $this->_rawHeader, 2);
        
        list($this->method, $this->uri, $this->version) = explode(' ',$headers[0]);
        
        $this->loadHeaders();
        
        $this->loadBody();
        
        $this->_REQUEST = array_merge($this->_GET, $this->_POST);
        
        $this->loadServerVars();
        $this->loadGet();
        
    }
765136
public function discard($n)
    {
        if ($this->length < $n) {
            throw new BufferUnderflowException();

        } elseif ($this->length === $n) {
            $this->buffer = "";
            $this->length = 0;
            return $this;

        } else {
            $this->buffer = substr($this->buffer, $n);
            $this->length -= $n;
            return $this;
        }
    }
269545
final public function compile(Buffer $buffer)
    {
        $buffer
            ->writeln("Phar::mapPhar('z.phar');")
            ->writeln("define('ZPREFIX', 'phar://z.phar/');")
            ->writeln("require_once 'phar://z.phar/vendor/autoload.php';")
        ;

        $this->compileInitialization($buffer);
        $buffer
            ->writeln('$app->run();')
            ->writeln('__HALT_COMPILER();')
        ;
    }
170488
public function compile(Buffer $buffer)
    {
        /** @var Script\Annotation[] $annotations */
        $annotations = array();
        $nodes = $this->nodes;
        while (current($nodes) instanceof Script\Annotation) {
            $annotations[] = array_shift($nodes);
        }

        foreach ($annotations as $annotation) {
            $annotation->beforeScript($buffer);
        }

        if (count($this->nodes)) {
            $buffer->write('$z->cmd(');
            foreach ($nodes as $i => $node) {
                if ($i > 0) {
                    $buffer->raw(' . ');
                }
                $buffer->raw('$z->str(');
                $node->compile($buffer);
                $buffer->raw(')');
            }
            $buffer->raw(');')->eol();
        }

        foreach (array_reverse($annotations) as $annotation) {
            $annotation->afterScript($buffer);
        }
    }
243168
public function shouldBuffer($buffer)
    {
        if ('' === $buffer) {
            return false;
        }

        $endOfBuffer = substr($buffer, -1);
        foreach ((array) $this->search as $needle) {
            if (false !== strpos($needle, $endOfBuffer)) {
                return true;
            }
        }

        return false;
    }
981322
public function setStorage($storage)
    {
        if ($this->storage !== $storage || ! $this->handler) {

            $this->storage = $storage;

            $this->handler = $this->getFileHandlerFactory()->create($storage);
        }

        return $this;
    }
797526
private function compressBuffer($buffer)
    {
        if (preg_match("/\<html/i",$buffer) == 1 && preg_match("/\<\/html\>/i",$buffer) == 1) {
            $buffer = preg_replace(
                ['/\>[^\S ]+/s', '/[^\S ]+\</s', '/(\s)+/s'],
                ['>', '<', '\\1'],
                $buffer
            );
        }

        return $buffer;
    }
416848
public static Persistable persistable(final ByteBuffer buffer) {
        return new Persistable() {

            @Override
            public int size() {
                return buffer.limit();
            }

            @Override
            public void write(ByteBuffer buffer1) {
                buffer1.put(buffer);
                buffer1.flip();
            }

            @Override
            public void read(ByteBuffer buffer1) {
                buffer.rewind();
                buffer.put(buffer1);
                buffer.rewind();
            }

        };
    }
679651
function set (buffer, offset, value) {
  debug('Array "type" setter for buffer at offset', buffer, offset, value)
  var array = this.get(buffer, offset)
  var isInstance = value instanceof this
  if (isInstance || isArray(value)) {
    for (var i = 0; i < value.length; i++) {
      array[i] = value[i]
    }
  } else {
    throw new Error('not sure how to set into Array: ' + value)
  }
}
651417
private function fillBuffer() {

	    // wrap bufferInstance in closure to allow the use of $this in template

	    $closure = function($outer) {

            ob_start();

            /* @deprecated use $this when accessing assigned variables */

            $tpl = $this;

            eval('?>' . $this->__rawContents);
            $outer->contents = ob_get_contents();
            ob_end_clean();

        };

	    $boundClosure = $closure->bindTo($this->bufferInstance);
	    $boundClosure($this);

	}
540241
public function compile(Buffer $buffer)
    {
        $name = explode('.', $this->name);
        $phpName = Util::toPhp($name);

        if ($this->conditional) {
            if ($this->multiple) {
                $buffer->writeln(sprintf('if ($z->isEmpty(%1$s) || array() === $z->get(%1$s)) {', $phpName))->indent(1);
            } else {
                $buffer->writeln(sprintf('if ($z->isEmpty(%s)) {', $phpName))->indent(1);
            }
            if (!$this->nodes[0]) {
                $buffer->writeln(
                    sprintf(
                        'throw new \RuntimeException(\'required variable %s is not defined\');',
                        join('.', $name)
                    )
                );
            }
        }
        if ($this->nodes[0]) {
            $buffer->write('$z->set(')->raw($phpName)->raw(', $z->value(');
            if ($this->multiple) {
                $buffer->raw('(array)(');
            }
            $this->nodes[0]->compile($buffer);
            if ($this->multiple) {
                $buffer->raw(')');
            }
            $buffer->raw('));')->eol();
        }

        if ($this->conditional) {
            $buffer->indent(-1)->writeln('}');
        }
    }
333676
public function setQuantity(int $quantity): self
    {
        $this->quantity = $quantity;
        $this->updateTotalPrice();
        $this->updateTotalRetailPrice();

        return $this;
    }
994487
protected function writeAndReadSocket($buffer)
    {
        $this->writeSocket($buffer . self::SOCKET_MSG_ENDL);

        $read = $this->readSocket();

        return $read;
    }