@@ 63-81 (lines=19) @@ | ||
60 | } |
|
61 | ||
62 | ||
63 | private function processOpen(PHP_CodeSniffer_File $file, int $position) |
|
64 | { |
|
65 | $tokens = $file->getTokens(); |
|
66 | $openingBracePosition = $tokens[$position]['scope_opener']; |
|
67 | $emptyLinesCount = $this->getEmptyLinesAfterOpeningBrace($file, $openingBracePosition); |
|
68 | ||
69 | if ($emptyLinesCount !== $this->emptyLinesAfterOpeningBrace) { |
|
70 | $error = 'Opening brace for the %s should be followed by %s empty line(s); %s found.'; |
|
71 | $data = [ |
|
72 | $tokens[$position]['content'], |
|
73 | $this->emptyLinesAfterOpeningBrace, |
|
74 | $emptyLinesCount, |
|
75 | ]; |
|
76 | $fix = $file->addFixableError($error, $openingBracePosition, 'OpenBraceFollowedByEmptyLines', $data); |
|
77 | if ($fix) { |
|
78 | $this->fixOpeningBraceSpaces($openingBracePosition, $emptyLinesCount); |
|
79 | } |
|
80 | } |
|
81 | } |
|
82 | ||
83 | ||
84 | private function processClose(PHP_CodeSniffer_File $file, int $position) |
|
@@ 84-102 (lines=19) @@ | ||
81 | } |
|
82 | ||
83 | ||
84 | private function processClose(PHP_CodeSniffer_File $file, int $position) |
|
85 | { |
|
86 | $tokens = $file->getTokens(); |
|
87 | $closeBracePosition = $tokens[$position]['scope_closer']; |
|
88 | $emptyLinesCount = $this->getEmptyLinesBeforeClosingBrace($file, $closeBracePosition); |
|
89 | ||
90 | if ($emptyLinesCount !== $this->emptyLinesBeforeClosingBrace) { |
|
91 | $error = 'Closing brace for the %s should be preceded by %s empty line(s); %s found.'; |
|
92 | $data = [ |
|
93 | $tokens[$position]['content'], |
|
94 | $this->emptyLinesBeforeClosingBrace, |
|
95 | $emptyLinesCount |
|
96 | ]; |
|
97 | $fix = $file->addFixableError($error, $closeBracePosition, 'CloseBracePrecededByEmptyLines', $data); |
|
98 | if ($fix) { |
|
99 | $this->fixClosingBraceSpaces($closeBracePosition, $emptyLinesCount); |
|
100 | } |
|
101 | } |
|
102 | } |
|
103 | ||
104 | ||
105 | private function getEmptyLinesBeforeClosingBrace(PHP_CodeSniffer_File $file, int $position) : int |