Mercurial > hg > cmmr2012-drupal-site
comparison vendor/psy/psysh/src/ExecutionLoopClosure.php @ 4:a9cd425dd02b
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:11:55 +0000 |
parents | c75dbcec494b |
children |
comparison
equal
deleted
inserted
replaced
3:307d7a7fd348 | 4:a9cd425dd02b |
---|---|
29 */ | 29 */ |
30 public function __construct(Shell $__psysh__) | 30 public function __construct(Shell $__psysh__) |
31 { | 31 { |
32 $this->setClosure($__psysh__, function () use ($__psysh__) { | 32 $this->setClosure($__psysh__, function () use ($__psysh__) { |
33 // Restore execution scope variables | 33 // Restore execution scope variables |
34 extract($__psysh__->getScopeVariables(false)); | 34 \extract($__psysh__->getScopeVariables(false)); |
35 | 35 |
36 do { | 36 do { |
37 $__psysh__->beforeLoop(); | 37 $__psysh__->beforeLoop(); |
38 | 38 |
39 try { | 39 try { |
40 $__psysh__->getInput(); | 40 $__psysh__->getInput(); |
41 | 41 |
42 try { | 42 try { |
43 // Pull in any new execution scope variables | |
44 if ($__psysh__->getLastExecSuccess()) { | |
45 \extract($__psysh__->getScopeVariablesDiff(\get_defined_vars())); | |
46 } | |
47 | |
43 // Buffer stdout; we'll need it later | 48 // Buffer stdout; we'll need it later |
44 ob_start([$__psysh__, 'writeStdout'], 1); | 49 \ob_start([$__psysh__, 'writeStdout'], 1); |
45 | 50 |
46 // Convert all errors to exceptions | 51 // Convert all errors to exceptions |
47 set_error_handler([$__psysh__, 'handleError']); | 52 \set_error_handler([$__psysh__, 'handleError']); |
48 | 53 |
49 // Evaluate the current code buffer | 54 // Evaluate the current code buffer |
50 $_ = eval($__psysh__->onExecute($__psysh__->flushCode() ?: ExecutionClosure::NOOP_INPUT)); | 55 $_ = eval($__psysh__->onExecute($__psysh__->flushCode() ?: ExecutionClosure::NOOP_INPUT)); |
51 } catch (\Throwable $_e) { | 56 } catch (\Throwable $_e) { |
52 // Clean up on our way out. | 57 // Clean up on our way out. |
53 restore_error_handler(); | 58 \restore_error_handler(); |
54 if (ob_get_level() > 0) { | 59 if (\ob_get_level() > 0) { |
55 ob_end_clean(); | 60 \ob_end_clean(); |
56 } | 61 } |
57 | 62 |
58 throw $_e; | 63 throw $_e; |
59 } catch (\Exception $_e) { | 64 } catch (\Exception $_e) { |
60 // Clean up on our way out. | 65 // Clean up on our way out. |
61 restore_error_handler(); | 66 \restore_error_handler(); |
62 if (ob_get_level() > 0) { | 67 if (\ob_get_level() > 0) { |
63 ob_end_clean(); | 68 \ob_end_clean(); |
64 } | 69 } |
65 | 70 |
66 throw $_e; | 71 throw $_e; |
67 } | 72 } |
68 | 73 |
69 // Won't be needing this anymore | 74 // Won't be needing this anymore |
70 restore_error_handler(); | 75 \restore_error_handler(); |
71 | 76 |
72 // Flush stdout (write to shell output, plus save to magic variable) | 77 // Flush stdout (write to shell output, plus save to magic variable) |
73 ob_end_flush(); | 78 \ob_end_flush(); |
74 | 79 |
75 // Save execution scope variables for next time | 80 // Save execution scope variables for next time |
76 $__psysh__->setScopeVariables(get_defined_vars()); | 81 $__psysh__->setScopeVariables(\get_defined_vars()); |
77 | 82 |
78 $__psysh__->writeReturnValue($_); | 83 $__psysh__->writeReturnValue($_); |
79 } catch (BreakException $_e) { | 84 } catch (BreakException $_e) { |
80 $__psysh__->writeException($_e); | 85 $__psysh__->writeException($_e); |
81 | 86 |