-
-
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
e2bcf3a
commit 493630e
Showing
11 changed files
with
194 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,54 @@ | ||
<?php | ||
|
||
namespace test\PhpStaticAnalysis\PHPStanExtension; | ||
|
||
class InternalAttributeTest extends BaseAttributeTestCase | ||
{ | ||
public function testClassInternalAttribute(): void | ||
{ | ||
$errors = $this->analyse(__DIR__ . '/data/Internal/ClassInternalAttribute.php'); | ||
$this->assertCount(0, $errors); | ||
} | ||
|
||
public function testTraitInternalAttribute(): void | ||
{ | ||
$errors = $this->analyse(__DIR__ . '/data/Internal/TraitInternalAttribute.php'); | ||
$this->assertCount(0, $errors); | ||
} | ||
|
||
public function testInterfaceInternalAttribute(): void | ||
{ | ||
$errors = $this->analyse(__DIR__ . '/data/Internal/InterfaceInternalAttribute.php'); | ||
$this->assertCount(0, $errors); | ||
} | ||
|
||
public function testMethodInternalAttribute(): void | ||
{ | ||
$errors = $this->analyse(__DIR__ . '/data/Internal/MethodInternalAttribute.php'); | ||
$this->assertCount(0, $errors); | ||
} | ||
|
||
public function testFunctionInternalAttribute(): void | ||
{ | ||
$errors = $this->analyse(__DIR__ . '/data/Internal/FunctionInternalAttribute.php'); | ||
$this->assertCount(0, $errors); | ||
} | ||
|
||
public function testProperyInternalAttribute(): void | ||
{ | ||
$errors = $this->analyse(__DIR__ . '/data/Internal/PropertyInternalAttribute.php'); | ||
$this->assertCount(0, $errors); | ||
} | ||
|
||
public function testInvalidMethodInternalAttribute(): void | ||
{ | ||
$errors = $this->analyse(__DIR__ . '/data/Internal/InvalidMethodInternalAttribute.php'); | ||
$expectedErrors = [ | ||
'Parameter #1 $namespace of attribute class PhpStaticAnalysis\Attributes\Internal constructor expects string|null, int given.' => 9, | ||
'Attribute class PhpStaticAnalysis\Attributes\Internal does not have the parameter target.' => 15, | ||
'Attribute class PhpStaticAnalysis\Attributes\Internal is not repeatable but is already present above the method.' => 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\PHPStanExtension\data\Internal; | ||
|
||
use PhpStaticAnalysis\Attributes\Internal; | ||
|
||
#[Internal('newNamespace\test')] // Can only be accessed from the current namespace | ||
class ClassInternalAttribute | ||
{ | ||
#[Internal] | ||
public function myFunction(): void | ||
{ | ||
} | ||
} | ||
|
||
namespace newNamespace\test; | ||
|
||
class newClass | ||
{ | ||
public function newFunction(): void | ||
{ | ||
$class = new \test\PhpStaticAnalysis\PHPStanExtension\data\Internal\ClassInternalAttribute(); | ||
|
||
$class->myFunction(); | ||
} | ||
} | ||
|
||
namespace newNamespace\other; | ||
|
||
class otherClass | ||
{ | ||
public function otherFunction(): void | ||
{ | ||
$class = new \test\PhpStaticAnalysis\PHPStanExtension\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\PHPStanExtension\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\PHPStanExtension\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\PHPStanExtension\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\PHPStanExtension\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\PHPStanExtension\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\PHPStanExtension\data\Internal; | ||
|
||
use PhpStaticAnalysis\Attributes\Internal; | ||
|
||
#[Internal] | ||
trait TraitInternalAttribute | ||
{ | ||
} |