Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7233e84

Browse files
committed
ProtectedToPrivateFixer: minor optimization
1 parent 39a57b6 commit 7233e84

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

src/Fixer/ClassNotation/ProtectedToPrivateFixer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function getPriority()
6060
*/
6161
public function isCandidate(Tokens $tokens)
6262
{
63-
return $tokens->isTokenKindFound(T_CLASS);
63+
return $tokens->isAllTokenKindsFound([T_CLASS, T_FINAL, T_PROTECTED]);
6464
}
6565

6666
/**

tests/Fixer/ClassNotation/ProtectedToPrivateFixerTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ public function provideCases()
8484
"<?php final class MyFirstClass { $attributesAndMethodsFixed } class MySecondClass { $attributesAndMethodsOriginal } final class MyThirdClass { $attributesAndMethodsFixed } ",
8585
"<?php final class MyFirstClass { $attributesAndMethodsOriginal } class MySecondClass { $attributesAndMethodsOriginal } final class MyThirdClass { $attributesAndMethodsOriginal } ",
8686
],
87+
'minimal-set' => [
88+
'<?php final class MyClass { private $v1; }',
89+
'<?php final class MyClass { protected $v1; }',
90+
],
8791
];
8892
}
8993

0 commit comments

Comments
 (0)