Skip to content

Commit ae34a97

Browse files
committed
Fix false missing arg type declaration for by-reference param
Fixes #17
1 parent 25edfc4 commit ae34a97

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## NOT RELEASED
4+
- Fixed false positive "missing argument type declaration" when param are passed by-reference.
5+
36
## 0.13.2
47
- Changed "squizlabs/php_codesniffer" in composer.json to "~3.2.3"
58

Inpsyde/Sniffs/CodeQuality/ArgumentTypeDeclarationSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function process(File $file, $position)
7070

7171
foreach (array_keys($variables) as $varPosition) {
7272
$typePosition = $file->findPrevious(
73-
[T_WHITESPACE, T_ELLIPSIS],
73+
[T_WHITESPACE, T_ELLIPSIS, T_BITWISE_AND],
7474
$varPosition - 1,
7575
$paramsStart + 1,
7676
true

tests/fixtures/argument-type-declaration.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<?php
22
// @phpcsSniff CodeQuality.ArgumentTypeDeclaration
33

4+
array_walk($slugs, function (string &$slug) {
5+
$slug = sanitize_key($slug);
6+
});
7+
48
// @phpcsWarningOnNextLine
59
function a($foo)
610
{

0 commit comments

Comments
 (0)