-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prototype #25
Prototype #25
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,7 +49,7 @@ class DocCommentAlignmentSniff implements Sniff | |
/** | ||
* Returns an array of tokens this test wants to listen for. | ||
* | ||
* @return array | ||
* @return array<int|string> | ||
*/ | ||
public function register() | ||
{ | ||
|
@@ -82,6 +82,8 @@ public function process(File $phpcsFile, $stackPtr) | |
$ignore = [ | ||
T_CLASS => true, | ||
T_INTERFACE => true, | ||
T_ENUM => true, | ||
T_ENUM_CASE => true, | ||
T_FUNCTION => true, | ||
T_PUBLIC => true, | ||
T_PRIVATE => true, | ||
|
@@ -92,6 +94,7 @@ public function process(File $phpcsFile, $stackPtr) | |
T_OBJECT => true, | ||
T_PROTOTYPE => true, | ||
T_VAR => true, | ||
T_READONLY => true, | ||
]; | ||
|
||
if ($nextToken === false || isset($ignore[$tokens[$nextToken]['code']]) === false) { | ||
|
@@ -127,7 +130,12 @@ public function process(File $phpcsFile, $stackPtr) | |
} | ||
|
||
if ($tokens[$i]['column'] !== $requiredColumn) { | ||
$error = 'Expected %s space(s) before asterisk; %s found'; | ||
$pluralizeSpace = 's'; | ||
if (($requiredColumn - 1) === 1) { | ||
$pluralizeSpace = ''; | ||
} | ||
|
||
$error = 'Expected %s space%s before asterisk; %s found'; | ||
$data = [ | ||
($requiredColumn - 1), | ||
($tokens[$i]['column'] - 1), | ||
|
@@ -141,7 +149,7 @@ public function process(File $phpcsFile, $stackPtr) | |
$phpcsFile->fixer->replaceToken(($i - 1), $padding); | ||
} | ||
} | ||
} | ||
}//end if | ||
|
||
if ($tokens[$i]['code'] !== T_DOC_COMMENT_STAR) { | ||
continue; | ||
|
@@ -162,6 +170,7 @@ public function process(File $phpcsFile, $stackPtr) | |
&& $tokens[($i + 1)]['content'] !== ' ' | ||
&& strtolower(substr($tokens[($i + 1)]['content'], 0, 3)) !== '@oa' | ||
&& strtolower(substr($tokens[($i + 2)]['content'], 0, 3)) !== '@oa' | ||
&& !str_starts_with(strtolower($tokens[($i + 1)]['content']), '@orm') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why using brackets in all the index statements? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As this was just a core hack to learn if it helps solving your problem I wouldn't go too deep into that. ^ |
||
) { | ||
$error = 'Expected 1 space after asterisk; %s found'; | ||
$data = [$tokens[($i + 1)]['length']]; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This
for
loop needs refactoring 😉