Skip to content

Commit

Permalink
Merge branch 'php-8.0/generic-unused-parameter-add-support-constr-pro…
Browse files Browse the repository at this point in the history
  • Loading branch information
gsherwood committed Mar 16, 2021
2 parents dc59530 + 529043f commit 6825333
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ public function process(File $phpcsFile, $stackPtr)
}

foreach ($methodParams as $param) {
if (isset($param['property_visibility']) === true) {
// Ignore. Constructor property promotion.
continue;
}

$params[$param['name']] = $stackPtr;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,16 @@ function moreParamFirst(Exception $foo, LogicException $bar) {
function moreParamSecond(LogicException $bar, Exception $foo) {
return 'foobar' . $bar;
}
// phpcs:set Generic.CodeAnalysis.UnusedFunctionParameter ignoreTypeHints[]

class ConstructorPropertyPromotionNoContentInMethod {
public function __construct(protected int $id) {}
}

class ConstructorPropertyPromotionWithContentInMethod {
public function __construct(protected int $id, $toggle = true) {
if ($toggle === true) {
doSomething();
}
}
}

0 comments on commit 6825333

Please sign in to comment.