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
29f1cbc
commit 833e1b2
Showing
5 changed files
with
96 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace test\PhpStaticAnalysis\PsalmPlugin; | ||
|
||
class SelfOutAttributeTest extends BaseAttributeTestCase | ||
{ | ||
public function testMethodSelfOutAttribute(): void | ||
{ | ||
$errors = $this->analyzeTestFile('/data/SelfOut/MethodSelfOutAttribute.php'); | ||
$this->assertCount(0, $errors); | ||
} | ||
|
||
public function testInvalidMethodSelfOutAttribute(): void | ||
{ | ||
$errors = $this->analyzeTestFile('/data/SelfOut/InvalidMethodSelfOutAttribute.php'); | ||
|
||
$expectedErrors = [ | ||
'Attribute SelfOut is not repeatable' => 15, | ||
'Attribute SelfOut cannot be used on a property' => 20, | ||
]; | ||
|
||
$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,22 @@ | ||
<?php | ||
|
||
namespace test\PhpStaticAnalysis\PsalmPlugin\data\SelfOut; | ||
|
||
use PhpStaticAnalysis\Attributes\Param; | ||
use PhpStaticAnalysis\Attributes\SelfOut; | ||
use PhpStaticAnalysis\Attributes\Template; | ||
|
||
#[Template('TValue')] | ||
class InvalidMethodSelfOutAttribute | ||
{ | ||
#[Template('TItemValue')] | ||
#[Param(item: 'TItemValue')] | ||
#[SelfOut('self<TValue|TItemValue>')] | ||
#[SelfOut('self<TValue|TItemValue>')] | ||
public function addMore($item): void | ||
{ | ||
} | ||
|
||
#[SelfOut('self<TValue|TItemValue>')] | ||
public string $property = ''; | ||
} |
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,47 @@ | ||
<?php | ||
|
||
namespace test\PhpStaticAnalysis\PsalmPlugin\data\SelfOut; | ||
|
||
use PhpStaticAnalysis\Attributes\Param; | ||
use PhpStaticAnalysis\Attributes\SelfOut; | ||
use PhpStaticAnalysis\Attributes\Template; | ||
|
||
#[Template('TValue')] | ||
class MethodSelfOutAttribute | ||
{ | ||
#[Template('TItemValue')] | ||
#[Param(item: 'TItemValue')] | ||
#[SelfOut('self<TValue|TItemValue>')] // we specify the new type | ||
public function add($item): void | ||
{ | ||
} | ||
|
||
/** | ||
* @deprecated | ||
*/ | ||
#[Template('TItemValue')] | ||
#[Param(item: 'TItemValue')] | ||
#[SelfOut('self<TValue|TItemValue>')] | ||
public function addMore($item): void | ||
{ | ||
} | ||
|
||
/** | ||
* @self-out self<TValue> | ||
*/ | ||
#[Template('TItemValue')] | ||
#[Param(item: 'TItemValue')] | ||
#[SelfOut('self<TValue|TItemValue>')] | ||
public function addEvenMore($item): void | ||
{ | ||
} | ||
|
||
/** | ||
* @self-out self<TValue|TItemValue> | ||
*/ | ||
#[Template('TItemValue')] | ||
#[Param(item: 'TItemValue')] | ||
public function addMoreAndMore($item): void | ||
{ | ||
} | ||
} |