Marshall the PHP scalar value to be marshalled into PHP source code.

@throws \qtism\data\storage\php\marshalling\PhpMarshallingException If an error occurs while marshalling.
762344
public function marshall()
    {
        $ctx = $this->getContext();
        $streamAccess = $ctx->getStreamAccess();

        try {
            $scalar = $this->getToMarshall();
            $varName = $this->getContext()->generateVariableName($scalar);

            $streamAccess->writeVariable($varName);
            $streamAccess->writeEquals($ctx->mustFormatOutput());
            $streamAccess->writeScalar($scalar);
            $streamAccess->writeSemicolon($ctx->mustFormatOutput());

            $ctx->pushOnVariableStack($varName);
        } catch (StreamAccessException $e) {
            $msg = "An error occured while marshalling the scalar value '${scalar}'.";
            throw new PhpMarshallingException($msg, PhpMarshallingException::STREAM, $e);
        }
    }
833943
protected function marshall(QtiComponent $component)
    {
        $element = static::getDOMCradle()->createElement($component->getQtiClassName());

        $this->setDOMElementAttribute($element, 'identifier', $component->getIdentifier());
        $this->setDOMElementAttribute($element, 'required', $component->isRequired());
        $this->setDOMElementAttribute($element, 'fixed', $component->isFixed());

        foreach ($component->getPreConditions() as $preCondition) {
            $marshaller = $this->getMarshallerFactory()->createMarshaller($preCondition);
            $element->appendChild($marshaller->marshall($preCondition));
        }

        foreach ($component->getBranchRules() as $branchRule) {
            $marshaller = $this->getMarshallerFactory()->createMarshaller($branchRule);
            $element->appendChild($marshaller->marshall($branchRule));
        }

        if ($component->getItemSessionControl() != null) {
            $marshaller = $this->getMarshallerFactory()->createMarshaller($component->getItemSessionControl());
            $element->appendChild($marshaller->marshall($component->getItemSessionControl()));
        }

        if ($component->getTimeLimits() != null) {
            $marshaller = $this->getMarshallerFactory()->createMarshaller($component->getTimeLimits());
            $element->appendChild($marshaller->marshall($component->getTimeLimits()));
        }

        return $element;
    }
514488
public void marshalling(Xdr xdr) {
        super.marshalling(xdr);
        xdr.putLong(_offset);
        xdr.putUnsignedInt(_size);
    }
569696
public static XContentBuilder marshall(ApiDefinitionBean bean) throws StorageException {
        try (XContentBuilder builder = XContentFactory.jsonBuilder()) {
            preMarshall(bean);
            builder
                .startObject()
                    .field("data", bean.getData())
                .endObject();
            postMarshall(bean);
            return builder;
        } catch (IOException e) {
            throw new StorageException(e);
        }
    }
1295648
ModuleMarshal marshal(Class<?> sourceType)
  {
    ModuleMarshal marshal = _marshalSourceMap.get(sourceType);
    
    if (marshal == null) {
      marshal = marshalImpl(sourceType);
      _marshalSourceMap.put(sourceType, marshal);
    }
    
    return marshal;
  }
328242
private static function _marshalProtocolVersion($server)
    {
        if (!isset($server['SERVER_PROTOCOL'])) {
            return '1.1';
        }

        if (!preg_match(
            '#^(HTTP/)?(?P<version>[1-9]\d*(?:\.\d)?)$#',
            $server['SERVER_PROTOCOL'], $matches
        )
        ) {
            throw new UnexpectedValueException(
                sprintf(
                    'Unrecognized protocol version (%s)',
                    $server['SERVER_PROTOCOL']
                )
            );
        }

        return $matches['version'];
    }
178899
protected void setMarshalledBytes() {
        int len = getName().length();
        this.marshalledBytes = new byte[len + BNFHeaders.KEY_VALUE_SEPARATOR.length];
        System.arraycopy(getByteArray(), 0, this.marshalledBytes, 0, len);
        System.arraycopy(BNFHeaders.KEY_VALUE_SEPARATOR, 0, this.marshalledBytes, len, BNFHeaders.KEY_VALUE_SEPARATOR.length);
    }
118121
protected function postGetValue()
    {
        if (is_null($this->value)) {
            $val = @unserialize($this->strval);
            $this->value = false === $val ? $this->strval : $val;
        }
        return $this->value;
    }
420747
protected function marshall(QtiComponent $component)
    {
        $element = static::getDOMCradle()->createElement($component->getQtiClassName());
        foreach ($component->getInterpolationTableEntries() as $interpolationTableEntry) {
            $marshaller = $this->getMarshallerFactory()->createMarshaller($interpolationTableEntry, array($this->getBaseType()));
            $element->appendChild($marshaller->marshall($interpolationTableEntry));
        }

        if ($component->getDefaultValue() !== null) {
            $this->setDOMElementAttribute($element, 'defaultValue', $component->getDefaultValue());
        }

        return $element;
    }
