Skip to content

Commit ab7501d

Browse files
authored
NoUselessParenthesisFixer - fix for callable properties
1 parent b94eba5 commit ab7501d

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![Latest stable version](https://img.shields.io/packagist/v/kubawerlos/php-cs-fixer-custom-fixers.svg?label=current%20version)](https://packagist.org/packages/kubawerlos/php-cs-fixer-custom-fixers)
44
[![PHP version](https://img.shields.io/packagist/php-v/kubawerlos/php-cs-fixer-custom-fixers.svg)](https://php.net)
55
[![License](https://img.shields.io/github/license/kubawerlos/php-cs-fixer-custom-fixers.svg)](LICENSE)
6-
![Tests](https://img.shields.io/badge/tests-2678-brightgreen.svg)
6+
![Tests](https://img.shields.io/badge/tests-2681-brightgreen.svg)
77
[![Downloads](https://img.shields.io/packagist/dt/kubawerlos/php-cs-fixer-custom-fixers.svg)](https://packagist.org/packages/kubawerlos/php-cs-fixer-custom-fixers)
88

99
[![CI Status](https://github.com/kubawerlos/php-cs-fixer-custom-fixers/workflows/CI/badge.svg?branch=main&event=push)](https://github.com/kubawerlos/php-cs-fixer-custom-fixers/actions)

src/Fixer/NoUselessParenthesisFixer.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ private function isBlockToRemove(Tokens $tokens, int $startIndex, int $endIndex)
105105
/** @var Token $nextEndToken */
106106
$nextEndToken = $tokens[$nextEndIndex];
107107

108+
if ($nextEndToken->equals('(')) {
109+
return false;
110+
}
111+
108112
if ($this->isForbiddenBeforeOpenParenthesis($tokens, $prevStartIndex)) {
109113
return false;
110114
}

tests/Fixer/NoUselessParenthesisFixerTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ public function createStatic() {
8080
return new static([1, 2]);
8181
}
8282
}'];
83+
yield ['<?php return ($function)(42);'];
84+
yield ['<?php return ($this->function)(42);'];
85+
yield ['<?php return ($this->getFunction())(42);'];
8386

8487
yield [
8588
'<?php return $bar;',

0 commit comments

Comments
 (0)