public function marshall()
    {
        $collection = $this->getToMarshall();
        $ctx = $this->getContext();
        $access = $ctx->getStreamAccess();

        $valueArray = $collection->getArrayCopy();
        $valueArrayVarName = $ctx->generateVariableName($valueArray);

        $arrayArgs = new PhpArgumentCollection();
        if (($count = count($collection)) > 0) {
            foreach ($ctx->popFromVariableStack($count) as $itemName) {
                $arrayArgs[] = new PhpArgument(new PhpVariable($itemName));
            }
        }

        try {
            $access->writeVariable($valueArrayVarName);
            $access->writeEquals($ctx->mustFormatOutput());
            $access->writeFunctionCall('array', $arrayArgs);
            $access->writeSemicolon($ctx->mustFormatOutput());

            $collectionVarName = $ctx->generateVariableName($collection);
            $access->writeVariable($collectionVarName);
            $access->writeEquals($ctx->mustFormatOutput());
            $collectionArgs = new PhpArgumentCollection(array(new PhpArgument(new PhpVariable($valueArrayVarName))));
            $access->writeInstantiation(get_class($collection), $collectionArgs);
            $access->writeSemicolon($ctx->mustFormatOutput());

            $ctx->pushOnVariableStack($collectionVarName);
        } catch (StreamAccessException $e) {
            $msg = "An error occured while marshalling a collection into PHP source code.";
            throw new PhpMarshallingException($msg, PhpMarshallingException::STREAM, $e);
        }
    }
public function marshall()
    {
        $collection = $this->getToMarshall();
        $ctx = $this->getContext();
        $access = $ctx->getStreamAccess();

        $valueArray = $collection->getArrayCopy();
        $valueArrayVarName = $ctx->generateVariableName($valueArray);

        $arrayArgs = new PhpArgumentCollection();
        if (($count = count($collection)) > 0) {
            foreach ($ctx->popFromVariableStack($count) as $itemName) {
                $arrayArgs[] = new PhpArgument(new PhpVariable($itemName));
            }
        }

        try {
            $access->writeVariable($valueArrayVarName);
            $access->writeEquals($ctx->mustFormatOutput());
            $access->writeFunctionCall('array', $arrayArgs);
            $access->writeSemicolon($ctx->mustFormatOutput());

            $collectionVarName = $ctx->generateVariableName($collection);
            $access->writeVariable($collectionVarName);
            $access->writeEquals($ctx->mustFormatOutput());
            $collectionArgs = new PhpArgumentCollection(array(new PhpArgument(new PhpVariable($valueArrayVarName))));
            $access->writeInstantiation(get_class($collection), $collectionArgs);
            $access->writeSemicolon($ctx->mustFormatOutput());

            $ctx->pushOnVariableStack($collectionVarName);
        } catch (StreamAccessException $e) {
            $msg = "An error occured while marshalling a collection into PHP source code.";
            throw new PhpMarshallingException($msg, PhpMarshallingException::STREAM, $e);
        }
    }
public function marshall ( ) { $ collection = $ this -> getToMarshall ( ) ; $ ctx = $ this -> getContext ( ) ; $ access = $ ctx -> getStreamAccess ( ) ; $ valueArray = $ collection -> getArrayCopy ( ) ; $ valueArrayVarName = $ ctx -> generateVariableName ( $ valueArray ) ; $ arrayArgs = new PhpArgumentCollection ( ) ; if ( ( $ count = count ( $ collection ) ) > 0 ) { foreach ( $ ctx -> popFromVariableStack ( $ count ) as $ itemName ) { $ arrayArgs [ ] = new PhpArgument ( new PhpVariable ( $ itemName ) ) ; } } try { $ access -> writeVariable ( $ valueArrayVarName ) ; $ access -> writeEquals ( $ ctx -> mustFormatOutput ( ) ) ; $ access -> writeFunctionCall ( 'array' , $ arrayArgs ) ; $ access -> writeSemicolon ( $ ctx -> mustFormatOutput ( ) ) ; $ collectionVarName = $ ctx -> generateVariableName ( $ collection ) ; $ access -> writeVariable ( $ collectionVarName ) ; $ access -> writeEquals ( $ ctx -> mustFormatOutput ( ) ) ; $ collectionArgs = new PhpArgumentCollection ( array ( new PhpArgument ( new PhpVariable ( $ valueArrayVarName ) ) ) ) ; $ access -> writeInstantiation ( get_class ( $ collection ) , $ collectionArgs ) ; $ access -> writeSemicolon ( $ ctx -> mustFormatOutput ( ) ) ; $ ctx -> pushOnVariableStack ( $ collectionVarName ) ; } catch ( StreamAccessException $ e ) { $ msg = "An error occured while marshalling a collection into PHP source code." ; throw new PhpMarshallingException ( $ msg , PhpMarshallingException :: STREAM , $ e ) ; } }
Marshall AbstractCollection objects into PHP source code.

@throws \qtism\data\storage\php\marshalling\PhpMarshallingException If something wrong happens during marshalling.
Marshall AbstractCollection objects into PHP source code .