From 378125cb5b1e44b7aa99d36e910568871c2045b1 Mon Sep 17 00:00:00 2001 From: Fred Emmott Date: Tue, 26 Sep 2017 11:10:09 -0700 Subject: [PATCH] Don't try to add <<__Override>> to private methods --- src/Linters/MustUseOverrideAttributeLinter.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Linters/MustUseOverrideAttributeLinter.php b/src/Linters/MustUseOverrideAttributeLinter.php index 5c451334d..46c94ef53 100644 --- a/src/Linters/MustUseOverrideAttributeLinter.php +++ b/src/Linters/MustUseOverrideAttributeLinter.php @@ -21,6 +21,7 @@ GenericTypeSpecifier, ListItem, MethodishDeclaration, + PrivateToken, SimpleTypeSpecifier }; use namespace Facebook\TypeAssert; @@ -124,6 +125,13 @@ private function canIgnoreMethod( return true; } + $private = $method->getModifiersx()->getDescendantsOfType( + PrivateToken::class, + ) |> C\first($$); + if ($private !== null) { + return true; + } + if (!$class->getKeyword() instanceof ClassToken) { return true; }