generated from psalm/psalm-plugin-skeleton
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1aad2a8
commit a686670
Showing
11 changed files
with
199 additions
and
3 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
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,59 @@ | ||
<?php | ||
|
||
namespace test\PhpStaticAnalysis\PsalmPlugin; | ||
|
||
class InternalAttributeTest extends BaseAttributeTestCase | ||
{ | ||
public function testClassInternalAttribute(): void | ||
{ | ||
$errors = $this->analyzeTestFile('/data/Internal/ClassInternalAttribute.php'); | ||
$expectedErrors = [ | ||
'test\PhpStaticAnalysis\PsalmPlugin\data\Internal\ClassInternalAttribute is internal to newNamespace\test but called from newNamespace\other\otherClass' => 34, | ||
'The method test\PhpStaticAnalysis\PsalmPlugin\data\Internal\ClassInternalAttribute::myFunction is internal to newNamespace\test and test but called from newNamespace\other\otherClass::otherFunction' => 36, | ||
]; | ||
$this->checkExpectedErrors($errors, $expectedErrors); | ||
} | ||
|
||
public function testTraitInternalAttribute(): void | ||
{ | ||
$errors = $this->analyzeTestFile('/data/Internal/TraitInternalAttribute.php'); | ||
$this->assertCount(0, $errors); | ||
} | ||
|
||
public function testInterfaceInternalAttribute(): void | ||
{ | ||
$errors = $this->analyzeTestFile('/data/Internal/InterfaceInternalAttribute.php'); | ||
$this->assertCount(0, $errors); | ||
} | ||
|
||
public function testMethodInternalAttribute(): void | ||
{ | ||
$errors = $this->analyzeTestFile('/data/Internal/MethodInternalAttribute.php'); | ||
$this->assertCount(0, $errors); | ||
} | ||
|
||
public function testFunctionInternalAttribute(): void | ||
{ | ||
$errors = $this->analyzeTestFile('/data/Internal/FunctionInternalAttribute.php'); | ||
$this->assertCount(0, $errors); | ||
} | ||
|
||
public function testProperyInternalAttribute(): void | ||
{ | ||
$errors = $this->analyzeTestFile('/data/Internal/PropertyInternalAttribute.php'); | ||
$this->assertCount(0, $errors); | ||
} | ||
|
||
public function testInvalidMethodInternalAttribute(): void | ||
{ | ||
$errors = $this->analyzeTestFile('/data/Internal/InvalidMethodInternalAttribute.php'); | ||
$expectedErrors = [ | ||
'psalm-internal annotation used without specifying namespace in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\Internal\InvalidMethodInternalAttribute::getName' => 9, | ||
'Argument 1 of PhpStaticAnalysis\Attributes\Internal::__construct expects null|string, but 0 provided' => 9, | ||
'Attribute Internal cannot be used on a function/method parameter' => 15, | ||
'Attribute Internal is not repeatable' => 22, | ||
]; | ||
|
||
$this->checkExpectedErrors($errors, $expectedErrors); | ||
} | ||
} |
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,38 @@ | ||
<?php | ||
|
||
namespace test\PhpStaticAnalysis\PsalmPlugin\data\Internal; | ||
|
||
use PhpStaticAnalysis\Attributes\Internal; | ||
|
||
#[Internal('newNamespace\test')] | ||
class ClassInternalAttribute | ||
{ | ||
#[Internal] // Can only be accessed from the current namespace | ||
public function myFunction(): void | ||
{ | ||
} | ||
} | ||
|
||
namespace newNamespace\test; | ||
|
||
class newClass | ||
{ | ||
public function newFunction(): void | ||
{ | ||
$class = new \test\PhpStaticAnalysis\PsalmPlugin\data\Internal\ClassInternalAttribute(); | ||
|
||
$class->myFunction(); | ||
} | ||
} | ||
|
||
namespace newNamespace\other; | ||
|
||
class otherClass | ||
{ | ||
public function otherFunction(): void | ||
{ | ||
$class = new \test\PhpStaticAnalysis\PsalmPlugin\data\Internal\ClassInternalAttribute(); | ||
|
||
$class->myFunction(); | ||
} | ||
} |
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,10 @@ | ||
<?php | ||
|
||
namespace test\PhpStaticAnalysis\PsalmPlugin\data; | ||
|
||
use PhpStaticAnalysis\Attributes\Internal; | ||
|
||
#[Internal] | ||
function returnInternal(): void | ||
{ | ||
} |
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,10 @@ | ||
<?php | ||
|
||
namespace test\PhpStaticAnalysis\PsalmPlugin\data\Internal; | ||
|
||
use PhpStaticAnalysis\Attributes\Internal; | ||
|
||
#[Internal] | ||
interface InterfaceInternalAttribute | ||
{ | ||
} |
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,26 @@ | ||
<?php | ||
|
||
namespace test\PhpStaticAnalysis\PsalmPlugin\data\Internal; | ||
|
||
use PhpStaticAnalysis\Attributes\Internal; | ||
|
||
class InvalidMethodInternalAttribute | ||
{ | ||
#[Internal(0)] | ||
public function getName(): void | ||
{ | ||
} | ||
|
||
public function getExtraName( | ||
#[Internal] | ||
string $name | ||
): string { | ||
return $name; | ||
} | ||
|
||
#[Internal] | ||
#[Internal] | ||
public function getMoreName(): void | ||
{ | ||
} | ||
} |
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,28 @@ | ||
<?php | ||
|
||
namespace test\PhpStaticAnalysis\PsalmPlugin\data\Internal; | ||
|
||
use PhpStaticAnalysis\Attributes\Internal; | ||
|
||
class MethodInternalAttribute | ||
{ | ||
#[Internal] | ||
public function returnInternal(): void | ||
{ | ||
} | ||
|
||
/** | ||
* @codeCoverageIgnore | ||
*/ | ||
#[Internal] | ||
public function returnAnotherInternal(): void | ||
{ | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
public function returnMoreInternals(): void | ||
{ | ||
} | ||
} |
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,14 @@ | ||
<?php | ||
|
||
namespace test\PhpStaticAnalysis\PsalmPlugin\data\Internal; | ||
|
||
use PhpStaticAnalysis\Attributes\Internal; | ||
|
||
class PropertyInternalAttribute | ||
{ | ||
#[Internal] | ||
public const NAME = 'name'; | ||
|
||
#[Internal] | ||
public string $name = ''; | ||
} |
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,10 @@ | ||
<?php | ||
|
||
namespace test\PhpStaticAnalysis\PsalmPlugin\data\Internal; | ||
|
||
use PhpStaticAnalysis\Attributes\Internal; | ||
|
||
#[Internal] | ||
trait TraitInternalAttribute | ||
{ | ||
} |