Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / psy / psysh / src / ExecutionLoopClosure.php
index e34848ed5a0b84949323085a9d3da37f506a2a66..5b8238cf632364ac80f3eb5a9b09aaf3fc656380 100644 (file)
@@ -31,7 +31,7 @@ class ExecutionLoopClosure extends ExecutionClosure
     {
         $this->setClosure($__psysh__, function () use ($__psysh__) {
             // Restore execution scope variables
-            extract($__psysh__->getScopeVariables(false));
+            \extract($__psysh__->getScopeVariables(false));
 
             do {
                 $__psysh__->beforeLoop();
@@ -40,40 +40,45 @@ class ExecutionLoopClosure extends ExecutionClosure
                     $__psysh__->getInput();
 
                     try {
+                        // Pull in any new execution scope variables
+                        if ($__psysh__->getLastExecSuccess()) {
+                            \extract($__psysh__->getScopeVariablesDiff(\get_defined_vars()));
+                        }
+
                         // Buffer stdout; we'll need it later
-                        ob_start([$__psysh__, 'writeStdout'], 1);
+                        \ob_start([$__psysh__, 'writeStdout'], 1);
 
                         // Convert all errors to exceptions
-                        set_error_handler([$__psysh__, 'handleError']);
+                        \set_error_handler([$__psysh__, 'handleError']);
 
                         // Evaluate the current code buffer
                         $_ = eval($__psysh__->onExecute($__psysh__->flushCode() ?: ExecutionClosure::NOOP_INPUT));
                     } catch (\Throwable $_e) {
                         // Clean up on our way out.
-                        restore_error_handler();
-                        if (ob_get_level() > 0) {
-                            ob_end_clean();
+                        \restore_error_handler();
+                        if (\ob_get_level() > 0) {
+                            \ob_end_clean();
                         }
 
                         throw $_e;
                     } catch (\Exception $_e) {
                         // Clean up on our way out.
-                        restore_error_handler();
-                        if (ob_get_level() > 0) {
-                            ob_end_clean();
+                        \restore_error_handler();
+                        if (\ob_get_level() > 0) {
+                            \ob_end_clean();
                         }
 
                         throw $_e;
                     }
 
                     // Won't be needing this anymore
-                    restore_error_handler();
+                    \restore_error_handler();
 
                     // Flush stdout (write to shell output, plus save to magic variable)
-                    ob_end_flush();
+                    \ob_end_flush();
 
                     // Save execution scope variables for next time
-                    $__psysh__->setScopeVariables(get_defined_vars());
+                    $__psysh__->setScopeVariables(\get_defined_vars());
 
                     $__psysh__->writeReturnValue($_);
                 } catch (BreakException $_e) {