Chris@0: loadIncludes($shell); Chris@0: Chris@0: $closure = new ExecutionLoopClosure($shell); Chris@0: $closure->execute(); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Load user-defined includes. Chris@0: * Chris@0: * @param Shell $shell Chris@0: */ Chris@0: protected function loadIncludes(Shell $shell) Chris@0: { Chris@0: // Load user-defined includes Chris@0: $load = function (Shell $__psysh__) { Chris@4: \set_error_handler([$__psysh__, 'handleError']); Chris@0: foreach ($__psysh__->getIncludes() as $__psysh_include__) { Chris@0: try { Chris@0: include $__psysh_include__; Chris@0: } catch (\Error $_e) { Chris@0: $__psysh__->writeException(ErrorException::fromError($_e)); Chris@0: } catch (\Exception $_e) { Chris@0: $__psysh__->writeException($_e); Chris@0: } Chris@0: } Chris@4: \restore_error_handler(); Chris@0: unset($__psysh_include__); Chris@0: Chris@0: // Override any new local variables with pre-defined scope variables Chris@4: \extract($__psysh__->getScopeVariables(false)); Chris@0: Chris@0: // ... then add the whole mess of variables back. Chris@4: $__psysh__->setScopeVariables(\get_defined_vars()); Chris@0: }; Chris@0: Chris@0: $load($shell); Chris@0: } Chris@0: }