Skip to content
Permalink
Browse files

Ignore protected properties redefined downstream

  • Loading branch information...
muglug committed Apr 17, 2019
1 parent 86c6b6f commit 1eabe6ed5559d6c51bfa55f9c1675b676ff89d54
Showing with 21 additions and 1 deletion.
  1. +4 −1 src/Psalm/Internal/Codebase/ClassLikes.php
  2. +17 −0 tests/UnusedCodeTest.php
@@ -976,7 +976,10 @@ private function checkPropertyReferences(ClassLikeStorage $classlike_storage)
// fall through
}
}
} elseif (!isset($classlike_storage->declaring_method_ids['__get'])) {
} elseif (!isset($classlike_storage->declaring_method_ids['__get'])
&& $property_storage->visibility === ClassLikeAnalyzer::VISIBILITY_PRIVATE
|| !isset($classlike_storage->overridden_property_ids[$property_name])
) {
$issue = new UnusedProperty(
'Property ' . $property_id . ' is never used',
$property_storage->location
@@ -370,6 +370,23 @@ function foo(A $a) : void {
foo(new B());',
],
'protectedPropertyOverriddenDownstream' => [
'<?php
class C {
/** @var int */
protected $foo = 1;
public function bar() : int {
return $this->foo;
}
}
class D extends C {
protected $foo = 2;
}
(new D)->bar();'
],
];
}

0 comments on commit 1eabe6e

Please sign in to comment.
You can’t perform that action at this time.