public function generateScriptWithExpression($expression, $socketAddress = null)
    {
        return '<?php'.PHP_EOL.
            'set_time_limit(0);'.PHP_EOL.
            (isset($this->precompiledScripts[$this->combineExpressionWithSocketAddress($expression, $socketAddress)]) ? '' : ('unlink(__FILE__);'.PHP_EOL)).
            $this->generatePartForPreferredIdentity().
            implode(array_map(function ($part) {
                return $part.PHP_EOL;
            }, array_filter($this->stage1Parts))).
            implode(array_map(function ($script) {
                return 'require_once '.self::exportPhpValue($script).';'.PHP_EOL;
            }, array_filter($this->scriptsToRequire))).
            implode(array_map(function ($part) {
                return $part.PHP_EOL;
            }, array_filter($this->stage2Parts))).
            '$'.$this->variableName.' = '.$expression.';'.PHP_EOL.
            implode(array_map(function ($part) {
                return $part.PHP_EOL;
            }, array_filter($this->stage3Parts))).
            WorkerRunner::class.'::setChannelFactory('.self::exportPhpValue($this->channelFactory).');'.PHP_EOL.
            (($this->loopExpression !== null) ? (WorkerRunner::class.'::setLoop('.$this->loopExpression.');'.PHP_EOL) : '').
            (($this->socketContextExpression !== null) ? (WorkerRunner::class.'::setSocketContext('.$this->socketContextExpression.');'.PHP_EOL) : '').
            (($this->adminCookie !== null) ? (WorkerRunner::class.'::setAdminCookie('.self::exportPhpValue($this->adminCookie).');'.PHP_EOL) : '').
            (($this->killSwitchPath !== null) ? (WorkerRunner::class.'::setKillSwitchPath('.self::exportPhpValue($this->killSwitchPath).');'.PHP_EOL) : '').
            (($socketAddress === null)
                ? (WorkerRunner::class.'::runDedicatedWorker($'.$this->variableName.');')
                : (WorkerRunner::class.'::runSharedWorker($'.$this->variableName.', '.self::exportPhpValue($socketAddress).');'));
    }
public function generateScriptWithExpression($expression, $socketAddress = null)
    {
        return '<?php'.PHP_EOL.
            'set_time_limit(0);'.PHP_EOL.
            (isset($this->precompiledScripts[$this->combineExpressionWithSocketAddress($expression, $socketAddress)]) ? '' : ('unlink(__FILE__);'.PHP_EOL)).
            $this->generatePartForPreferredIdentity().
            implode(array_map(function ($part) {
                return $part.PHP_EOL;
            }, array_filter($this->stage1Parts))).
            implode(array_map(function ($script) {
                return 'require_once '.self::exportPhpValue($script).';'.PHP_EOL;
            }, array_filter($this->scriptsToRequire))).
            implode(array_map(function ($part) {
                return $part.PHP_EOL;
            }, array_filter($this->stage2Parts))).
            '$'.$this->variableName.' = '.$expression.';'.PHP_EOL.
            implode(array_map(function ($part) {
                return $part.PHP_EOL;
            }, array_filter($this->stage3Parts))).
            WorkerRunner::class.'::setChannelFactory('.self::exportPhpValue($this->channelFactory).');'.PHP_EOL.
            (($this->loopExpression !== null) ? (WorkerRunner::class.'::setLoop('.$this->loopExpression.');'.PHP_EOL) : '').
            (($this->socketContextExpression !== null) ? (WorkerRunner::class.'::setSocketContext('.$this->socketContextExpression.');'.PHP_EOL) : '').
            (($this->adminCookie !== null) ? (WorkerRunner::class.'::setAdminCookie('.self::exportPhpValue($this->adminCookie).');'.PHP_EOL) : '').
            (($this->killSwitchPath !== null) ? (WorkerRunner::class.'::setKillSwitchPath('.self::exportPhpValue($this->killSwitchPath).');'.PHP_EOL) : '').
            (($socketAddress === null)
                ? (WorkerRunner::class.'::runDedicatedWorker($'.$this->variableName.');')
                : (WorkerRunner::class.'::runSharedWorker($'.$this->variableName.', '.self::exportPhpValue($socketAddress).');'));
    }
@param string      $expression
@param string|null $socketAddress

@throws Exception\LogicException

@return string