Skip to content

Commit

Permalink
Fix #909 - support private trait aliasing
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Jan 13, 2019
1 parent 7e0928d commit 6d462fc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Psalm/Internal/Visitor/ReflectorVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,10 @@ public function enterNode(PhpParser\Node $node)
case 2:
$visibility_map[$new_name] = ClassLikeAnalyzer::VISIBILITY_PROTECTED;
break;

case 4:
$visibility_map[$new_name] = ClassLikeAnalyzer::VISIBILITY_PRIVATE;
break;
}
}
}
Expand Down
25 changes: 25 additions & 0 deletions tests/TraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,31 @@ protected function foo(string $s) : void {}
}',
'error_message' => 'TooFewArguments',
],
'traitMethodMadePrivate' => [
'<?php
trait T {
public function foo() : void {
echo "here";
}
}
class C {
use T {
foo as private traitFoo;
}
public function bar() : void {
$this->traitFoo();
}
}
class D extends C {
public function bar() : void {
$this->traitFoo(); // should fail
}
}',
'error_message' => 'InaccessibleMethod'
],
];
}
}

0 comments on commit 6d462fc

Please sign in to comment.