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
1a546ac
commit 1aad2a8
Showing
10 changed files
with
175 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,62 @@ | ||
<?php | ||
|
||
namespace test\PhpStaticAnalysis\PsalmPlugin; | ||
|
||
class DeprecatedAttributeTest extends BaseAttributeTestCase | ||
{ | ||
public function testClassDeprecatedAttribute(): void | ||
{ | ||
$errors = $this->analyzeTestFile( '/data/Deprecated/ClassDeprecatedAttribute.php'); | ||
$expectedErrors = [ | ||
'test\PhpStaticAnalysis\PsalmPlugin\data\Deprecated\ClassDeprecatedAttribute is marked deprecated' => 12, | ||
]; | ||
|
||
$this->checkExpectedErrors($errors, $expectedErrors); | ||
} | ||
|
||
public function testTraitDeprecatedAttribute(): void | ||
{ | ||
$errors = $this->analyzeTestFile( '/data/Deprecated/TraitDeprecatedAttribute.php'); | ||
$this->assertCount(0, $errors); | ||
} | ||
|
||
public function testInterfaceDeprecatedAttribute(): void | ||
{ | ||
$errors = $this->analyzeTestFile('/data/Deprecated/InterfaceDeprecatedAttribute.php'); | ||
$this->assertCount(0, $errors); | ||
} | ||
|
||
public function testMethodDeprecatedAttribute(): void | ||
{ | ||
$errors = $this->analyzeTestFile('/data/Deprecated/MethodDeprecatedAttribute.php'); | ||
$expectedErrors = [ | ||
'The method test\PhpStaticAnalysis\PsalmPlugin\data\Deprecated\MethodDeprecatedAttribute::returnDeprecated has been marked as deprecated' => 31, | ||
]; | ||
|
||
$this->checkExpectedErrors($errors, $expectedErrors); | ||
} | ||
|
||
public function testFunctionDeprecatedAttribute(): void | ||
{ | ||
$errors = $this->analyzeTestFile('/data/Deprecated/FunctionDeprecatedAttribute.php'); | ||
$this->assertCount(0, $errors); | ||
} | ||
|
||
public function testProperyDeprecatedAttribute(): void | ||
{ | ||
$errors = $this->analyzeTestFile('/data/Deprecated/PropertyDeprecatedAttribute.php'); | ||
$this->assertCount(0, $errors); | ||
} | ||
|
||
public function testInvalidMethodDeprecatedAttribute(): void | ||
{ | ||
$errors = $this->analyzeTestFile('/data/Deprecated/InvalidMethodDeprecatedAttribute.php'); | ||
|
||
$expectedErrors = [ | ||
'Attribute Deprecated cannot be used on a function/method parameter' => 12, | ||
'Attribute Deprecated is not repeatable' => 19, | ||
]; | ||
|
||
$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,12 @@ | ||
<?php | ||
|
||
namespace test\PhpStaticAnalysis\PsalmPlugin\data\Deprecated; | ||
|
||
use PhpStaticAnalysis\Attributes\Deprecated; | ||
|
||
#[Deprecated] // Use NotDeprecatedClassInstead | ||
class ClassDeprecatedAttribute | ||
{ | ||
} | ||
|
||
$class = new ClassDeprecatedAttribute(); |
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\Deprecated; | ||
|
||
#[Deprecated] | ||
function returnDeprecated(): 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\Deprecated; | ||
|
||
use PhpStaticAnalysis\Attributes\Deprecated; | ||
|
||
#[Deprecated] | ||
interface InterfaceDeprecatedAttribute | ||
{ | ||
} |
23 changes: 23 additions & 0 deletions
23
tests/data/Deprecated/InvalidMethodDeprecatedAttribute.php
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,23 @@ | ||
<?php | ||
|
||
namespace test\PhpStaticAnalysis\PsalmPlugin\data\Deprecated; | ||
|
||
use PhpStaticAnalysis\Attributes\Deprecated; | ||
use PhpStaticAnalysis\Attributes\Param; | ||
use PhpStaticAnalysis\Attributes\Returns; | ||
|
||
class InvalidMethodDeprecatedAttribute | ||
{ | ||
public function getName( | ||
#[Deprecated] | ||
string $name | ||
): string { | ||
return $name; | ||
} | ||
|
||
#[Deprecated] | ||
#[Deprecated] | ||
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\Deprecated; | ||
|
||
use PhpStaticAnalysis\Attributes\Deprecated; | ||
|
||
class MethodDeprecatedAttribute | ||
{ | ||
#[Deprecated] | ||
public function returnDeprecated(): void | ||
{ | ||
} | ||
|
||
/** | ||
* @codeCoverageIgnore | ||
*/ | ||
#[Deprecated] | ||
public function returnAnotherDeprecated(): void | ||
{ | ||
} | ||
|
||
/** | ||
* @deprecated | ||
*/ | ||
public function returnMoreDeprecateds(): void | ||
{ | ||
} | ||
} | ||
|
||
$class = new MethodDeprecatedAttribute(); | ||
$class->returnDeprecated(); |
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\Deprecated; | ||
|
||
use PhpStaticAnalysis\Attributes\Deprecated; | ||
|
||
class PropertyDeprecatedAttribute | ||
{ | ||
#[Deprecated] | ||
public const NAME = 'name'; | ||
|
||
#[Deprecated] | ||
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\Deprecated; | ||
|
||
use PhpStaticAnalysis\Attributes\Deprecated; | ||
|
||
#[Deprecated] | ||
trait TraitDeprecatedAttribute | ||
{ | ||
} |