-
Notifications
You must be signed in to change notification settings - Fork 430
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement MethodVisibitiliyInInterfaceRule
- Loading branch information
Showing
7 changed files
with
66 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 0 additions & 27 deletions
27
tests/PHPStan/Rules/Methods/AbstractProtectedMethodRuleTest.php
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
tests/PHPStan/Rules/Methods/MethodVisibitiliyInInterfaceRuleTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\Rules\Methods; | ||
|
||
use PHPStan\Rules\Rule; | ||
use PHPStan\Testing\RuleTestCase; | ||
|
||
/** @extends RuleTestCase<MethodVisibitiliyInInterfaceRule> */ | ||
class MethodVisibitiliyInInterfaceRuleTest extends RuleTestCase | ||
{ | ||
|
||
protected function getRule(): Rule | ||
{ | ||
return new MethodVisibitiliyInInterfaceRule(); | ||
} | ||
|
||
public function testRule(): void | ||
{ | ||
$this->analyse([__DIR__ . '/data/visibility-in-interace.php'], [ | ||
[ | ||
'Method VisibilityInInterface\FooInterface::sayPrivate() cannot use non-public visibility in interface.', | ||
7, | ||
], | ||
[ | ||
'Method VisibilityInInterface\FooInterface::sayProtected() cannot use non-public visibility in interface.', | ||
8, | ||
], | ||
]); | ||
} | ||
|
||
} |
File renamed without changes.
30 changes: 30 additions & 0 deletions
30
tests/PHPStan/Rules/Methods/data/visibility-in-interace.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace VisibilityInInterface; | ||
|
||
interface FooInterface | ||
{ | ||
private function sayPrivate() : void; | ||
protected function sayProtected() : void; | ||
public function sayPublic() : void; | ||
|
||
function noVisibility() : void; | ||
} | ||
|
||
trait FooTrait | ||
{ | ||
private function sayPrivate() : void {} | ||
protected function sayProtected() : void {} | ||
public function sayPublic() : void {} | ||
|
||
function noVisibility() : void {} | ||
} | ||
|
||
abstract class AbstractFoo | ||
{ | ||
abstract private function sayPrivate() : void; | ||
abstract protected function sayProtected() : void; | ||
abstract public function sayPublic() : void; | ||
|
||
abstract function noVisibility() : void; | ||
} |