Completed
Pull Request — master (#383)
by rakekniven
02:38
created
vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/TokenEmulator.php 2 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -5,21 +5,21 @@
 block discarded – undo
5 5
 /** @internal */
6 6
 abstract class TokenEmulator
7 7
 {
8
-    abstract public function getPhpVersion(): string;
8
+	abstract public function getPhpVersion(): string;
9 9
 
10
-    abstract public function isEmulationNeeded(string $code): bool;
10
+	abstract public function isEmulationNeeded(string $code): bool;
11 11
 
12
-    /**
13
-     * @return array Modified Tokens
14
-     */
15
-    abstract public function emulate(string $code, array $tokens): array;
12
+	/**
13
+	 * @return array Modified Tokens
14
+	 */
15
+	abstract public function emulate(string $code, array $tokens): array;
16 16
 
17
-    /**
18
-     * @return array Modified Tokens
19
-     */
20
-    abstract public function reverseEmulate(string $code, array $tokens): array;
17
+	/**
18
+	 * @return array Modified Tokens
19
+	 */
20
+	abstract public function reverseEmulate(string $code, array $tokens): array;
21 21
 
22
-    public function preprocessCode(string $code, array &$patches): string {
23
-        return $code;
24
-    }
22
+	public function preprocessCode(string $code, array &$patches): string {
23
+		return $code;
24
+	}
25 25
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3,8 +3,7 @@
 block discarded – undo
3 3
 namespace PhpParser\Lexer\TokenEmulator;
4 4
 
5 5
 /** @internal */
6
-abstract class TokenEmulator
7
-{
6
+abstract class TokenEmulator {
8 7
     abstract public function getPhpVersion(): string;
9 8
 
10 9
     abstract public function isEmulationNeeded(string $code): bool;
Please login to merge, or discard this patch.
lib/PhpParser/Lexer/TokenEmulator/NumericLiteralSeparatorEmulator.php 3 patches
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -6,100 +6,100 @@
 block discarded – undo
6 6
 
7 7
 final class NumericLiteralSeparatorEmulator extends TokenEmulator
8 8
 {
9
-    const BIN = '(?:0b[01]+(?:_[01]+)*)';
10
-    const HEX = '(?:0x[0-9a-f]+(?:_[0-9a-f]+)*)';
11
-    const DEC = '(?:[0-9]+(?:_[0-9]+)*)';
12
-    const SIMPLE_FLOAT = '(?:' . self::DEC . '\.' . self::DEC . '?|\.' . self::DEC . ')';
13
-    const EXP = '(?:e[+-]?' . self::DEC . ')';
14
-    const FLOAT = '(?:' . self::SIMPLE_FLOAT . self::EXP . '?|' . self::DEC . self::EXP . ')';
15
-    const NUMBER = '~' . self::FLOAT . '|' . self::BIN . '|' . self::HEX . '|' . self::DEC . '~iA';
16
-
17
-    public function getPhpVersion(): string
18
-    {
19
-        return Emulative::PHP_7_4;
20
-    }
21
-
22
-    public function isEmulationNeeded(string $code) : bool
23
-    {
24
-        return preg_match('~[0-9]_[0-9]~', $code)
25
-            || preg_match('~0x[0-9a-f]+_[0-9a-f]~i', $code);
26
-    }
27
-
28
-    public function emulate(string $code, array $tokens): array
29
-    {
30
-        // We need to manually iterate and manage a count because we'll change
31
-        // the tokens array on the way
32
-        $codeOffset = 0;
33
-        for ($i = 0, $c = count($tokens); $i < $c; ++$i) {
34
-            $token = $tokens[$i];
35
-            $tokenLen = \strlen(\is_array($token) ? $token[1] : $token);
36
-
37
-            if ($token[0] !== T_LNUMBER && $token[0] !== T_DNUMBER) {
38
-                $codeOffset += $tokenLen;
39
-                continue;
40
-            }
41
-
42
-            $res = preg_match(self::NUMBER, $code, $matches, 0, $codeOffset);
43
-            assert($res, "No number at number token position");
44
-
45
-            $match = $matches[0];
46
-            $matchLen = \strlen($match);
47
-            if ($matchLen === $tokenLen) {
48
-                // Original token already holds the full number.
49
-                $codeOffset += $tokenLen;
50
-                continue;
51
-            }
52
-
53
-            $tokenKind = $this->resolveIntegerOrFloatToken($match);
54
-            $newTokens = [[$tokenKind, $match, $token[2]]];
55
-
56
-            $numTokens = 1;
57
-            $len = $tokenLen;
58
-            while ($matchLen > $len) {
59
-                $nextToken = $tokens[$i + $numTokens];
60
-                $nextTokenText = \is_array($nextToken) ? $nextToken[1] : $nextToken;
61
-                $nextTokenLen = \strlen($nextTokenText);
62
-
63
-                $numTokens++;
64
-                if ($matchLen < $len + $nextTokenLen) {
65
-                    // Split trailing characters into a partial token.
66
-                    assert(is_array($nextToken), "Partial token should be an array token");
67
-                    $partialText = substr($nextTokenText, $matchLen - $len);
68
-                    $newTokens[] = [$nextToken[0], $partialText, $nextToken[2]];
69
-                    break;
70
-                }
71
-
72
-                $len += $nextTokenLen;
73
-            }
74
-
75
-            array_splice($tokens, $i, $numTokens, $newTokens);
76
-            $c -= $numTokens - \count($newTokens);
77
-            $codeOffset += $matchLen;
78
-        }
79
-
80
-        return $tokens;
81
-    }
82
-
83
-    private function resolveIntegerOrFloatToken(string $str): int
84
-    {
85
-        $str = str_replace('_', '', $str);
86
-
87
-        if (stripos($str, '0b') === 0) {
88
-            $num = bindec($str);
89
-        } elseif (stripos($str, '0x') === 0) {
90
-            $num = hexdec($str);
91
-        } elseif (stripos($str, '0') === 0 && ctype_digit($str)) {
92
-            $num = octdec($str);
93
-        } else {
94
-            $num = +$str;
95
-        }
96
-
97
-        return is_float($num) ? T_DNUMBER : T_LNUMBER;
98
-    }
99
-
100
-    public function reverseEmulate(string $code, array $tokens): array
101
-    {
102
-        // Numeric separators were not legal code previously, don't bother.
103
-        return $tokens;
104
-    }
9
+	const BIN = '(?:0b[01]+(?:_[01]+)*)';
10
+	const HEX = '(?:0x[0-9a-f]+(?:_[0-9a-f]+)*)';
11
+	const DEC = '(?:[0-9]+(?:_[0-9]+)*)';
12
+	const SIMPLE_FLOAT = '(?:' . self::DEC . '\.' . self::DEC . '?|\.' . self::DEC . ')';
13
+	const EXP = '(?:e[+-]?' . self::DEC . ')';
14
+	const FLOAT = '(?:' . self::SIMPLE_FLOAT . self::EXP . '?|' . self::DEC . self::EXP . ')';
15
+	const NUMBER = '~' . self::FLOAT . '|' . self::BIN . '|' . self::HEX . '|' . self::DEC . '~iA';
16
+
17
+	public function getPhpVersion(): string
18
+	{
19
+		return Emulative::PHP_7_4;
20
+	}
21
+
22
+	public function isEmulationNeeded(string $code) : bool
23
+	{
24
+		return preg_match('~[0-9]_[0-9]~', $code)
25
+			|| preg_match('~0x[0-9a-f]+_[0-9a-f]~i', $code);
26
+	}
27
+
28
+	public function emulate(string $code, array $tokens): array
29
+	{
30
+		// We need to manually iterate and manage a count because we'll change
31
+		// the tokens array on the way
32
+		$codeOffset = 0;
33
+		for ($i = 0, $c = count($tokens); $i < $c; ++$i) {
34
+			$token = $tokens[$i];
35
+			$tokenLen = \strlen(\is_array($token) ? $token[1] : $token);
36
+
37
+			if ($token[0] !== T_LNUMBER && $token[0] !== T_DNUMBER) {
38
+				$codeOffset += $tokenLen;
39
+				continue;
40
+			}
41
+
42
+			$res = preg_match(self::NUMBER, $code, $matches, 0, $codeOffset);
43
+			assert($res, "No number at number token position");
44
+
45
+			$match = $matches[0];
46
+			$matchLen = \strlen($match);
47
+			if ($matchLen === $tokenLen) {
48
+				// Original token already holds the full number.
49
+				$codeOffset += $tokenLen;
50
+				continue;
51
+			}
52
+
53
+			$tokenKind = $this->resolveIntegerOrFloatToken($match);
54
+			$newTokens = [[$tokenKind, $match, $token[2]]];
55
+
56
+			$numTokens = 1;
57
+			$len = $tokenLen;
58
+			while ($matchLen > $len) {
59
+				$nextToken = $tokens[$i + $numTokens];
60
+				$nextTokenText = \is_array($nextToken) ? $nextToken[1] : $nextToken;
61
+				$nextTokenLen = \strlen($nextTokenText);
62
+
63
+				$numTokens++;
64
+				if ($matchLen < $len + $nextTokenLen) {
65
+					// Split trailing characters into a partial token.
66
+					assert(is_array($nextToken), "Partial token should be an array token");
67
+					$partialText = substr($nextTokenText, $matchLen - $len);
68
+					$newTokens[] = [$nextToken[0], $partialText, $nextToken[2]];
69
+					break;
70
+				}
71
+
72
+				$len += $nextTokenLen;
73
+			}
74
+
75
+			array_splice($tokens, $i, $numTokens, $newTokens);
76
+			$c -= $numTokens - \count($newTokens);
77
+			$codeOffset += $matchLen;
78
+		}
79
+
80
+		return $tokens;
81
+	}
82
+
83
+	private function resolveIntegerOrFloatToken(string $str): int
84
+	{
85
+		$str = str_replace('_', '', $str);
86
+
87
+		if (stripos($str, '0b') === 0) {
88
+			$num = bindec($str);
89
+		} elseif (stripos($str, '0x') === 0) {
90
+			$num = hexdec($str);
91
+		} elseif (stripos($str, '0') === 0 && ctype_digit($str)) {
92
+			$num = octdec($str);
93
+		} else {
94
+			$num = +$str;
95
+		}
96
+
97
+		return is_float($num) ? T_DNUMBER : T_LNUMBER;
98
+	}
99
+
100
+	public function reverseEmulate(string $code, array $tokens): array
101
+	{
102
+		// Numeric separators were not legal code previously, don't bother.
103
+		return $tokens;
104
+	}
105 105
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -9,10 +9,10 @@
 block discarded – undo
9 9
     const BIN = '(?:0b[01]+(?:_[01]+)*)';
10 10
     const HEX = '(?:0x[0-9a-f]+(?:_[0-9a-f]+)*)';
11 11
     const DEC = '(?:[0-9]+(?:_[0-9]+)*)';
12
-    const SIMPLE_FLOAT = '(?:' . self::DEC . '\.' . self::DEC . '?|\.' . self::DEC . ')';
13
-    const EXP = '(?:e[+-]?' . self::DEC . ')';
14
-    const FLOAT = '(?:' . self::SIMPLE_FLOAT . self::EXP . '?|' . self::DEC . self::EXP . ')';
15
-    const NUMBER = '~' . self::FLOAT . '|' . self::BIN . '|' . self::HEX . '|' . self::DEC . '~iA';
12
+    const SIMPLE_FLOAT = '(?:'.self::DEC.'\.'.self::DEC.'?|\.'.self::DEC.')';
13
+    const EXP = '(?:e[+-]?'.self::DEC.')';
14
+    const FLOAT = '(?:'.self::SIMPLE_FLOAT.self::EXP.'?|'.self::DEC.self::EXP.')';
15
+    const NUMBER = '~'.self::FLOAT.'|'.self::BIN.'|'.self::HEX.'|'.self::DEC.'~iA';
16 16
 
17 17
     public function getPhpVersion(): string
18 18
     {
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\Lexer\Emulative;
6 6
 
7
-final class NumericLiteralSeparatorEmulator extends TokenEmulator
8
-{
7
+final class NumericLiteralSeparatorEmulator extends TokenEmulator {
9 8
     const BIN = '(?:0b[01]+(?:_[01]+)*)';
10 9
     const HEX = '(?:0x[0-9a-f]+(?:_[0-9a-f]+)*)';
11 10
     const DEC = '(?:[0-9]+(?:_[0-9]+)*)';
Please login to merge, or discard this patch.
php-parser/lib/PhpParser/Lexer/TokenEmulator/FlexibleDocStringEmulator.php 3 patches
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -6,71 +6,71 @@
 block discarded – undo
6 6
 
7 7
 final class FlexibleDocStringEmulator extends TokenEmulator
8 8
 {
9
-    const FLEXIBLE_DOC_STRING_REGEX = <<<'REGEX'
9
+	const FLEXIBLE_DOC_STRING_REGEX = <<<'REGEX'
10 10
 /<<<[ \t]*(['"]?)([a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*)\1\r?\n
11 11
 (?:.*\r?\n)*?
12 12
 (?<indentation>\h*)\2(?![a-zA-Z0-9_\x80-\xff])(?<separator>(?:;?[\r\n])?)/x
13 13
 REGEX;
14 14
 
15
-    public function getPhpVersion(): string
16
-    {
17
-        return Emulative::PHP_7_3;
18
-    }
15
+	public function getPhpVersion(): string
16
+	{
17
+		return Emulative::PHP_7_3;
18
+	}
19 19
 
20
-    public function isEmulationNeeded(string $code) : bool
21
-    {
22
-        return strpos($code, '<<<') !== false;
23
-    }
20
+	public function isEmulationNeeded(string $code) : bool
21
+	{
22
+		return strpos($code, '<<<') !== false;
23
+	}
24 24
 
25
-    public function emulate(string $code, array $tokens): array
26
-    {
27
-        // Handled by preprocessing + fixup.
28
-        return $tokens;
29
-    }
25
+	public function emulate(string $code, array $tokens): array
26
+	{
27
+		// Handled by preprocessing + fixup.
28
+		return $tokens;
29
+	}
30 30
 
31
-    public function reverseEmulate(string $code, array $tokens): array
32
-    {
33
-        // Not supported.
34
-        return $tokens;
35
-    }
31
+	public function reverseEmulate(string $code, array $tokens): array
32
+	{
33
+		// Not supported.
34
+		return $tokens;
35
+	}
36 36
 
37
-    public function preprocessCode(string $code, array &$patches): string {
38
-        if (!preg_match_all(self::FLEXIBLE_DOC_STRING_REGEX, $code, $matches, PREG_SET_ORDER|PREG_OFFSET_CAPTURE)) {
39
-            // No heredoc/nowdoc found
40
-            return $code;
41
-        }
37
+	public function preprocessCode(string $code, array &$patches): string {
38
+		if (!preg_match_all(self::FLEXIBLE_DOC_STRING_REGEX, $code, $matches, PREG_SET_ORDER|PREG_OFFSET_CAPTURE)) {
39
+			// No heredoc/nowdoc found
40
+			return $code;
41
+		}
42 42
 
43
-        // Keep track of how much we need to adjust string offsets due to the modifications we
44
-        // already made
45
-        $posDelta = 0;
46
-        foreach ($matches as $match) {
47
-            $indentation = $match['indentation'][0];
48
-            $indentationStart = $match['indentation'][1];
43
+		// Keep track of how much we need to adjust string offsets due to the modifications we
44
+		// already made
45
+		$posDelta = 0;
46
+		foreach ($matches as $match) {
47
+			$indentation = $match['indentation'][0];
48
+			$indentationStart = $match['indentation'][1];
49 49
 
50
-            $separator = $match['separator'][0];
51
-            $separatorStart = $match['separator'][1];
50
+			$separator = $match['separator'][0];
51
+			$separatorStart = $match['separator'][1];
52 52
 
53
-            if ($indentation === '' && $separator !== '') {
54
-                // Ordinary heredoc/nowdoc
55
-                continue;
56
-            }
53
+			if ($indentation === '' && $separator !== '') {
54
+				// Ordinary heredoc/nowdoc
55
+				continue;
56
+			}
57 57
 
58
-            if ($indentation !== '') {
59
-                // Remove indentation
60
-                $indentationLen = strlen($indentation);
61
-                $code = substr_replace($code, '', $indentationStart + $posDelta, $indentationLen);
62
-                $patches[] = [$indentationStart + $posDelta, 'add', $indentation];
63
-                $posDelta -= $indentationLen;
64
-            }
58
+			if ($indentation !== '') {
59
+				// Remove indentation
60
+				$indentationLen = strlen($indentation);
61
+				$code = substr_replace($code, '', $indentationStart + $posDelta, $indentationLen);
62
+				$patches[] = [$indentationStart + $posDelta, 'add', $indentation];
63
+				$posDelta -= $indentationLen;
64
+			}
65 65
 
66
-            if ($separator === '') {
67
-                // Insert newline as separator
68
-                $code = substr_replace($code, "\n", $separatorStart + $posDelta, 0);
69
-                $patches[] = [$separatorStart + $posDelta, 'remove', "\n"];
70
-                $posDelta += 1;
71
-            }
72
-        }
66
+			if ($separator === '') {
67
+				// Insert newline as separator
68
+				$code = substr_replace($code, "\n", $separatorStart + $posDelta, 0);
69
+				$patches[] = [$separatorStart + $posDelta, 'remove', "\n"];
70
+				$posDelta += 1;
71
+			}
72
+		}
73 73
 
74
-        return $code;
75
-    }
74
+		return $code;
75
+	}
76 76
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
     }
36 36
 
37 37
     public function preprocessCode(string $code, array &$patches): string {
38
-        if (!preg_match_all(self::FLEXIBLE_DOC_STRING_REGEX, $code, $matches, PREG_SET_ORDER|PREG_OFFSET_CAPTURE)) {
38
+        if (!preg_match_all(self::FLEXIBLE_DOC_STRING_REGEX, $code, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) {
39 39
             // No heredoc/nowdoc found
40 40
             return $code;
41 41
         }
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\Lexer\Emulative;
6 6
 
7
-final class FlexibleDocStringEmulator extends TokenEmulator
8
-{
7
+final class FlexibleDocStringEmulator extends TokenEmulator {
9 8
     const FLEXIBLE_DOC_STRING_REGEX = <<<'REGEX'
10 9
 /<<<[ \t]*(['"]?)([a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*)\1\r?\n
11 10
 (?:.*\r?\n)*?
Please login to merge, or discard this patch.
nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/KeywordEmulator.php 2 patches
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -4,59 +4,59 @@
 block discarded – undo
4 4
 
5 5
 abstract class KeywordEmulator extends TokenEmulator
6 6
 {
7
-    abstract function getKeywordString(): string;
8
-    abstract function getKeywordToken(): int;
9
-
10
-    public function isEmulationNeeded(string $code): bool
11
-    {
12
-        return strpos(strtolower($code), $this->getKeywordString()) !== false;
13
-    }
14
-
15
-    protected function isKeywordContext(array $tokens, int $pos): bool
16
-    {
17
-        $previousNonSpaceToken = $this->getPreviousNonSpaceToken($tokens, $pos);
18
-        return $previousNonSpaceToken === null || $previousNonSpaceToken[0] !== \T_OBJECT_OPERATOR;
19
-    }
20
-
21
-    public function emulate(string $code, array $tokens): array
22
-    {
23
-        $keywordString = $this->getKeywordString();
24
-        foreach ($tokens as $i => $token) {
25
-            if ($token[0] === T_STRING && strtolower($token[1]) === $keywordString
26
-                    && $this->isKeywordContext($tokens, $i)) {
27
-                $tokens[$i][0] = $this->getKeywordToken();
28
-            }
29
-        }
30
-
31
-        return $tokens;
32
-    }
33
-
34
-    /**
35
-     * @param mixed[] $tokens
36
-     * @return array|string|null
37
-     */
38
-    private function getPreviousNonSpaceToken(array $tokens, int $start)
39
-    {
40
-        for ($i = $start - 1; $i >= 0; --$i) {
41
-            if ($tokens[$i][0] === T_WHITESPACE) {
42
-                continue;
43
-            }
44
-
45
-            return $tokens[$i];
46
-        }
47
-
48
-        return null;
49
-    }
50
-
51
-    public function reverseEmulate(string $code, array $tokens): array
52
-    {
53
-        $keywordToken = $this->getKeywordToken();
54
-        foreach ($tokens as $i => $token) {
55
-            if ($token[0] === $keywordToken) {
56
-                $tokens[$i][0] = \T_STRING;
57
-            }
58
-        }
59
-
60
-        return $tokens;
61
-    }
7
+	abstract function getKeywordString(): string;
8
+	abstract function getKeywordToken(): int;
9
+
10
+	public function isEmulationNeeded(string $code): bool
11
+	{
12
+		return strpos(strtolower($code), $this->getKeywordString()) !== false;
13
+	}
14
+
15
+	protected function isKeywordContext(array $tokens, int $pos): bool
16
+	{
17
+		$previousNonSpaceToken = $this->getPreviousNonSpaceToken($tokens, $pos);
18
+		return $previousNonSpaceToken === null || $previousNonSpaceToken[0] !== \T_OBJECT_OPERATOR;
19
+	}
20
+
21
+	public function emulate(string $code, array $tokens): array
22
+	{
23
+		$keywordString = $this->getKeywordString();
24
+		foreach ($tokens as $i => $token) {
25
+			if ($token[0] === T_STRING && strtolower($token[1]) === $keywordString
26
+					&& $this->isKeywordContext($tokens, $i)) {
27
+				$tokens[$i][0] = $this->getKeywordToken();
28
+			}
29
+		}
30
+
31
+		return $tokens;
32
+	}
33
+
34
+	/**
35
+	 * @param mixed[] $tokens
36
+	 * @return array|string|null
37
+	 */
38
+	private function getPreviousNonSpaceToken(array $tokens, int $start)
39
+	{
40
+		for ($i = $start - 1; $i >= 0; --$i) {
41
+			if ($tokens[$i][0] === T_WHITESPACE) {
42
+				continue;
43
+			}
44
+
45
+			return $tokens[$i];
46
+		}
47
+
48
+		return null;
49
+	}
50
+
51
+	public function reverseEmulate(string $code, array $tokens): array
52
+	{
53
+		$keywordToken = $this->getKeywordToken();
54
+		foreach ($tokens as $i => $token) {
55
+			if ($token[0] === $keywordToken) {
56
+				$tokens[$i][0] = \T_STRING;
57
+			}
58
+		}
59
+
60
+		return $tokens;
61
+	}
62 62
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2,8 +2,7 @@
 block discarded – undo
2 2
 
3 3
 namespace PhpParser\Lexer\TokenEmulator;
4 4
 
5
-abstract class KeywordEmulator extends TokenEmulator
6
-{
5
+abstract class KeywordEmulator extends TokenEmulator {
7 6
     abstract function getKeywordString(): string;
8 7
     abstract function getKeywordToken(): int;
9 8
 
Please login to merge, or discard this patch.
nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/FnTokenEmulator.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -6,18 +6,18 @@
 block discarded – undo
6 6
 
7 7
 final class FnTokenEmulator extends KeywordEmulator
8 8
 {
9
-    public function getPhpVersion(): string
10
-    {
11
-        return Emulative::PHP_7_4;
12
-    }
9
+	public function getPhpVersion(): string
10
+	{
11
+		return Emulative::PHP_7_4;
12
+	}
13 13
 
14
-    public function getKeywordString(): string
15
-    {
16
-        return 'fn';
17
-    }
14
+	public function getKeywordString(): string
15
+	{
16
+		return 'fn';
17
+	}
18 18
 
19
-    public function getKeywordToken(): int
20
-    {
21
-        return \T_FN;
22
-    }
19
+	public function getKeywordToken(): int
20
+	{
21
+		return \T_FN;
22
+	}
23 23
 }
24 24
\ No newline at end of file
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\Lexer\Emulative;
6 6
 
7
-final class FnTokenEmulator extends KeywordEmulator
8
-{
7
+final class FnTokenEmulator extends KeywordEmulator {
9 8
     public function getPhpVersion(): string
10 9
     {
11 10
         return Emulative::PHP_7_4;
Please login to merge, or discard this patch.
php-scoper/vendor/nikic/php-parser/lib/PhpParser/Lexer/Emulative.php 2 patches
Indentation   +227 added lines, -227 removed lines patch added patch discarded remove patch
@@ -21,231 +21,231 @@
 block discarded – undo
21 21
 
22 22
 class Emulative extends Lexer
23 23
 {
24
-    const PHP_7_3 = '7.3dev';
25
-    const PHP_7_4 = '7.4dev';
26
-    const PHP_8_0 = '8.0dev';
27
-    const PHP_8_1 = '8.1dev';
28
-    const PHP_8_2 = '8.2dev';
29
-
30
-    /** @var mixed[] Patches used to reverse changes introduced in the code */
31
-    private $patches = [];
32
-
33
-    /** @var TokenEmulator[] */
34
-    private $emulators = [];
35
-
36
-    /** @var string */
37
-    private $targetPhpVersion;
38
-
39
-    /**
40
-     * @param mixed[] $options Lexer options. In addition to the usual options,
41
-     *                         accepts a 'phpVersion' string that specifies the
42
-     *                         version to emulate. Defaults to newest supported.
43
-     */
44
-    public function __construct(array $options = [])
45
-    {
46
-        $this->targetPhpVersion = $options['phpVersion'] ?? Emulative::PHP_8_2;
47
-        unset($options['phpVersion']);
48
-
49
-        parent::__construct($options);
50
-
51
-        $emulators = [
52
-            new FlexibleDocStringEmulator(),
53
-            new FnTokenEmulator(),
54
-            new MatchTokenEmulator(),
55
-            new CoaleseEqualTokenEmulator(),
56
-            new NumericLiteralSeparatorEmulator(),
57
-            new NullsafeTokenEmulator(),
58
-            new AttributeEmulator(),
59
-            new EnumTokenEmulator(),
60
-            new ReadonlyTokenEmulator(),
61
-            new ExplicitOctalEmulator(),
62
-            new ReadonlyFunctionTokenEmulator(),
63
-        ];
64
-
65
-        // Collect emulators that are relevant for the PHP version we're running
66
-        // and the PHP version we're targeting for emulation.
67
-        foreach ($emulators as $emulator) {
68
-            $emulatorPhpVersion = $emulator->getPhpVersion();
69
-            if ($this->isForwardEmulationNeeded($emulatorPhpVersion)) {
70
-                $this->emulators[] = $emulator;
71
-            } else if ($this->isReverseEmulationNeeded($emulatorPhpVersion)) {
72
-                $this->emulators[] = new ReverseEmulator($emulator);
73
-            }
74
-        }
75
-    }
76
-
77
-    public function startLexing(string $code, ?ErrorHandler $errorHandler = null) {
78
-        $emulators = array_filter($this->emulators, function($emulator) use($code) {
79
-            return $emulator->isEmulationNeeded($code);
80
-        });
81
-
82
-        if (empty($emulators)) {
83
-            // Nothing to emulate, yay
84
-            parent::startLexing($code, $errorHandler);
85
-            return;
86
-        }
87
-
88
-        $this->patches = [];
89
-        foreach ($emulators as $emulator) {
90
-            $code = $emulator->preprocessCode($code, $this->patches);
91
-        }
92
-
93
-        $collector = new ErrorHandler\Collecting();
94
-        parent::startLexing($code, $collector);
95
-        $this->sortPatches();
96
-        $this->fixupTokens();
97
-
98
-        $errors = $collector->getErrors();
99
-        if (!empty($errors)) {
100
-            $this->fixupErrors($errors);
101
-            foreach ($errors as $error) {
102
-                $errorHandler->handleError($error);
103
-            }
104
-        }
105
-
106
-        foreach ($emulators as $emulator) {
107
-            $this->tokens = $emulator->emulate($code, $this->tokens);
108
-        }
109
-    }
110
-
111
-    private function isForwardEmulationNeeded(string $emulatorPhpVersion): bool {
112
-        return version_compare(\PHP_VERSION, $emulatorPhpVersion, '<')
113
-            && version_compare($this->targetPhpVersion, $emulatorPhpVersion, '>=');
114
-    }
115
-
116
-    private function isReverseEmulationNeeded(string $emulatorPhpVersion): bool {
117
-        return version_compare(\PHP_VERSION, $emulatorPhpVersion, '>=')
118
-            && version_compare($this->targetPhpVersion, $emulatorPhpVersion, '<');
119
-    }
120
-
121
-    private function sortPatches()
122
-    {
123
-        // Patches may be contributed by different emulators.
124
-        // Make sure they are sorted by increasing patch position.
125
-        usort($this->patches, function($p1, $p2) {
126
-            return $p1[0] <=> $p2[0];
127
-        });
128
-    }
129
-
130
-    private function fixupTokens()
131
-    {
132
-        if (\count($this->patches) === 0) {
133
-            return;
134
-        }
135
-
136
-        // Load first patch
137
-        $patchIdx = 0;
138
-
139
-        list($patchPos, $patchType, $patchText) = $this->patches[$patchIdx];
140
-
141
-        // We use a manual loop over the tokens, because we modify the array on the fly
142
-        $pos = 0;
143
-        for ($i = 0, $c = \count($this->tokens); $i < $c; $i++) {
144
-            $token = $this->tokens[$i];
145
-            if (\is_string($token)) {
146
-                if ($patchPos === $pos) {
147
-                    // Only support replacement for string tokens.
148
-                    assert($patchType === 'replace');
149
-                    $this->tokens[$i] = $patchText;
150
-
151
-                    // Fetch the next patch
152
-                    $patchIdx++;
153
-                    if ($patchIdx >= \count($this->patches)) {
154
-                        // No more patches, we're done
155
-                        return;
156
-                    }
157
-                    list($patchPos, $patchType, $patchText) = $this->patches[$patchIdx];
158
-                }
159
-
160
-                $pos += \strlen($token);
161
-                continue;
162
-            }
163
-
164
-            $len = \strlen($token[1]);
165
-            $posDelta = 0;
166
-            while ($patchPos >= $pos && $patchPos < $pos + $len) {
167
-                $patchTextLen = \strlen($patchText);
168
-                if ($patchType === 'remove') {
169
-                    if ($patchPos === $pos && $patchTextLen === $len) {
170
-                        // Remove token entirely
171
-                        array_splice($this->tokens, $i, 1, []);
172
-                        $i--;
173
-                        $c--;
174
-                    } else {
175
-                        // Remove from token string
176
-                        $this->tokens[$i][1] = substr_replace(
177
-                            $token[1], '', $patchPos - $pos + $posDelta, $patchTextLen
178
-                        );
179
-                        $posDelta -= $patchTextLen;
180
-                    }
181
-                } elseif ($patchType === 'add') {
182
-                    // Insert into the token string
183
-                    $this->tokens[$i][1] = substr_replace(
184
-                        $token[1], $patchText, $patchPos - $pos + $posDelta, 0
185
-                    );
186
-                    $posDelta += $patchTextLen;
187
-                } else if ($patchType === 'replace') {
188
-                    // Replace inside the token string
189
-                    $this->tokens[$i][1] = substr_replace(
190
-                        $token[1], $patchText, $patchPos - $pos + $posDelta, $patchTextLen
191
-                    );
192
-                } else {
193
-                    assert(false);
194
-                }
195
-
196
-                // Fetch the next patch
197
-                $patchIdx++;
198
-                if ($patchIdx >= \count($this->patches)) {
199
-                    // No more patches, we're done
200
-                    return;
201
-                }
202
-
203
-                list($patchPos, $patchType, $patchText) = $this->patches[$patchIdx];
204
-
205
-                // Multiple patches may apply to the same token. Reload the current one to check
206
-                // If the new patch applies
207
-                $token = $this->tokens[$i];
208
-            }
209
-
210
-            $pos += $len;
211
-        }
212
-
213
-        // A patch did not apply
214
-        assert(false);
215
-    }
216
-
217
-    /**
218
-     * Fixup line and position information in errors.
219
-     *
220
-     * @param Error[] $errors
221
-     */
222
-    private function fixupErrors(array $errors) {
223
-        foreach ($errors as $error) {
224
-            $attrs = $error->getAttributes();
225
-
226
-            $posDelta = 0;
227
-            $lineDelta = 0;
228
-            foreach ($this->patches as $patch) {
229
-                list($patchPos, $patchType, $patchText) = $patch;
230
-                if ($patchPos >= $attrs['startFilePos']) {
231
-                    // No longer relevant
232
-                    break;
233
-                }
234
-
235
-                if ($patchType === 'add') {
236
-                    $posDelta += strlen($patchText);
237
-                    $lineDelta += substr_count($patchText, "\n");
238
-                } else if ($patchType === 'remove') {
239
-                    $posDelta -= strlen($patchText);
240
-                    $lineDelta -= substr_count($patchText, "\n");
241
-                }
242
-            }
243
-
244
-            $attrs['startFilePos'] += $posDelta;
245
-            $attrs['endFilePos'] += $posDelta;
246
-            $attrs['startLine'] += $lineDelta;
247
-            $attrs['endLine'] += $lineDelta;
248
-            $error->setAttributes($attrs);
249
-        }
250
-    }
24
+	const PHP_7_3 = '7.3dev';
25
+	const PHP_7_4 = '7.4dev';
26
+	const PHP_8_0 = '8.0dev';
27
+	const PHP_8_1 = '8.1dev';
28
+	const PHP_8_2 = '8.2dev';
29
+
30
+	/** @var mixed[] Patches used to reverse changes introduced in the code */
31
+	private $patches = [];
32
+
33
+	/** @var TokenEmulator[] */
34
+	private $emulators = [];
35
+
36
+	/** @var string */
37
+	private $targetPhpVersion;
38
+
39
+	/**
40
+	 * @param mixed[] $options Lexer options. In addition to the usual options,
41
+	 *                         accepts a 'phpVersion' string that specifies the
42
+	 *                         version to emulate. Defaults to newest supported.
43
+	 */
44
+	public function __construct(array $options = [])
45
+	{
46
+		$this->targetPhpVersion = $options['phpVersion'] ?? Emulative::PHP_8_2;
47
+		unset($options['phpVersion']);
48
+
49
+		parent::__construct($options);
50
+
51
+		$emulators = [
52
+			new FlexibleDocStringEmulator(),
53
+			new FnTokenEmulator(),
54
+			new MatchTokenEmulator(),
55
+			new CoaleseEqualTokenEmulator(),
56
+			new NumericLiteralSeparatorEmulator(),
57
+			new NullsafeTokenEmulator(),
58
+			new AttributeEmulator(),
59
+			new EnumTokenEmulator(),
60
+			new ReadonlyTokenEmulator(),
61
+			new ExplicitOctalEmulator(),
62
+			new ReadonlyFunctionTokenEmulator(),
63
+		];
64
+
65
+		// Collect emulators that are relevant for the PHP version we're running
66
+		// and the PHP version we're targeting for emulation.
67
+		foreach ($emulators as $emulator) {
68
+			$emulatorPhpVersion = $emulator->getPhpVersion();
69
+			if ($this->isForwardEmulationNeeded($emulatorPhpVersion)) {
70
+				$this->emulators[] = $emulator;
71
+			} else if ($this->isReverseEmulationNeeded($emulatorPhpVersion)) {
72
+				$this->emulators[] = new ReverseEmulator($emulator);
73
+			}
74
+		}
75
+	}
76
+
77
+	public function startLexing(string $code, ?ErrorHandler $errorHandler = null) {
78
+		$emulators = array_filter($this->emulators, function($emulator) use($code) {
79
+			return $emulator->isEmulationNeeded($code);
80
+		});
81
+
82
+		if (empty($emulators)) {
83
+			// Nothing to emulate, yay
84
+			parent::startLexing($code, $errorHandler);
85
+			return;
86
+		}
87
+
88
+		$this->patches = [];
89
+		foreach ($emulators as $emulator) {
90
+			$code = $emulator->preprocessCode($code, $this->patches);
91
+		}
92
+
93
+		$collector = new ErrorHandler\Collecting();
94
+		parent::startLexing($code, $collector);
95
+		$this->sortPatches();
96
+		$this->fixupTokens();
97
+
98
+		$errors = $collector->getErrors();
99
+		if (!empty($errors)) {
100
+			$this->fixupErrors($errors);
101
+			foreach ($errors as $error) {
102
+				$errorHandler->handleError($error);
103
+			}
104
+		}
105
+
106
+		foreach ($emulators as $emulator) {
107
+			$this->tokens = $emulator->emulate($code, $this->tokens);
108
+		}
109
+	}
110
+
111
+	private function isForwardEmulationNeeded(string $emulatorPhpVersion): bool {
112
+		return version_compare(\PHP_VERSION, $emulatorPhpVersion, '<')
113
+			&& version_compare($this->targetPhpVersion, $emulatorPhpVersion, '>=');
114
+	}
115
+
116
+	private function isReverseEmulationNeeded(string $emulatorPhpVersion): bool {
117
+		return version_compare(\PHP_VERSION, $emulatorPhpVersion, '>=')
118
+			&& version_compare($this->targetPhpVersion, $emulatorPhpVersion, '<');
119
+	}
120
+
121
+	private function sortPatches()
122
+	{
123
+		// Patches may be contributed by different emulators.
124
+		// Make sure they are sorted by increasing patch position.
125
+		usort($this->patches, function($p1, $p2) {
126
+			return $p1[0] <=> $p2[0];
127
+		});
128
+	}
129
+
130
+	private function fixupTokens()
131
+	{
132
+		if (\count($this->patches) === 0) {
133
+			return;
134
+		}
135
+
136
+		// Load first patch
137
+		$patchIdx = 0;
138
+
139
+		list($patchPos, $patchType, $patchText) = $this->patches[$patchIdx];
140
+
141
+		// We use a manual loop over the tokens, because we modify the array on the fly
142
+		$pos = 0;
143
+		for ($i = 0, $c = \count($this->tokens); $i < $c; $i++) {
144
+			$token = $this->tokens[$i];
145
+			if (\is_string($token)) {
146
+				if ($patchPos === $pos) {
147
+					// Only support replacement for string tokens.
148
+					assert($patchType === 'replace');
149
+					$this->tokens[$i] = $patchText;
150
+
151
+					// Fetch the next patch
152
+					$patchIdx++;
153
+					if ($patchIdx >= \count($this->patches)) {
154
+						// No more patches, we're done
155
+						return;
156
+					}
157
+					list($patchPos, $patchType, $patchText) = $this->patches[$patchIdx];
158
+				}
159
+
160
+				$pos += \strlen($token);
161
+				continue;
162
+			}
163
+
164
+			$len = \strlen($token[1]);
165
+			$posDelta = 0;
166
+			while ($patchPos >= $pos && $patchPos < $pos + $len) {
167
+				$patchTextLen = \strlen($patchText);
168
+				if ($patchType === 'remove') {
169
+					if ($patchPos === $pos && $patchTextLen === $len) {
170
+						// Remove token entirely
171
+						array_splice($this->tokens, $i, 1, []);
172
+						$i--;
173
+						$c--;
174
+					} else {
175
+						// Remove from token string
176
+						$this->tokens[$i][1] = substr_replace(
177
+							$token[1], '', $patchPos - $pos + $posDelta, $patchTextLen
178
+						);
179
+						$posDelta -= $patchTextLen;
180
+					}
181
+				} elseif ($patchType === 'add') {
182
+					// Insert into the token string
183
+					$this->tokens[$i][1] = substr_replace(
184
+						$token[1], $patchText, $patchPos - $pos + $posDelta, 0
185
+					);
186
+					$posDelta += $patchTextLen;
187
+				} else if ($patchType === 'replace') {
188
+					// Replace inside the token string
189
+					$this->tokens[$i][1] = substr_replace(
190
+						$token[1], $patchText, $patchPos - $pos + $posDelta, $patchTextLen
191
+					);
192
+				} else {
193
+					assert(false);
194
+				}
195
+
196
+				// Fetch the next patch
197
+				$patchIdx++;
198
+				if ($patchIdx >= \count($this->patches)) {
199
+					// No more patches, we're done
200
+					return;
201
+				}
202
+
203
+				list($patchPos, $patchType, $patchText) = $this->patches[$patchIdx];
204
+
205
+				// Multiple patches may apply to the same token. Reload the current one to check
206
+				// If the new patch applies
207
+				$token = $this->tokens[$i];
208
+			}
209
+
210
+			$pos += $len;
211
+		}
212
+
213
+		// A patch did not apply
214
+		assert(false);
215
+	}
216
+
217
+	/**
218
+	 * Fixup line and position information in errors.
219
+	 *
220
+	 * @param Error[] $errors
221
+	 */
222
+	private function fixupErrors(array $errors) {
223
+		foreach ($errors as $error) {
224
+			$attrs = $error->getAttributes();
225
+
226
+			$posDelta = 0;
227
+			$lineDelta = 0;
228
+			foreach ($this->patches as $patch) {
229
+				list($patchPos, $patchType, $patchText) = $patch;
230
+				if ($patchPos >= $attrs['startFilePos']) {
231
+					// No longer relevant
232
+					break;
233
+				}
234
+
235
+				if ($patchType === 'add') {
236
+					$posDelta += strlen($patchText);
237
+					$lineDelta += substr_count($patchText, "\n");
238
+				} else if ($patchType === 'remove') {
239
+					$posDelta -= strlen($patchText);
240
+					$lineDelta -= substr_count($patchText, "\n");
241
+				}
242
+			}
243
+
244
+			$attrs['startFilePos'] += $posDelta;
245
+			$attrs['endFilePos'] += $posDelta;
246
+			$attrs['startLine'] += $lineDelta;
247
+			$attrs['endLine'] += $lineDelta;
248
+			$error->setAttributes($attrs);
249
+		}
250
+	}
251 251
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,8 +19,7 @@
 block discarded – undo
19 19
 use PhpParser\Lexer\TokenEmulator\ReverseEmulator;
20 20
 use PhpParser\Lexer\TokenEmulator\TokenEmulator;
21 21
 
22
-class Emulative extends Lexer
23
-{
22
+class Emulative extends Lexer {
24 23
     const PHP_7_3 = '7.3dev';
25 24
     const PHP_7_4 = '7.4dev';
26 25
     const PHP_8_0 = '8.0dev';
Please login to merge, or discard this patch.
nikic/php-parser/lib/PhpParser/NodeVisitor/ParentConnectingVisitor.php 2 patches
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -15,27 +15,27 @@
 block discarded – undo
15 15
  */
16 16
 final class ParentConnectingVisitor extends NodeVisitorAbstract
17 17
 {
18
-    /**
19
-     * @var Node[]
20
-     */
21
-    private $stack = [];
18
+	/**
19
+	 * @var Node[]
20
+	 */
21
+	private $stack = [];
22 22
 
23
-    public function beforeTraverse(array $nodes)
24
-    {
25
-        $this->stack = [];
26
-    }
23
+	public function beforeTraverse(array $nodes)
24
+	{
25
+		$this->stack = [];
26
+	}
27 27
 
28
-    public function enterNode(Node $node)
29
-    {
30
-        if (!empty($this->stack)) {
31
-            $node->setAttribute('parent', $this->stack[count($this->stack) - 1]);
32
-        }
28
+	public function enterNode(Node $node)
29
+	{
30
+		if (!empty($this->stack)) {
31
+			$node->setAttribute('parent', $this->stack[count($this->stack) - 1]);
32
+		}
33 33
 
34
-        $this->stack[] = $node;
35
-    }
34
+		$this->stack[] = $node;
35
+	}
36 36
 
37
-    public function leaveNode(Node $node)
38
-    {
39
-        array_pop($this->stack);
40
-    }
37
+	public function leaveNode(Node $node)
38
+	{
39
+		array_pop($this->stack);
40
+	}
41 41
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,8 +13,7 @@
 block discarded – undo
13 13
  * On the child node, the parent node can be accessed through
14 14
  * <code>$node->getAttribute('parent')</code>.
15 15
  */
16
-final class ParentConnectingVisitor extends NodeVisitorAbstract
17
-{
16
+final class ParentConnectingVisitor extends NodeVisitorAbstract {
18 17
     /**
19 18
      * @var Node[]
20 19
      */
Please login to merge, or discard this patch.
vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/NodeConnectingVisitor.php 2 patches
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -16,37 +16,37 @@
 block discarded – undo
16 16
  */
17 17
 final class NodeConnectingVisitor extends NodeVisitorAbstract
18 18
 {
19
-    /**
20
-     * @var Node[]
21
-     */
22
-    private $stack = [];
23
-
24
-    /**
25
-     * @var ?Node
26
-     */
27
-    private $previous;
28
-
29
-    public function beforeTraverse(array $nodes) {
30
-        $this->stack    = [];
31
-        $this->previous = null;
32
-    }
33
-
34
-    public function enterNode(Node $node) {
35
-        if (!empty($this->stack)) {
36
-            $node->setAttribute('parent', $this->stack[count($this->stack) - 1]);
37
-        }
38
-
39
-        if ($this->previous !== null && $this->previous->getAttribute('parent') === $node->getAttribute('parent')) {
40
-            $node->setAttribute('previous', $this->previous);
41
-            $this->previous->setAttribute('next', $node);
42
-        }
43
-
44
-        $this->stack[] = $node;
45
-    }
46
-
47
-    public function leaveNode(Node $node) {
48
-        $this->previous = $node;
49
-
50
-        array_pop($this->stack);
51
-    }
19
+	/**
20
+	 * @var Node[]
21
+	 */
22
+	private $stack = [];
23
+
24
+	/**
25
+	 * @var ?Node
26
+	 */
27
+	private $previous;
28
+
29
+	public function beforeTraverse(array $nodes) {
30
+		$this->stack    = [];
31
+		$this->previous = null;
32
+	}
33
+
34
+	public function enterNode(Node $node) {
35
+		if (!empty($this->stack)) {
36
+			$node->setAttribute('parent', $this->stack[count($this->stack) - 1]);
37
+		}
38
+
39
+		if ($this->previous !== null && $this->previous->getAttribute('parent') === $node->getAttribute('parent')) {
40
+			$node->setAttribute('previous', $this->previous);
41
+			$this->previous->setAttribute('next', $node);
42
+		}
43
+
44
+		$this->stack[] = $node;
45
+	}
46
+
47
+	public function leaveNode(Node $node) {
48
+		$this->previous = $node;
49
+
50
+		array_pop($this->stack);
51
+	}
52 52
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,8 +14,7 @@
 block discarded – undo
14 14
  * node can be accessed through <code>$node->getAttribute('previous')</code>,
15 15
  * and the next node can be accessed through <code>$node->getAttribute('next')</code>.
16 16
  */
17
-final class NodeConnectingVisitor extends NodeVisitorAbstract
18
-{
17
+final class NodeConnectingVisitor extends NodeVisitorAbstract {
19 18
     /**
20 19
      * @var Node[]
21 20
      */
Please login to merge, or discard this patch.
vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/FindingVisitor.php 2 patches
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -11,38 +11,38 @@
 block discarded – undo
11 11
  */
12 12
 class FindingVisitor extends NodeVisitorAbstract
13 13
 {
14
-    /** @var callable Filter callback */
15
-    protected $filterCallback;
16
-    /** @var Node[] Found nodes */
17
-    protected $foundNodes;
18
-
19
-    public function __construct(callable $filterCallback) {
20
-        $this->filterCallback = $filterCallback;
21
-    }
22
-
23
-    /**
24
-     * Get found nodes satisfying the filter callback.
25
-     *
26
-     * Nodes are returned in pre-order.
27
-     *
28
-     * @return Node[] Found nodes
29
-     */
30
-    public function getFoundNodes() : array {
31
-        return $this->foundNodes;
32
-    }
33
-
34
-    public function beforeTraverse(array $nodes) {
35
-        $this->foundNodes = [];
36
-
37
-        return null;
38
-    }
39
-
40
-    public function enterNode(Node $node) {
41
-        $filterCallback = $this->filterCallback;
42
-        if ($filterCallback($node)) {
43
-            $this->foundNodes[] = $node;
44
-        }
45
-
46
-        return null;
47
-    }
14
+	/** @var callable Filter callback */
15
+	protected $filterCallback;
16
+	/** @var Node[] Found nodes */
17
+	protected $foundNodes;
18
+
19
+	public function __construct(callable $filterCallback) {
20
+		$this->filterCallback = $filterCallback;
21
+	}
22
+
23
+	/**
24
+	 * Get found nodes satisfying the filter callback.
25
+	 *
26
+	 * Nodes are returned in pre-order.
27
+	 *
28
+	 * @return Node[] Found nodes
29
+	 */
30
+	public function getFoundNodes() : array {
31
+		return $this->foundNodes;
32
+	}
33
+
34
+	public function beforeTraverse(array $nodes) {
35
+		$this->foundNodes = [];
36
+
37
+		return null;
38
+	}
39
+
40
+	public function enterNode(Node $node) {
41
+		$filterCallback = $this->filterCallback;
42
+		if ($filterCallback($node)) {
43
+			$this->foundNodes[] = $node;
44
+		}
45
+
46
+		return null;
47
+	}
48 48
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,8 +9,7 @@
 block discarded – undo
9 9
  * This visitor can be used to find and collect all nodes satisfying some criterion determined by
10 10
  * a filter callback.
11 11
  */
12
-class FindingVisitor extends NodeVisitorAbstract
13
-{
12
+class FindingVisitor extends NodeVisitorAbstract {
14 13
     /** @var callable Filter callback */
15 14
     protected $filterCallback;
16 15
     /** @var Node[] Found nodes */
Please login to merge, or discard this patch.