File tree Expand file tree Collapse file tree 3 files changed +30
-0
lines changed Expand file tree Collapse file tree 3 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -93,6 +93,16 @@ public function process(File $phpcsFile, $stackPtr)
93
93
break ;
94
94
}
95
95
96
+ // Constructor methods are exempt from requiring a docblock.
97
+ // @see https://www.drupal.org/project/coder/issues/3400560.
98
+ $ methodName = $ phpcsFile ->getDeclarationName ($ stackPtr );
99
+ if ($ methodName === '__construct '
100
+ && $ tokens [$ commentEnd ]['code ' ] !== T_DOC_COMMENT_CLOSE_TAG
101
+ && $ tokens [$ commentEnd ]['code ' ] !== T_COMMENT
102
+ ) {
103
+ return ;
104
+ }
105
+
96
106
$ beforeCommentEnd = $ phpcsFile ->findPrevious (Tokens::$ emptyTokens , ($ commentEnd - 1 ), null , true );
97
107
if (($ tokens [$ commentEnd ]['code ' ] !== T_DOC_COMMENT_CLOSE_TAG
98
108
&& $ tokens [$ commentEnd ]['code ' ] !== T_COMMENT )
Original file line number Diff line number Diff line change @@ -947,4 +947,14 @@ class Test3 {
947
947
return [];
948
948
}
949
949
950
+ }
951
+
952
+ /**
953
+ * Test that docblock is optional for __construct methods.
954
+ */
955
+ class Test43 {
956
+
957
+ public function __construct () {
958
+ }
959
+
950
960
}
Original file line number Diff line number Diff line change @@ -974,3 +974,13 @@ class Test3 {
974
974
}
975
975
976
976
}
977
+
978
+ /**
979
+ * Test that docblock is optional for __construct methods.
980
+ */
981
+ class Test43 {
982
+
983
+ public function __construct() {
984
+ }
985
+
986
+ }
You can’t perform that action at this time.
0 commit comments