Completed
Push — master ( 8e973a...811a95 )
by
unknown
03:40 queued 01:04
created
php-scoper/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp.php 2 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -6,35 +6,35 @@
 block discarded – undo
6 6
 
7 7
 abstract class BinaryOp extends Expr
8 8
 {
9
-    /** @var Expr The left hand side expression */
10
-    public $left;
11
-    /** @var Expr The right hand side expression */
12
-    public $right;
9
+	/** @var Expr The left hand side expression */
10
+	public $left;
11
+	/** @var Expr The right hand side expression */
12
+	public $right;
13 13
 
14
-    /**
15
-     * Constructs a binary operator node.
16
-     *
17
-     * @param Expr  $left       The left hand side expression
18
-     * @param Expr  $right      The right hand side expression
19
-     * @param array $attributes Additional attributes
20
-     */
21
-    public function __construct(Expr $left, Expr $right, array $attributes = []) {
22
-        $this->attributes = $attributes;
23
-        $this->left = $left;
24
-        $this->right = $right;
25
-    }
14
+	/**
15
+	 * Constructs a binary operator node.
16
+	 *
17
+	 * @param Expr  $left       The left hand side expression
18
+	 * @param Expr  $right      The right hand side expression
19
+	 * @param array $attributes Additional attributes
20
+	 */
21
+	public function __construct(Expr $left, Expr $right, array $attributes = []) {
22
+		$this->attributes = $attributes;
23
+		$this->left = $left;
24
+		$this->right = $right;
25
+	}
26 26
 
27
-    public function getSubNodeNames() : array {
28
-        return ['left', 'right'];
29
-    }
27
+	public function getSubNodeNames() : array {
28
+		return ['left', 'right'];
29
+	}
30 30
 
31
-    /**
32
-     * Get the operator sigil for this binary operation.
33
-     *
34
-     * In the case there are multiple possible sigils for an operator, this method does not
35
-     * necessarily return the one used in the parsed code.
36
-     *
37
-     * @return string
38
-     */
39
-    abstract public function getOperatorSigil() : string;
31
+	/**
32
+	 * Get the operator sigil for this binary operation.
33
+	 *
34
+	 * In the case there are multiple possible sigils for an operator, this method does not
35
+	 * necessarily return the one used in the parsed code.
36
+	 *
37
+	 * @return string
38
+	 */
39
+	abstract public function getOperatorSigil() : string;
40 40
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,8 +4,7 @@
 block discarded – undo
4 4
 
5 5
 use PhpParser\Node\Expr;
6 6
 
7
-abstract class BinaryOp extends Expr
8
-{
7
+abstract class BinaryOp extends Expr {
9 8
     /** @var Expr The left hand side expression */
10 9
     public $left;
11 10
     /** @var Expr The right hand side expression */
Please login to merge, or discard this patch.
vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ErrorSuppress.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -6,25 +6,25 @@
 block discarded – undo
6 6
 
7 7
 class ErrorSuppress extends Expr
8 8
 {
9
-    /** @var Expr Expression */
10
-    public $expr;
9
+	/** @var Expr Expression */
10
+	public $expr;
11 11
 
12
-    /**
13
-     * Constructs an error suppress node.
14
-     *
15
-     * @param Expr  $expr       Expression
16
-     * @param array $attributes Additional attributes
17
-     */
18
-    public function __construct(Expr $expr, array $attributes = []) {
19
-        $this->attributes = $attributes;
20
-        $this->expr = $expr;
21
-    }
12
+	/**
13
+	 * Constructs an error suppress node.
14
+	 *
15
+	 * @param Expr  $expr       Expression
16
+	 * @param array $attributes Additional attributes
17
+	 */
18
+	public function __construct(Expr $expr, array $attributes = []) {
19
+		$this->attributes = $attributes;
20
+		$this->expr = $expr;
21
+	}
22 22
 
23
-    public function getSubNodeNames() : array {
24
-        return ['expr'];
25
-    }
23
+	public function getSubNodeNames() : array {
24
+		return ['expr'];
25
+	}
26 26
     
27
-    public function getType() : string {
28
-        return 'Expr_ErrorSuppress';
29
-    }
27
+	public function getType() : string {
28
+		return 'Expr_ErrorSuppress';
29
+	}
30 30
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,8 +4,7 @@
 block discarded – undo
4 4
 
5 5
 use PhpParser\Node\Expr;
6 6
 
7
-class ErrorSuppress extends Expr
8
-{
7
+class ErrorSuppress extends Expr {
9 8
     /** @var Expr Expression */
10 9
     public $expr;
11 10
 
Please login to merge, or discard this patch.
vendor/nikic/php-parser/lib/PhpParser/Node/Expr/NullsafeMethodCall.php 2 patches
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -9,37 +9,37 @@
 block discarded – undo
9 9
 
10 10
 class NullsafeMethodCall extends CallLike
11 11
 {
12
-    /** @var Expr Variable holding object */
13
-    public $var;
14
-    /** @var Identifier|Expr Method name */
15
-    public $name;
16
-    /** @var array<Arg|VariadicPlaceholder> Arguments */
17
-    public $args;
12
+	/** @var Expr Variable holding object */
13
+	public $var;
14
+	/** @var Identifier|Expr Method name */
15
+	public $name;
16
+	/** @var array<Arg|VariadicPlaceholder> Arguments */
17
+	public $args;
18 18
 
19
-    /**
20
-     * Constructs a nullsafe method call node.
21
-     *
22
-     * @param Expr                           $var        Variable holding object
23
-     * @param string|Identifier|Expr         $name       Method name
24
-     * @param array<Arg|VariadicPlaceholder> $args       Arguments
25
-     * @param array                          $attributes Additional attributes
26
-     */
27
-    public function __construct(Expr $var, $name, array $args = [], array $attributes = []) {
28
-        $this->attributes = $attributes;
29
-        $this->var = $var;
30
-        $this->name = \is_string($name) ? new Identifier($name) : $name;
31
-        $this->args = $args;
32
-    }
19
+	/**
20
+	 * Constructs a nullsafe method call node.
21
+	 *
22
+	 * @param Expr                           $var        Variable holding object
23
+	 * @param string|Identifier|Expr         $name       Method name
24
+	 * @param array<Arg|VariadicPlaceholder> $args       Arguments
25
+	 * @param array                          $attributes Additional attributes
26
+	 */
27
+	public function __construct(Expr $var, $name, array $args = [], array $attributes = []) {
28
+		$this->attributes = $attributes;
29
+		$this->var = $var;
30
+		$this->name = \is_string($name) ? new Identifier($name) : $name;
31
+		$this->args = $args;
32
+	}
33 33
 
34
-    public function getSubNodeNames() : array {
35
-        return ['var', 'name', 'args'];
36
-    }
34
+	public function getSubNodeNames() : array {
35
+		return ['var', 'name', 'args'];
36
+	}
37 37
     
38
-    public function getType() : string {
39
-        return 'Expr_NullsafeMethodCall';
40
-    }
38
+	public function getType() : string {
39
+		return 'Expr_NullsafeMethodCall';
40
+	}
41 41
 
42
-    public function getRawArgs(): array {
43
-        return $this->args;
44
-    }
42
+	public function getRawArgs(): array {
43
+		return $this->args;
44
+	}
45 45
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,8 +7,7 @@
 block discarded – undo
7 7
 use PhpParser\Node\Identifier;
8 8
 use PhpParser\Node\VariadicPlaceholder;
9 9
 
10
-class NullsafeMethodCall extends CallLike
11
-{
10
+class NullsafeMethodCall extends CallLike {
12 11
     /** @var Expr Variable holding object */
13 12
     public $var;
14 13
     /** @var Identifier|Expr Method name */
Please login to merge, or discard this patch.
php-scoper/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Isset_.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -6,25 +6,25 @@
 block discarded – undo
6 6
 
7 7
 class Isset_ extends Expr
8 8
 {
9
-    /** @var Expr[] Variables */
10
-    public $vars;
9
+	/** @var Expr[] Variables */
10
+	public $vars;
11 11
 
12
-    /**
13
-     * Constructs an array node.
14
-     *
15
-     * @param Expr[] $vars       Variables
16
-     * @param array  $attributes Additional attributes
17
-     */
18
-    public function __construct(array $vars, array $attributes = []) {
19
-        $this->attributes = $attributes;
20
-        $this->vars = $vars;
21
-    }
12
+	/**
13
+	 * Constructs an array node.
14
+	 *
15
+	 * @param Expr[] $vars       Variables
16
+	 * @param array  $attributes Additional attributes
17
+	 */
18
+	public function __construct(array $vars, array $attributes = []) {
19
+		$this->attributes = $attributes;
20
+		$this->vars = $vars;
21
+	}
22 22
 
23
-    public function getSubNodeNames() : array {
24
-        return ['vars'];
25
-    }
23
+	public function getSubNodeNames() : array {
24
+		return ['vars'];
25
+	}
26 26
     
27
-    public function getType() : string {
28
-        return 'Expr_Isset';
29
-    }
27
+	public function getType() : string {
28
+		return 'Expr_Isset';
29
+	}
30 30
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,8 +4,7 @@
 block discarded – undo
4 4
 
5 5
 use PhpParser\Node\Expr;
6 6
 
7
-class Isset_ extends Expr
8
-{
7
+class Isset_ extends Expr {
9 8
     /** @var Expr[] Variables */
10 9
     public $vars;
11 10
 
Please login to merge, or discard this patch.
php-scoper/vendor/nikic/php-parser/lib/PhpParser/Node/Identifier.php 2 patches
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -9,67 +9,67 @@
 block discarded – undo
9 9
  */
10 10
 class Identifier extends NodeAbstract
11 11
 {
12
-    /** @var string Identifier as string */
13
-    public $name;
12
+	/** @var string Identifier as string */
13
+	public $name;
14 14
 
15
-    private static $specialClassNames = [
16
-        'self'   => true,
17
-        'parent' => true,
18
-        'static' => true,
19
-    ];
15
+	private static $specialClassNames = [
16
+		'self'   => true,
17
+		'parent' => true,
18
+		'static' => true,
19
+	];
20 20
 
21
-    /**
22
-     * Constructs an identifier node.
23
-     *
24
-     * @param string $name       Identifier as string
25
-     * @param array  $attributes Additional attributes
26
-     */
27
-    public function __construct(string $name, array $attributes = []) {
28
-        $this->attributes = $attributes;
29
-        $this->name = $name;
30
-    }
21
+	/**
22
+	 * Constructs an identifier node.
23
+	 *
24
+	 * @param string $name       Identifier as string
25
+	 * @param array  $attributes Additional attributes
26
+	 */
27
+	public function __construct(string $name, array $attributes = []) {
28
+		$this->attributes = $attributes;
29
+		$this->name = $name;
30
+	}
31 31
 
32
-    public function getSubNodeNames() : array {
33
-        return ['name'];
34
-    }
32
+	public function getSubNodeNames() : array {
33
+		return ['name'];
34
+	}
35 35
 
36
-    /**
37
-     * Get identifier as string.
38
-     *
39
-     * @return string Identifier as string.
40
-     */
41
-    public function toString() : string {
42
-        return $this->name;
43
-    }
36
+	/**
37
+	 * Get identifier as string.
38
+	 *
39
+	 * @return string Identifier as string.
40
+	 */
41
+	public function toString() : string {
42
+		return $this->name;
43
+	}
44 44
 
45
-    /**
46
-     * Get lowercased identifier as string.
47
-     *
48
-     * @return string Lowercased identifier as string
49
-     */
50
-    public function toLowerString() : string {
51
-        return strtolower($this->name);
52
-    }
45
+	/**
46
+	 * Get lowercased identifier as string.
47
+	 *
48
+	 * @return string Lowercased identifier as string
49
+	 */
50
+	public function toLowerString() : string {
51
+		return strtolower($this->name);
52
+	}
53 53
 
54
-    /**
55
-     * Checks whether the identifier is a special class name (self, parent or static).
56
-     *
57
-     * @return bool Whether identifier is a special class name
58
-     */
59
-    public function isSpecialClassName() : bool {
60
-        return isset(self::$specialClassNames[strtolower($this->name)]);
61
-    }
54
+	/**
55
+	 * Checks whether the identifier is a special class name (self, parent or static).
56
+	 *
57
+	 * @return bool Whether identifier is a special class name
58
+	 */
59
+	public function isSpecialClassName() : bool {
60
+		return isset(self::$specialClassNames[strtolower($this->name)]);
61
+	}
62 62
 
63
-    /**
64
-     * Get identifier as string.
65
-     *
66
-     * @return string Identifier as string
67
-     */
68
-    public function __toString() : string {
69
-        return $this->name;
70
-    }
63
+	/**
64
+	 * Get identifier as string.
65
+	 *
66
+	 * @return string Identifier as string
67
+	 */
68
+	public function __toString() : string {
69
+		return $this->name;
70
+	}
71 71
     
72
-    public function getType() : string {
73
-        return 'Identifier';
74
-    }
72
+	public function getType() : string {
73
+		return 'Identifier';
74
+	}
75 75
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,8 +7,7 @@
 block discarded – undo
7 7
 /**
8 8
  * Represents a non-namespaced name. Namespaced names are represented using Name nodes.
9 9
  */
10
-class Identifier extends NodeAbstract
11
-{
10
+class Identifier extends NodeAbstract {
12 11
     /** @var string Identifier as string */
13 12
     public $name;
14 13
 
Please login to merge, or discard this patch.
vendor/nikic/php-parser/lib/PhpParser/Node/Name/FullyQualified.php 2 patches
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -4,47 +4,47 @@
 block discarded – undo
4 4
 
5 5
 class FullyQualified extends \PhpParser\Node\Name
6 6
 {
7
-    /**
8
-     * Checks whether the name is unqualified. (E.g. Name)
9
-     *
10
-     * @return bool Whether the name is unqualified
11
-     */
12
-    public function isUnqualified() : bool {
13
-        return false;
14
-    }
7
+	/**
8
+	 * Checks whether the name is unqualified. (E.g. Name)
9
+	 *
10
+	 * @return bool Whether the name is unqualified
11
+	 */
12
+	public function isUnqualified() : bool {
13
+		return false;
14
+	}
15 15
 
16
-    /**
17
-     * Checks whether the name is qualified. (E.g. Name\Name)
18
-     *
19
-     * @return bool Whether the name is qualified
20
-     */
21
-    public function isQualified() : bool {
22
-        return false;
23
-    }
16
+	/**
17
+	 * Checks whether the name is qualified. (E.g. Name\Name)
18
+	 *
19
+	 * @return bool Whether the name is qualified
20
+	 */
21
+	public function isQualified() : bool {
22
+		return false;
23
+	}
24 24
 
25
-    /**
26
-     * Checks whether the name is fully qualified. (E.g. \Name)
27
-     *
28
-     * @return bool Whether the name is fully qualified
29
-     */
30
-    public function isFullyQualified() : bool {
31
-        return true;
32
-    }
25
+	/**
26
+	 * Checks whether the name is fully qualified. (E.g. \Name)
27
+	 *
28
+	 * @return bool Whether the name is fully qualified
29
+	 */
30
+	public function isFullyQualified() : bool {
31
+		return true;
32
+	}
33 33
 
34
-    /**
35
-     * Checks whether the name is explicitly relative to the current namespace. (E.g. namespace\Name)
36
-     *
37
-     * @return bool Whether the name is relative
38
-     */
39
-    public function isRelative() : bool {
40
-        return false;
41
-    }
34
+	/**
35
+	 * Checks whether the name is explicitly relative to the current namespace. (E.g. namespace\Name)
36
+	 *
37
+	 * @return bool Whether the name is relative
38
+	 */
39
+	public function isRelative() : bool {
40
+		return false;
41
+	}
42 42
 
43
-    public function toCodeString() : string {
44
-        return '\\' . $this->toString();
45
-    }
43
+	public function toCodeString() : string {
44
+		return '\\' . $this->toString();
45
+	}
46 46
     
47
-    public function getType() : string {
48
-        return 'Name_FullyQualified';
49
-    }
47
+	public function getType() : string {
48
+		return 'Name_FullyQualified';
49
+	}
50 50
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
     }
42 42
 
43 43
     public function toCodeString() : string {
44
-        return '\\' . $this->toString();
44
+        return '\\'.$this->toString();
45 45
     }
46 46
     
47 47
     public function getType() : string {
Please login to merge, or discard this patch.
php-scoper/vendor/nikic/php-parser/lib/PhpParser/Node/Name/Relative.php 2 patches
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -4,47 +4,47 @@
 block discarded – undo
4 4
 
5 5
 class Relative extends \PhpParser\Node\Name
6 6
 {
7
-    /**
8
-     * Checks whether the name is unqualified. (E.g. Name)
9
-     *
10
-     * @return bool Whether the name is unqualified
11
-     */
12
-    public function isUnqualified() : bool {
13
-        return false;
14
-    }
7
+	/**
8
+	 * Checks whether the name is unqualified. (E.g. Name)
9
+	 *
10
+	 * @return bool Whether the name is unqualified
11
+	 */
12
+	public function isUnqualified() : bool {
13
+		return false;
14
+	}
15 15
 
16
-    /**
17
-     * Checks whether the name is qualified. (E.g. Name\Name)
18
-     *
19
-     * @return bool Whether the name is qualified
20
-     */
21
-    public function isQualified() : bool {
22
-        return false;
23
-    }
16
+	/**
17
+	 * Checks whether the name is qualified. (E.g. Name\Name)
18
+	 *
19
+	 * @return bool Whether the name is qualified
20
+	 */
21
+	public function isQualified() : bool {
22
+		return false;
23
+	}
24 24
 
25
-    /**
26
-     * Checks whether the name is fully qualified. (E.g. \Name)
27
-     *
28
-     * @return bool Whether the name is fully qualified
29
-     */
30
-    public function isFullyQualified() : bool {
31
-        return false;
32
-    }
25
+	/**
26
+	 * Checks whether the name is fully qualified. (E.g. \Name)
27
+	 *
28
+	 * @return bool Whether the name is fully qualified
29
+	 */
30
+	public function isFullyQualified() : bool {
31
+		return false;
32
+	}
33 33
 
34
-    /**
35
-     * Checks whether the name is explicitly relative to the current namespace. (E.g. namespace\Name)
36
-     *
37
-     * @return bool Whether the name is relative
38
-     */
39
-    public function isRelative() : bool {
40
-        return true;
41
-    }
34
+	/**
35
+	 * Checks whether the name is explicitly relative to the current namespace. (E.g. namespace\Name)
36
+	 *
37
+	 * @return bool Whether the name is relative
38
+	 */
39
+	public function isRelative() : bool {
40
+		return true;
41
+	}
42 42
 
43
-    public function toCodeString() : string {
44
-        return 'namespace\\' . $this->toString();
45
-    }
43
+	public function toCodeString() : string {
44
+		return 'namespace\\' . $this->toString();
45
+	}
46 46
     
47
-    public function getType() : string {
48
-        return 'Name_Relative';
49
-    }
47
+	public function getType() : string {
48
+		return 'Name_Relative';
49
+	}
50 50
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
     }
42 42
 
43 43
     public function toCodeString() : string {
44
-        return 'namespace\\' . $this->toString();
44
+        return 'namespace\\'.$this->toString();
45 45
     }
46 46
     
47 47
     public function getType() : string {
Please login to merge, or discard this patch.
php-scoper/vendor/nikic/php-parser/lib/PhpParser/Node/AttributeGroup.php 2 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -7,23 +7,23 @@
 block discarded – undo
7 7
 
8 8
 class AttributeGroup extends NodeAbstract
9 9
 {
10
-    /** @var Attribute[] Attributes */
11
-    public $attrs;
10
+	/** @var Attribute[] Attributes */
11
+	public $attrs;
12 12
 
13
-    /**
14
-     * @param Attribute[] $attrs PHP attributes
15
-     * @param array $attributes Additional node attributes
16
-     */
17
-    public function __construct(array $attrs, array $attributes = []) {
18
-        $this->attributes = $attributes;
19
-        $this->attrs = $attrs;
20
-    }
13
+	/**
14
+	 * @param Attribute[] $attrs PHP attributes
15
+	 * @param array $attributes Additional node attributes
16
+	 */
17
+	public function __construct(array $attrs, array $attributes = []) {
18
+		$this->attributes = $attributes;
19
+		$this->attrs = $attrs;
20
+	}
21 21
 
22
-    public function getSubNodeNames() : array {
23
-        return ['attrs'];
24
-    }
22
+	public function getSubNodeNames() : array {
23
+		return ['attrs'];
24
+	}
25 25
 
26
-    public function getType() : string {
27
-        return 'AttributeGroup';
28
-    }
26
+	public function getType() : string {
27
+		return 'AttributeGroup';
28
+	}
29 29
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -5,8 +5,7 @@
 block discarded – undo
5 5
 use PhpParser\Node;
6 6
 use PhpParser\NodeAbstract;
7 7
 
8
-class AttributeGroup extends NodeAbstract
9
-{
8
+class AttributeGroup extends NodeAbstract {
10 9
     /** @var Attribute[] Attributes */
11 10
     public $attrs;
12 11
 
Please login to merge, or discard this patch.
php-scoper/vendor/nikic/php-parser/lib/PhpParser/ConstExprEvaluator.php 3 patches
Indentation   +199 added lines, -199 removed lines patch added patch discarded remove patch
@@ -27,203 +27,203 @@
 block discarded – undo
27 27
  */
28 28
 class ConstExprEvaluator
29 29
 {
30
-    private $fallbackEvaluator;
31
-
32
-    /**
33
-     * Create a constant expression evaluator.
34
-     *
35
-     * The provided fallback evaluator is invoked whenever a subexpression cannot be evaluated. See
36
-     * class doc comment for more information.
37
-     *
38
-     * @param callable|null $fallbackEvaluator To call if subexpression cannot be evaluated
39
-     */
40
-    public function __construct(?callable $fallbackEvaluator = null) {
41
-        $this->fallbackEvaluator = $fallbackEvaluator ?? function(Expr $expr) {
42
-            throw new ConstExprEvaluationException(
43
-                "Expression of type {$expr->getType()} cannot be evaluated"
44
-            );
45
-        };
46
-    }
47
-
48
-    /**
49
-     * Silently evaluates a constant expression into a PHP value.
50
-     *
51
-     * Thrown Errors, warnings or notices will be converted into a ConstExprEvaluationException.
52
-     * The original source of the exception is available through getPrevious().
53
-     *
54
-     * If some part of the expression cannot be evaluated, the fallback evaluator passed to the
55
-     * constructor will be invoked. By default, if no fallback is provided, an exception of type
56
-     * ConstExprEvaluationException is thrown.
57
-     *
58
-     * See class doc comment for caveats and limitations.
59
-     *
60
-     * @param Expr $expr Constant expression to evaluate
61
-     * @return mixed Result of evaluation
62
-     *
63
-     * @throws ConstExprEvaluationException if the expression cannot be evaluated or an error occurred
64
-     */
65
-    public function evaluateSilently(Expr $expr) {
66
-        set_error_handler(function($num, $str, $file, $line) {
67
-            throw new \ErrorException($str, 0, $num, $file, $line);
68
-        });
69
-
70
-        try {
71
-            return $this->evaluate($expr);
72
-        } catch (\Throwable $e) {
73
-            if (!$e instanceof ConstExprEvaluationException) {
74
-                $e = new ConstExprEvaluationException(
75
-                    "An error occurred during constant expression evaluation", 0, $e);
76
-            }
77
-            throw $e;
78
-        } finally {
79
-            restore_error_handler();
80
-        }
81
-    }
82
-
83
-    /**
84
-     * Directly evaluates a constant expression into a PHP value.
85
-     *
86
-     * May generate Error exceptions, warnings or notices. Use evaluateSilently() to convert these
87
-     * into a ConstExprEvaluationException.
88
-     *
89
-     * If some part of the expression cannot be evaluated, the fallback evaluator passed to the
90
-     * constructor will be invoked. By default, if no fallback is provided, an exception of type
91
-     * ConstExprEvaluationException is thrown.
92
-     *
93
-     * See class doc comment for caveats and limitations.
94
-     *
95
-     * @param Expr $expr Constant expression to evaluate
96
-     * @return mixed Result of evaluation
97
-     *
98
-     * @throws ConstExprEvaluationException if the expression cannot be evaluated
99
-     */
100
-    public function evaluateDirectly(Expr $expr) {
101
-        return $this->evaluate($expr);
102
-    }
103
-
104
-    private function evaluate(Expr $expr) {
105
-        if ($expr instanceof Scalar\LNumber
106
-            || $expr instanceof Scalar\DNumber
107
-            || $expr instanceof Scalar\String_
108
-        ) {
109
-            return $expr->value;
110
-        }
111
-
112
-        if ($expr instanceof Expr\Array_) {
113
-            return $this->evaluateArray($expr);
114
-        }
115
-
116
-        // Unary operators
117
-        if ($expr instanceof Expr\UnaryPlus) {
118
-            return +$this->evaluate($expr->expr);
119
-        }
120
-        if ($expr instanceof Expr\UnaryMinus) {
121
-            return -$this->evaluate($expr->expr);
122
-        }
123
-        if ($expr instanceof Expr\BooleanNot) {
124
-            return !$this->evaluate($expr->expr);
125
-        }
126
-        if ($expr instanceof Expr\BitwiseNot) {
127
-            return ~$this->evaluate($expr->expr);
128
-        }
129
-
130
-        if ($expr instanceof Expr\BinaryOp) {
131
-            return $this->evaluateBinaryOp($expr);
132
-        }
133
-
134
-        if ($expr instanceof Expr\Ternary) {
135
-            return $this->evaluateTernary($expr);
136
-        }
137
-
138
-        if ($expr instanceof Expr\ArrayDimFetch && null !== $expr->dim) {
139
-            return $this->evaluate($expr->var)[$this->evaluate($expr->dim)];
140
-        }
141
-
142
-        if ($expr instanceof Expr\ConstFetch) {
143
-            return $this->evaluateConstFetch($expr);
144
-        }
145
-
146
-        return ($this->fallbackEvaluator)($expr);
147
-    }
148
-
149
-    private function evaluateArray(Expr\Array_ $expr) {
150
-        $array = [];
151
-        foreach ($expr->items as $item) {
152
-            if (null !== $item->key) {
153
-                $array[$this->evaluate($item->key)] = $this->evaluate($item->value);
154
-            } elseif ($item->unpack) {
155
-                $array = array_merge($array, $this->evaluate($item->value));
156
-            } else {
157
-                $array[] = $this->evaluate($item->value);
158
-            }
159
-        }
160
-        return $array;
161
-    }
162
-
163
-    private function evaluateTernary(Expr\Ternary $expr) {
164
-        if (null === $expr->if) {
165
-            return $this->evaluate($expr->cond) ?: $this->evaluate($expr->else);
166
-        }
167
-
168
-        return $this->evaluate($expr->cond)
169
-            ? $this->evaluate($expr->if)
170
-            : $this->evaluate($expr->else);
171
-    }
172
-
173
-    private function evaluateBinaryOp(Expr\BinaryOp $expr) {
174
-        if ($expr instanceof Expr\BinaryOp\Coalesce
175
-            && $expr->left instanceof Expr\ArrayDimFetch
176
-        ) {
177
-            // This needs to be special cased to respect BP_VAR_IS fetch semantics
178
-            return $this->evaluate($expr->left->var)[$this->evaluate($expr->left->dim)]
179
-                ?? $this->evaluate($expr->right);
180
-        }
181
-
182
-        // The evaluate() calls are repeated in each branch, because some of the operators are
183
-        // short-circuiting and evaluating the RHS in advance may be illegal in that case
184
-        $l = $expr->left;
185
-        $r = $expr->right;
186
-        switch ($expr->getOperatorSigil()) {
187
-            case '&':   return $this->evaluate($l) &   $this->evaluate($r);
188
-            case '|':   return $this->evaluate($l) |   $this->evaluate($r);
189
-            case '^':   return $this->evaluate($l) ^   $this->evaluate($r);
190
-            case '&&':  return $this->evaluate($l) &&  $this->evaluate($r);
191
-            case '||':  return $this->evaluate($l) ||  $this->evaluate($r);
192
-            case '??':  return $this->evaluate($l) ??  $this->evaluate($r);
193
-            case '.':   return $this->evaluate($l) .   $this->evaluate($r);
194
-            case '/':   return $this->evaluate($l) /   $this->evaluate($r);
195
-            case '==':  return $this->evaluate($l) ==  $this->evaluate($r);
196
-            case '>':   return $this->evaluate($l) >   $this->evaluate($r);
197
-            case '>=':  return $this->evaluate($l) >=  $this->evaluate($r);
198
-            case '===': return $this->evaluate($l) === $this->evaluate($r);
199
-            case 'and': return $this->evaluate($l) and $this->evaluate($r);
200
-            case 'or':  return $this->evaluate($l) or  $this->evaluate($r);
201
-            case 'xor': return $this->evaluate($l) xor $this->evaluate($r);
202
-            case '-':   return $this->evaluate($l) -   $this->evaluate($r);
203
-            case '%':   return $this->evaluate($l) %   $this->evaluate($r);
204
-            case '*':   return $this->evaluate($l) *   $this->evaluate($r);
205
-            case '!=':  return $this->evaluate($l) !=  $this->evaluate($r);
206
-            case '!==': return $this->evaluate($l) !== $this->evaluate($r);
207
-            case '+':   return $this->evaluate($l) +   $this->evaluate($r);
208
-            case '**':  return $this->evaluate($l) **  $this->evaluate($r);
209
-            case '<<':  return $this->evaluate($l) <<  $this->evaluate($r);
210
-            case '>>':  return $this->evaluate($l) >>  $this->evaluate($r);
211
-            case '<':   return $this->evaluate($l) <   $this->evaluate($r);
212
-            case '<=':  return $this->evaluate($l) <=  $this->evaluate($r);
213
-            case '<=>': return $this->evaluate($l) <=> $this->evaluate($r);
214
-        }
215
-
216
-        throw new \Exception('Should not happen');
217
-    }
218
-
219
-    private function evaluateConstFetch(Expr\ConstFetch $expr) {
220
-        $name = $expr->name->toLowerString();
221
-        switch ($name) {
222
-            case 'null': return null;
223
-            case 'false': return false;
224
-            case 'true': return true;
225
-        }
226
-
227
-        return ($this->fallbackEvaluator)($expr);
228
-    }
30
+	private $fallbackEvaluator;
31
+
32
+	/**
33
+	 * Create a constant expression evaluator.
34
+	 *
35
+	 * The provided fallback evaluator is invoked whenever a subexpression cannot be evaluated. See
36
+	 * class doc comment for more information.
37
+	 *
38
+	 * @param callable|null $fallbackEvaluator To call if subexpression cannot be evaluated
39
+	 */
40
+	public function __construct(?callable $fallbackEvaluator = null) {
41
+		$this->fallbackEvaluator = $fallbackEvaluator ?? function(Expr $expr) {
42
+			throw new ConstExprEvaluationException(
43
+				"Expression of type {$expr->getType()} cannot be evaluated"
44
+			);
45
+		};
46
+	}
47
+
48
+	/**
49
+	 * Silently evaluates a constant expression into a PHP value.
50
+	 *
51
+	 * Thrown Errors, warnings or notices will be converted into a ConstExprEvaluationException.
52
+	 * The original source of the exception is available through getPrevious().
53
+	 *
54
+	 * If some part of the expression cannot be evaluated, the fallback evaluator passed to the
55
+	 * constructor will be invoked. By default, if no fallback is provided, an exception of type
56
+	 * ConstExprEvaluationException is thrown.
57
+	 *
58
+	 * See class doc comment for caveats and limitations.
59
+	 *
60
+	 * @param Expr $expr Constant expression to evaluate
61
+	 * @return mixed Result of evaluation
62
+	 *
63
+	 * @throws ConstExprEvaluationException if the expression cannot be evaluated or an error occurred
64
+	 */
65
+	public function evaluateSilently(Expr $expr) {
66
+		set_error_handler(function($num, $str, $file, $line) {
67
+			throw new \ErrorException($str, 0, $num, $file, $line);
68
+		});
69
+
70
+		try {
71
+			return $this->evaluate($expr);
72
+		} catch (\Throwable $e) {
73
+			if (!$e instanceof ConstExprEvaluationException) {
74
+				$e = new ConstExprEvaluationException(
75
+					"An error occurred during constant expression evaluation", 0, $e);
76
+			}
77
+			throw $e;
78
+		} finally {
79
+			restore_error_handler();
80
+		}
81
+	}
82
+
83
+	/**
84
+	 * Directly evaluates a constant expression into a PHP value.
85
+	 *
86
+	 * May generate Error exceptions, warnings or notices. Use evaluateSilently() to convert these
87
+	 * into a ConstExprEvaluationException.
88
+	 *
89
+	 * If some part of the expression cannot be evaluated, the fallback evaluator passed to the
90
+	 * constructor will be invoked. By default, if no fallback is provided, an exception of type
91
+	 * ConstExprEvaluationException is thrown.
92
+	 *
93
+	 * See class doc comment for caveats and limitations.
94
+	 *
95
+	 * @param Expr $expr Constant expression to evaluate
96
+	 * @return mixed Result of evaluation
97
+	 *
98
+	 * @throws ConstExprEvaluationException if the expression cannot be evaluated
99
+	 */
100
+	public function evaluateDirectly(Expr $expr) {
101
+		return $this->evaluate($expr);
102
+	}
103
+
104
+	private function evaluate(Expr $expr) {
105
+		if ($expr instanceof Scalar\LNumber
106
+			|| $expr instanceof Scalar\DNumber
107
+			|| $expr instanceof Scalar\String_
108
+		) {
109
+			return $expr->value;
110
+		}
111
+
112
+		if ($expr instanceof Expr\Array_) {
113
+			return $this->evaluateArray($expr);
114
+		}
115
+
116
+		// Unary operators
117
+		if ($expr instanceof Expr\UnaryPlus) {
118
+			return +$this->evaluate($expr->expr);
119
+		}
120
+		if ($expr instanceof Expr\UnaryMinus) {
121
+			return -$this->evaluate($expr->expr);
122
+		}
123
+		if ($expr instanceof Expr\BooleanNot) {
124
+			return !$this->evaluate($expr->expr);
125
+		}
126
+		if ($expr instanceof Expr\BitwiseNot) {
127
+			return ~$this->evaluate($expr->expr);
128
+		}
129
+
130
+		if ($expr instanceof Expr\BinaryOp) {
131
+			return $this->evaluateBinaryOp($expr);
132
+		}
133
+
134
+		if ($expr instanceof Expr\Ternary) {
135
+			return $this->evaluateTernary($expr);
136
+		}
137
+
138
+		if ($expr instanceof Expr\ArrayDimFetch && null !== $expr->dim) {
139
+			return $this->evaluate($expr->var)[$this->evaluate($expr->dim)];
140
+		}
141
+
142
+		if ($expr instanceof Expr\ConstFetch) {
143
+			return $this->evaluateConstFetch($expr);
144
+		}
145
+
146
+		return ($this->fallbackEvaluator)($expr);
147
+	}
148
+
149
+	private function evaluateArray(Expr\Array_ $expr) {
150
+		$array = [];
151
+		foreach ($expr->items as $item) {
152
+			if (null !== $item->key) {
153
+				$array[$this->evaluate($item->key)] = $this->evaluate($item->value);
154
+			} elseif ($item->unpack) {
155
+				$array = array_merge($array, $this->evaluate($item->value));
156
+			} else {
157
+				$array[] = $this->evaluate($item->value);
158
+			}
159
+		}
160
+		return $array;
161
+	}
162
+
163
+	private function evaluateTernary(Expr\Ternary $expr) {
164
+		if (null === $expr->if) {
165
+			return $this->evaluate($expr->cond) ?: $this->evaluate($expr->else);
166
+		}
167
+
168
+		return $this->evaluate($expr->cond)
169
+			? $this->evaluate($expr->if)
170
+			: $this->evaluate($expr->else);
171
+	}
172
+
173
+	private function evaluateBinaryOp(Expr\BinaryOp $expr) {
174
+		if ($expr instanceof Expr\BinaryOp\Coalesce
175
+			&& $expr->left instanceof Expr\ArrayDimFetch
176
+		) {
177
+			// This needs to be special cased to respect BP_VAR_IS fetch semantics
178
+			return $this->evaluate($expr->left->var)[$this->evaluate($expr->left->dim)]
179
+				?? $this->evaluate($expr->right);
180
+		}
181
+
182
+		// The evaluate() calls are repeated in each branch, because some of the operators are
183
+		// short-circuiting and evaluating the RHS in advance may be illegal in that case
184
+		$l = $expr->left;
185
+		$r = $expr->right;
186
+		switch ($expr->getOperatorSigil()) {
187
+			case '&':   return $this->evaluate($l) &   $this->evaluate($r);
188
+			case '|':   return $this->evaluate($l) |   $this->evaluate($r);
189
+			case '^':   return $this->evaluate($l) ^   $this->evaluate($r);
190
+			case '&&':  return $this->evaluate($l) &&  $this->evaluate($r);
191
+			case '||':  return $this->evaluate($l) ||  $this->evaluate($r);
192
+			case '??':  return $this->evaluate($l) ??  $this->evaluate($r);
193
+			case '.':   return $this->evaluate($l) .   $this->evaluate($r);
194
+			case '/':   return $this->evaluate($l) /   $this->evaluate($r);
195
+			case '==':  return $this->evaluate($l) ==  $this->evaluate($r);
196
+			case '>':   return $this->evaluate($l) >   $this->evaluate($r);
197
+			case '>=':  return $this->evaluate($l) >=  $this->evaluate($r);
198
+			case '===': return $this->evaluate($l) === $this->evaluate($r);
199
+			case 'and': return $this->evaluate($l) and $this->evaluate($r);
200
+			case 'or':  return $this->evaluate($l) or  $this->evaluate($r);
201
+			case 'xor': return $this->evaluate($l) xor $this->evaluate($r);
202
+			case '-':   return $this->evaluate($l) -   $this->evaluate($r);
203
+			case '%':   return $this->evaluate($l) %   $this->evaluate($r);
204
+			case '*':   return $this->evaluate($l) *   $this->evaluate($r);
205
+			case '!=':  return $this->evaluate($l) !=  $this->evaluate($r);
206
+			case '!==': return $this->evaluate($l) !== $this->evaluate($r);
207
+			case '+':   return $this->evaluate($l) +   $this->evaluate($r);
208
+			case '**':  return $this->evaluate($l) **  $this->evaluate($r);
209
+			case '<<':  return $this->evaluate($l) <<  $this->evaluate($r);
210
+			case '>>':  return $this->evaluate($l) >>  $this->evaluate($r);
211
+			case '<':   return $this->evaluate($l) <   $this->evaluate($r);
212
+			case '<=':  return $this->evaluate($l) <=  $this->evaluate($r);
213
+			case '<=>': return $this->evaluate($l) <=> $this->evaluate($r);
214
+		}
215
+
216
+		throw new \Exception('Should not happen');
217
+	}
218
+
219
+	private function evaluateConstFetch(Expr\ConstFetch $expr) {
220
+		$name = $expr->name->toLowerString();
221
+		switch ($name) {
222
+			case 'null': return null;
223
+			case 'false': return false;
224
+			case 'true': return true;
225
+		}
226
+
227
+		return ($this->fallbackEvaluator)($expr);
228
+	}
229 229
 }
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -184,32 +184,32 @@
 block discarded – undo
184 184
         $l = $expr->left;
185 185
         $r = $expr->right;
186 186
         switch ($expr->getOperatorSigil()) {
187
-            case '&':   return $this->evaluate($l) &   $this->evaluate($r);
188
-            case '|':   return $this->evaluate($l) |   $this->evaluate($r);
189
-            case '^':   return $this->evaluate($l) ^   $this->evaluate($r);
190
-            case '&&':  return $this->evaluate($l) &&  $this->evaluate($r);
191
-            case '||':  return $this->evaluate($l) ||  $this->evaluate($r);
192
-            case '??':  return $this->evaluate($l) ??  $this->evaluate($r);
193
-            case '.':   return $this->evaluate($l) .   $this->evaluate($r);
194
-            case '/':   return $this->evaluate($l) /   $this->evaluate($r);
195
-            case '==':  return $this->evaluate($l) ==  $this->evaluate($r);
196
-            case '>':   return $this->evaluate($l) >   $this->evaluate($r);
197
-            case '>=':  return $this->evaluate($l) >=  $this->evaluate($r);
187
+            case '&':   return $this->evaluate($l) & $this->evaluate($r);
188
+            case '|':   return $this->evaluate($l) | $this->evaluate($r);
189
+            case '^':   return $this->evaluate($l) ^ $this->evaluate($r);
190
+            case '&&':  return $this->evaluate($l) && $this->evaluate($r);
191
+            case '||':  return $this->evaluate($l) || $this->evaluate($r);
192
+            case '??':  return $this->evaluate($l) ?? $this->evaluate($r);
193
+            case '.':   return $this->evaluate($l).$this->evaluate($r);
194
+            case '/':   return $this->evaluate($l) / $this->evaluate($r);
195
+            case '==':  return $this->evaluate($l) == $this->evaluate($r);
196
+            case '>':   return $this->evaluate($l) > $this->evaluate($r);
197
+            case '>=':  return $this->evaluate($l) >= $this->evaluate($r);
198 198
             case '===': return $this->evaluate($l) === $this->evaluate($r);
199 199
             case 'and': return $this->evaluate($l) and $this->evaluate($r);
200
-            case 'or':  return $this->evaluate($l) or  $this->evaluate($r);
200
+            case 'or':  return $this->evaluate($l) or $this->evaluate($r);
201 201
             case 'xor': return $this->evaluate($l) xor $this->evaluate($r);
202
-            case '-':   return $this->evaluate($l) -   $this->evaluate($r);
203
-            case '%':   return $this->evaluate($l) %   $this->evaluate($r);
204
-            case '*':   return $this->evaluate($l) *   $this->evaluate($r);
205
-            case '!=':  return $this->evaluate($l) !=  $this->evaluate($r);
202
+            case '-':   return $this->evaluate($l) - $this->evaluate($r);
203
+            case '%':   return $this->evaluate($l) % $this->evaluate($r);
204
+            case '*':   return $this->evaluate($l) * $this->evaluate($r);
205
+            case '!=':  return $this->evaluate($l) != $this->evaluate($r);
206 206
             case '!==': return $this->evaluate($l) !== $this->evaluate($r);
207
-            case '+':   return $this->evaluate($l) +   $this->evaluate($r);
207
+            case '+':   return $this->evaluate($l) + $this->evaluate($r);
208 208
             case '**':  return $this->evaluate($l) **  $this->evaluate($r);
209
-            case '<<':  return $this->evaluate($l) <<  $this->evaluate($r);
210
-            case '>>':  return $this->evaluate($l) >>  $this->evaluate($r);
211
-            case '<':   return $this->evaluate($l) <   $this->evaluate($r);
212
-            case '<=':  return $this->evaluate($l) <=  $this->evaluate($r);
209
+            case '<<':  return $this->evaluate($l) << $this->evaluate($r);
210
+            case '>>':  return $this->evaluate($l) >> $this->evaluate($r);
211
+            case '<':   return $this->evaluate($l) < $this->evaluate($r);
212
+            case '<=':  return $this->evaluate($l) <= $this->evaluate($r);
213 213
             case '<=>': return $this->evaluate($l) <=> $this->evaluate($r);
214 214
         }
215 215
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,8 +25,7 @@
 block discarded – undo
25 25
  * point to string conversions are affected by the precision ini setting. Secondly, they are also
26 26
  * affected by the LC_NUMERIC locale.
27 27
  */
28
-class ConstExprEvaluator
29
-{
28
+class ConstExprEvaluator {
30 29
     private $fallbackEvaluator;
31 30
 
32 31
     /**
Please login to merge, or discard this patch.