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
a686670
commit 1a0052e
Showing
7 changed files
with
120 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,37 @@ | ||
<?php | ||
|
||
namespace test\PhpStaticAnalysis\PsalmPlugin; | ||
|
||
class MixinAttributeTest extends BaseAttributeTestCase | ||
{ | ||
public function testClassMixinAttribute(): void | ||
{ | ||
$errors = $this->analyzeTestFile( '/data/Mixin/ClassMixinAttribute.php'); | ||
$this->assertCount(0, $errors); | ||
} | ||
|
||
public function testInterfaceMixinAttribute(): void | ||
{ | ||
$errors = $this->analyzeTestFile( '/data/Mixin/InterfaceMixinAttribute.php'); | ||
$this->assertCount(0, $errors); | ||
} | ||
|
||
public function testTraitMixinAttribute(): void | ||
{ | ||
$errors = $this->analyzeTestFile( '/data/Mixin/TraitMixinAttribute.php'); | ||
$this->assertCount(0, $errors); | ||
} | ||
|
||
public function testInvalidClassMixinAttribute(): void | ||
{ | ||
$errors = $this->analyzeTestFile( '/data/Mixin/InvalidClassMixinAttribute.php'); | ||
|
||
$expectedErrors = [ | ||
'@mixin annotation used without specifying class in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\Mixin\InvalidClassMixinAttribute' => 9, | ||
'Argument 1 of PhpStaticAnalysis\Attributes\Mixin::__construct expects string, but 0 provided' => 7, | ||
'Attribute Mixin cannot be used on a method' => 11, | ||
]; | ||
|
||
$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,36 @@ | ||
<?php | ||
|
||
namespace test\PhpStaticAnalysis\PsalmPlugin\data\Mixin; | ||
|
||
use PhpStaticAnalysis\Attributes\Mixin; | ||
|
||
class ClassMixinAttribute | ||
{ | ||
public function proxied(): void | ||
{ | ||
} | ||
} | ||
|
||
class MyClass | ||
{ | ||
} | ||
|
||
class Another | ||
{ | ||
} | ||
|
||
#[Mixin('ClassMixinAttribute')] // this is the proxied class | ||
#[Mixin( | ||
'MyClass', | ||
'Another', | ||
)] | ||
class ClassMixinAttributeProxy | ||
{ | ||
public function __call(string $name, mixed ...$arguments): void | ||
{ | ||
(new ClassMixinAttribute())->$name(...$arguments); | ||
} | ||
} | ||
|
||
$proxy = new ClassMixinAttributeProxy(); | ||
$proxy->proxied(); |
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\Mixin; | ||
|
||
use PhpStaticAnalysis\Attributes\Mixin; | ||
|
||
#[Mixin('AClass')] | ||
interface InterfaceMixinAttribute | ||
{ | ||
} | ||
|
||
class AClass | ||
{ | ||
} |
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,16 @@ | ||
<?php | ||
|
||
namespace test\PhpStaticAnalysis\PsalmPlugin\data\Mixin; | ||
|
||
use PhpStaticAnalysis\Attributes\Mixin; | ||
|
||
#[Mixin(0)] | ||
#[Mixin('count($a)')] | ||
class InvalidClassMixinAttribute | ||
{ | ||
#[Mixin('A')] | ||
public function getName(): string | ||
{ | ||
return "John"; | ||
} | ||
} |
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\Mixin; | ||
|
||
use PhpStaticAnalysis\Attributes\Mixin; | ||
|
||
class Other | ||
{ | ||
} | ||
|
||
#[Mixin('Other')] | ||
trait TraitMixinAttribute | ||
{ | ||
} |