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
d726548
commit 4c9f253
Showing
6 changed files
with
115 additions
and
22 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,30 @@ | ||
<?php | ||
|
||
namespace test\PhpStaticAnalysis\PsalmPlugin; | ||
|
||
class PureAttributeTest extends BaseAttributeTestCase | ||
{ | ||
public function testMethodPureAttribute(): void | ||
{ | ||
$errors = $this->analyzeTestFile('/data/Pure/MethodPureAttribute.php'); | ||
$this->assertCount(0, $errors); | ||
} | ||
|
||
public function testFunctionPureAttribute(): void | ||
{ | ||
$errors = $this->analyzeTestFile('/data/Pure/FunctionPureAttribute.php'); | ||
$this->assertCount(0, $errors); | ||
} | ||
|
||
public function testInvalidMethodPureAttribute(): void | ||
{ | ||
$errors = $this->analyzeTestFile('/data/Pure/InvalidMethodPureAttribute.php'); | ||
|
||
$expectedErrors = [ | ||
'Attribute Pure is not repeatable' => 15, | ||
'Attribute Pure cannot be used on a property' => 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,11 @@ | ||
<?php | ||
|
||
namespace test\PhpStaticAnalysis\PsalmPlugin\data; | ||
|
||
use PhpStaticAnalysis\Attributes\Pure; | ||
|
||
#[Pure] | ||
function add(int $left, int $right): int | ||
{ | ||
return $left + $right; | ||
} |
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,19 @@ | ||
<?php | ||
|
||
namespace test\PhpStaticAnalysis\PsalmPlugin\data\Pure; | ||
|
||
use PhpStaticAnalysis\Attributes\Param; | ||
use PhpStaticAnalysis\Attributes\Pure; | ||
use PhpStaticAnalysis\Attributes\Returns; | ||
|
||
class InvalidMethodPureAttribute | ||
{ | ||
#[Pure] | ||
public string $name = ''; | ||
|
||
#[Pure] | ||
#[Pure] | ||
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,31 @@ | ||
<?php | ||
|
||
namespace test\PhpStaticAnalysis\PsalmPlugin\data\Pure; | ||
|
||
use PhpStaticAnalysis\Attributes\Pure; | ||
|
||
class MethodPureAttribute | ||
{ | ||
#[Pure] | ||
public function add(int $left, int $right): int | ||
{ | ||
return $left + $right; | ||
} | ||
|
||
/** | ||
* @codeCoverageIgnore | ||
*/ | ||
#[Pure] | ||
public function addAnother(int $left, int $right): int | ||
{ | ||
return $left + $right; | ||
} | ||
|
||
/** | ||
* @pure | ||
*/ | ||
public function addMore(int $left, int $right): int | ||
{ | ||
return $left + $right; | ||
} | ||
} |