Updated from some -dev modules to alpha, beta or full releases
[yaffs-website] / vendor / psy / psysh / src / ExecutionClosure.php
index d2c551b8c14d2409d1d995b532177e8993cb5950..29a3bcc6d9169eeef89614069aec0a800b3ae28b 100644 (file)
@@ -25,7 +25,7 @@ class ExecutionClosure
      */
     public function __construct(Shell $__psysh__)
     {
-        $exec = function () use ($__psysh__) {
+        $this->setClosure($__psysh__, function () use ($__psysh__) {
             try {
                 // Restore execution scope variables
                 extract($__psysh__->getScopeVariables(false));
@@ -66,20 +66,27 @@ class ExecutionClosure
             $__psysh__->setScopeVariables(get_defined_vars());
 
             return $_;
-        };
+        });
+    }
 
+    /**
+     * Set the closure instance.
+     *
+     * @param Shell    $psysh
+     * @param \Closure $closure
+     */
+    protected function setClosure(Shell $shell, \Closure $closure)
+    {
         if (self::shouldBindClosure()) {
-            $that = $__psysh__->getBoundObject();
+            $that = $shell->getBoundObject();
             if (is_object($that)) {
-                $this->closure = $exec->bindTo($that, get_class($that));
+                $closure = $closure->bindTo($that, get_class($that));
             } else {
-                $this->closure = $exec->bindTo(null, null);
+                $closure = $closure->bindTo(null, $shell->getBoundClass());
             }
-
-            return;
         }
 
-        $this->closure = $exec;
+        $this->closure = $closure;
     }
 
     /**