Example #1
0
 /**
  * @return callable
  */
 private function getClosure()
 {
     $closure = function () {
         extract($this->shellSoul->getScopeVariables());
         try {
             $this->shellSoul->addCode($this->code);
             // evaluate the current code buffer
             ob_start([$this->shellSoul, 'writeStdout'], version_compare(PHP_VERSION, '5.4', '>=') ? 1 : 2);
             set_error_handler([$this->shellSoul, 'handleError']);
             $_ = eval($this->shellSoul->flushCode() ?: Loop::NOOP_INPUT);
             restore_error_handler();
             ob_end_flush();
             $this->shellSoul->writeReturnValue($_);
         } catch (BreakException $_e) {
             restore_error_handler();
             if (ob_get_level() > 0) {
                 ob_end_clean();
             }
             $this->shellSoul->writeException($_e);
             return;
         } catch (ThrowUpException $_e) {
             restore_error_handler();
             if (ob_get_level() > 0) {
                 ob_end_clean();
             }
             $this->shellSoul->writeException($_e);
             throw $_e;
         } catch (\Exception $_e) {
             restore_error_handler();
             if (ob_get_level() > 0) {
                 ob_end_clean();
             }
             $this->shellSoul->writeException($_e);
         }
         $this->shellSoul->setScopeVariables(get_defined_vars());
     };
     return $closure;
 }
Example #2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->psysh->debug($this->psysh->getScopeVariables());
 }