319013
public function getValues()
    {
        if (!$this->storeSerialized) {
            return $this->values;
        }

        $values = $this->values;
        foreach ($values as $k => $v) {
            if (null === $v || 'N;' === $v) {
                continue;
            }
            if (!\is_string($v) || !isset($v[2]) || ':' !== $v[1]) {
                $values[$k] = serialize($v);
            }
        }

        return $values;
    }
984353
static byte[] marshallIDL5(final AttributeImpl attribute) throws DevFailed {
        XLOGGER.entry();
        final AttributeValue_5 attributeValue = TangoIDLAttributeUtil.toAttributeValue5(attribute,
                attribute.getReadValue(), attribute.getWriteValue());
        return marshallIDL5(attributeValue);
    }
150097
public Marshaller getMarshaller(boolean reuse)
    throws JAXBException {
    if (!reuse || this.marshaller == null) {
      Marshaller marshaller = context.createMarshaller();
      marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
      marshaller.setProperty(Marshaller.JAXB_ENCODING,         "UTF-8");
      this.marshaller = marshaller;
    }
    return this.marshaller;
  }
322106
public function unserialize($value)
    {
        if ($value === null || is_scalar($value)) {
            $this->str = unserialize($value);
        } else {
            throw new \InvalidArgumentException(sprintf('HString cannot unserialize a %s', Helper::getType($value)));
        }
    }
1266556
public void marshall(MarshallLocation marshallLocation, Object val) {
        marshallerRegistry().getMarshaller(marshallLocation, val).marshall(val, this, null);
    }
17003
public static void marshallByteArray(byte[] array, ObjectOutput out) throws IOException {
      final int size = array == null ? NULL_VALUE : array.length;
      marshallSize(out, size);
      if (size <= 0) {
         return;
      }
      out.write(array);
   }
1230780
protected function marshall(QtiComponent $component)
    {
        $element = parent::marshall($component);

        foreach ($component->getResponseDeclarations() as $responseDeclaration) {
            $marshaller = $this->getMarshallerFactory()->createMarshaller($responseDeclaration);
            $element->appendChild($marshaller->marshall($responseDeclaration));
        }

        foreach ($component->getOutcomeDeclarations() as $outcomeDeclaration) {
            $marshaller = $this->getMarshallerFactory()->createMarshaller($outcomeDeclaration);
            $element->appendChild($marshaller->marshall($outcomeDeclaration));
        }
        
        foreach ($component->getTemplateDeclarations() as $templateDeclaration) {
            $marshaller = $this->getMarshallerFactory()->createMarshaller($templateDeclaration);
            $element->appendChild($marshaller->marshall($templateDeclaration));
        }
        
        if ($component->hasTemplateProcessing() === true) {
            $marshaller = $this->getMarshallerFactory()->createMarshaller($component->getTemplateProcessing());
            $templProcElt = $marshaller->marshall($component->getTemplateProcessing());
            $element->appendChild($templProcElt);
        }
        
        if ($component->hasResponseProcessing() === true) {
            $marshaller = $this->getMarshallerFactory()->createMarshaller($component->getResponseProcessing());
            $respProcElt = $marshaller->marshall($component->getResponseProcessing());
            $element->appendChild($respProcElt);
        }
        
        foreach ($component->getModalFeedbackRules() as $modalFeedbackRule) {
            $marshaller = $this->getMarshallerFactory()->createMarshaller($modalFeedbackRule);
            $element->appendChild($marshaller->marshall($modalFeedbackRule));
        }
        
        foreach ($component->getShufflings() as $shuffling) {
            $marshaller = $this->getMarshallerFactory()->createMarshaller($shuffling);
            $element->appendChild($marshaller->marshall($shuffling));
        }
        
        foreach ($component->getResponseValidityConstraints() as $responseValidityConstraint) {
            $marshaller = $this->getMarshallerFactory()->createMarshaller($responseValidityConstraint);
            $element->appendChild($marshaller->marshall($responseValidityConstraint));
        }
        
        $this->setDOMElementAttribute($element, 'adaptive', $component->isAdaptive());
        $this->setDOMElementAttribute($element, 'timeDependent', $component->isTimeDependent());
        
        $endAttemptIdentifiers = $component->getEndAttemptIdentifiers();
        if (count($endAttemptIdentifiers) > 0) {
            $this->setDOMElementAttribute($element, 'endAttemptIdentifiers', implode("\x20", $endAttemptIdentifiers->getArrayCopy()));
        }

        return $element;
    }
835487
public void marshalling(Xdr xdr) {
        super.marshalling(xdr);
        xdr.putByteArray(_parentDirectoryFileHandle);
        xdr.putString(_name);
    }