GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#55)
by
unknown
01:07
created

CustomExecutionClosure   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 12
lcom 0
cbo 5
dl 0
loc 72
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
C __construct() 0 66 12
1
<?php
2
3
namespace Spatie\WebTinker;
4
5
use Psy\Exception\BreakException;
6
use Psy\Exception\ErrorException;
7
use Psy\Exception\ThrowUpException;
8
use Psy\Exception\TypeErrorException;
9
use Psy\ExecutionClosure;
10
use Psy\Shell;
11
12
/**
13
 * The custom execustion closure
14
 *
15
 * This class is base on the Psy\ExecutionLoopClosure
16
 * Extracted the do while loop and removed the loop
17
 * To avoid infinite looping on execution
18
 */
19
class CustomExecutionClosure extends ExecutionClosure
20
{
21
    /**
22
     * @param Shell $__psysh__
23
     */
24
    public function __construct(Shell $__psysh__)
25
    {
26
        $this->setClosure($__psysh__, function () use ($__psysh__) {
27
            // Restore execution scope variables
28
            \extract($__psysh__->getScopeVariables(false));
0 ignored issues
show
Bug introduced by
$__psysh__->getScopeVariables(false) cannot be passed to extract() as the parameter $var_array expects a reference.
Loading history...
29
30
            try {
31
                $__psysh__->getInput();
32
33
                try {
34
                    // Pull in any new execution scope variables
35
                    if ($__psysh__->getLastExecSuccess()) {
36
                        \extract($__psysh__->getScopeVariablesDiff(\get_defined_vars()));
0 ignored issues
show
Bug introduced by
$__psysh__->getScopeVari...ff(\get_defined_vars()) cannot be passed to extract() as the parameter $var_array expects a reference.
Loading history...
37
                    }
38
39
                    // Buffer stdout; we'll need it later
40
                    \ob_start([$__psysh__, 'writeStdout'], 1);
41
42
                    // Convert all errors to exceptions
43
                    \set_error_handler([$__psysh__, 'handleError']);
44
45
                    // Evaluate the current code buffer
46
                    $_ = eval($__psysh__->onExecute($__psysh__->flushCode() ?: ExecutionClosure::NOOP_INPUT));
47
                } catch (\Throwable $_e) {
48
                    // Clean up on our way out.
49
                    if (\ob_get_level() > 0) {
50
                        \ob_end_clean();
51
                    }
52
53
                    throw $_e;
54
                } catch (\Exception $_e) {
55
                    // Clean up on our way out.
56
                    if (\ob_get_level() > 0) {
57
                        \ob_end_clean();
58
                    }
59
60
                    throw $_e;
61
                } finally {
62
                    // Won't be needing this anymore
63
                    \restore_error_handler();
64
                }
65
66
                // Flush stdout (write to shell output, plus save to magic variable)
67
                \ob_end_flush();
68
69
                // Save execution scope variables for next time
70
                $__psysh__->setScopeVariables(\get_defined_vars());
71
72
                $__psysh__->writeReturnValue($_);
73
            } catch (BreakException $_e) {
74
                $__psysh__->writeException($_e);
75
76
                return;
77
            } catch (ThrowUpException $_e) {
78
                $__psysh__->writeException($_e);
79
80
                throw $_e;
81
            } catch (\TypeError $_e) {
82
                $__psysh__->writeException(TypeErrorException::fromTypeError($_e));
83
            } catch (\Error $_e) {
84
                $__psysh__->writeException(ErrorException::fromError($_e));
85
            } catch (\Exception $_e) {
86
                $__psysh__->writeException($_e);
87
            }
88
        });
89
    }
90
}