Skip to content
This repository was archived by the owner on Nov 5, 2022. It is now read-only.

Commit 7a58ab9

Browse files
committed
Fixed issue with return array alignment
1 parent 204803e commit 7a58ab9

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

CodeIgniter4/Sniffs/Arrays/ArrayDeclarationSniff.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,9 @@ public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $array
406406
$prevNonWhitespaceToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
407407
if ($tokens[$prevNonWhitespaceToken]['code'] === T_EQUAL
408408
|| $tokens[$prevNonWhitespaceToken]['code'] === T_OPEN_PARENTHESIS
409+
|| $tokens[$prevNonWhitespaceToken]['code'] === T_RETURN
409410
) {
410-
// It's "=" or "(".
411+
// It's "=", "(" or "return".
411412
$indentStart = $this->arrayDeclaredAt($phpcsFile, $prevNonWhitespaceToken);
412413
} else if ($tokens[$prevNonWhitespaceToken]['code'] === T_DOUBLE_ARROW) {
413414
// It's an array in an array "=> []".

CodeIgniter4/Tests/Arrays/ArrayDeclarationUnitTest.inc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,12 @@ class MyClass {
6363
// 2xx: Success
6464
200 => 'OK',
6565
];
66+
67+
public function error()
68+
{
69+
return [
70+
'code' => '',
71+
'message' => pg_last_error($this->connID)
72+
];
73+
}
6674
}

CodeIgniter4/Tests/Arrays/ArrayDeclarationUnitTest.inc.fixed

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,12 @@ class MyClass {
127127
// 2xx: Success
128128
200 => 'OK',
129129
];
130+
131+
public function error()
132+
{
133+
return [
134+
'code' => '',
135+
'message' => pg_last_error($this->connID),
136+
];
137+
}
130138
}

CodeIgniter4/Tests/Arrays/ArrayDeclarationUnitTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ public function getErrorList()
7171
61 => 1,
7272
62 => 1,
7373
64 => 1,
74+
70 => 1,
75+
71 => 1,
7476
);
7577

7678
}//end getErrorList()

0 commit comments

Comments
 (0)