Skip to content

Commit 4bbc820

Browse files
authored
Merge pull request #340 from fredden/missing-fixed-file/Squiz.Commenting.ClosingDeclarationComment
`Squiz.Commenting.ClosingDeclarationComment` - add missing `.fixed` file for test-suite, and fix a bug found during
2 parents 3e582fe + 66e87a1 commit 4bbc820

File tree

2 files changed

+86
-1
lines changed

2 files changed

+86
-1
lines changed

src/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function process(File $phpcsFile, $stackPtr)
110110
} else {
111111
$fix = $phpcsFile->addFixableError('Expected %s', $closingBracket, 'Missing', $data);
112112
if ($fix === true) {
113-
$phpcsFile->fixer->replaceToken($closingBracket, '}'.$comment.$phpcsFile->eolChar);
113+
$phpcsFile->fixer->replaceToken($closingBracket, '}'.$comment);
114114
}
115115
}
116116

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?php
2+
3+
function __construct()
4+
{
5+
}//end __construct()
6+
7+
function myFunction()
8+
{
9+
}//end myFunction()
10+
11+
function ourFunction()
12+
{
13+
}//end ourFunction()
14+
15+
function yourFunction()
16+
{
17+
}//end yourFunction()
18+
19+
class TestClass
20+
{
21+
function __construct()
22+
{
23+
}//end __construct()
24+
25+
function myFunction()
26+
{
27+
}//end myFunction()
28+
29+
function yourFunction()
30+
{
31+
}//end yourFunction()
32+
33+
}//end class
34+
35+
abstract class TestClass
36+
{
37+
abstract function myFunction();
38+
39+
function ourFunction()
40+
{
41+
}//end ourFunction()
42+
43+
function yourFunction()
44+
{
45+
}//end yourFunction()
46+
47+
}//end class
48+
49+
interface TestClass
50+
{
51+
function myFunction();
52+
function ourFunction();
53+
function yourFunction();
54+
55+
}//end interface
56+
57+
class TestClass
58+
{
59+
}//end class
60+
61+
abstract class TestClass
62+
{
63+
}//end class
64+
65+
interface TestClass
66+
{
67+
}//end interface
68+
69+
class MyClass
70+
{
71+
public function myFunction();
72+
}//end class
73+
74+
// Closures don't need end comments.
75+
echo preg_replace_callback('~-([a-z])~', function ($match) { return strtoupper($match[1]); }, 'hello-world');
76+
77+
class TestClass
78+
{
79+
}//end class
80+
81+
enum MissingClosingComment {
82+
}//end enum
83+
84+
enum HasClosingComment {
85+
}//end enum

0 commit comments

Comments
 (0)