Skip to content

Commit 5c92ab8

Browse files
committed
CS fix and cleanup
1 parent 34a477e commit 5c92ab8

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

Inpsyde/Sniffs/CodeQuality/ForbiddenPublicPropertySniff.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function process(File $file, $position)
4949
return;
5050
}
5151

52-
$scopeModifierToken = $this->getPropertyScopeModifier($file, $position);
52+
$scopeModifierToken = $this->propertyScopeModifier($file, $position);
5353
if ($scopeModifierToken['code'] === T_PUBLIC) {
5454
$file->addError(
5555
'Do not use public properties. Use method access instead.',
@@ -85,12 +85,9 @@ private function isSniffClass(File $file, int $position): bool
8585
* @param int $position
8686
* @return mixed[]
8787
*/
88-
private function getPropertyScopeModifier(File $file, int $position): array
88+
private function propertyScopeModifier(File $file, int $position): array
8989
{
90-
$scopeModifierPosition = $file->findPrevious(
91-
Tokens::$scopeModifiers,
92-
($position - 1)
93-
);
90+
$scopeModifierPosition = $file->findPrevious(Tokens::$scopeModifiers, ($position - 1));
9491

9592
return $file->getTokens()[$scopeModifierPosition];
9693
}

Inpsyde/Sniffs/CodeQuality/FunctionLengthSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function register()
5858
*/
5959
public function process(File $file, $position)
6060
{
61-
$length = $this->getStructureLengthInLines($file, $position);
61+
$length = $this->structureLinesCount($file, $position);
6262
if ($length <= $this->maxLength) {
6363
return;
6464
}
@@ -90,7 +90,7 @@ public function process(File $file, $position)
9090
* @param int $position
9191
* @return int
9292
*/
93-
public function getStructureLengthInLines(File $file, int $position): int
93+
public function structureLinesCount(File $file, int $position): int
9494
{
9595
$tokens = $file->getTokens();
9696
$token = $tokens[$position] ?? [];

Inpsyde/Sniffs/CodeQuality/NoElseSniff.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@
2424
*/
2525
final class NoElseSniff implements Sniff
2626
{
27-
/**
28-
* @var string
29-
*/
30-
const ERROR_MESSAGE = 'Do not use "else". Prefer early return statement instead.';
31-
3227
/**
3328
* @return int[]
3429
*/
@@ -43,6 +38,10 @@ public function register()
4338
*/
4439
public function process(File $file, $position)
4540
{
46-
$file->addWarning(self::ERROR_MESSAGE, $position, 'NoElse');
41+
$file->addWarning(
42+
'Do not use "else". Prefer early return statement instead.',
43+
$position,
44+
'ElseFound'
45+
);
4746
}
4847
}

0 commit comments

Comments
 (0)