src/AbstractEngine.php
public function executeCommand(CommandInterface $command)
    {
        $this->storeCommand($command);
        
        $this->performExecution(function () use ($command) {
            
            $priority = $command->getPriority();
            
            while (!empty($this->commands) && $this->commands[0]->getPriority() >= $priority) {
                $cmd = array_shift($this->commands);
                
                $this->commandResults[$cmd] = $cmd->execute($this);
                $this->executionCount++;
                
                if ($cmd === $command) {
                    // Bail out as soon as target command has been executed.
                    break;
                }
            }
            
            if ($this->executionDepth == 1) {
                // Execute remaining commands if this is a top level execution.
                while (!empty($this->commands)) {
                    $cmd = array_shift($this->commands);
                    
                    $this->commandResults[$cmd] = $cmd->execute($this);
                    $this->executionCount++;
                }
            }
        });
        
        try {
            if ($this->commandResults->offsetExists($command)) {
                return $this->commandResults[$command];
            }
        } finally {
            if ($this->executionDepth == 0) {
                // Free command result memory after top level execution.
                $this->commandResults = new \SplObjectStorage();
            }
        }
    }
public function executeCommand(CommandInterface $command)
    {
        $this->storeCommand($command);
        
        $this->performExecution(function () use ($command) {
            
            $priority = $command->getPriority();
            
            while (!empty($this->commands) && $this->commands[0]->getPriority() >= $priority) {
                $cmd = array_shift($this->commands);
                
                $this->commandResults[$cmd] = $cmd->execute($this);
                $this->executionCount++;
                
                if ($cmd === $command) {
                    // Bail out as soon as target command has been executed.
                    break;
                }
            }
            
            if ($this->executionDepth == 1) {
                // Execute remaining commands if this is a top level execution.
                while (!empty($this->commands)) {
                    $cmd = array_shift($this->commands);
                    
                    $this->commandResults[$cmd] = $cmd->execute($this);
                    $this->executionCount++;
                }
            }
        });
        
        try {
            if ($this->commandResults->offsetExists($command)) {
                return $this->commandResults[$command];
            }
        } finally {
            if ($this->executionDepth == 0) {
                // Free command result memory after top level execution.
                $this->commandResults = new \SplObjectStorage();
            }
        }
    }
{@inheritdoc}