-
-
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
1eaf5e0
commit cae6644
Showing
4 changed files
with
82 additions
and
1 deletion.
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,28 @@ | ||
<?php | ||
|
||
namespace test\PhpStaticAnalysis\NodeVisitor; | ||
|
||
use PhpParser\Node; | ||
use PhpParser\Node\Attribute; | ||
use PhpParser\Node\AttributeGroup; | ||
use PhpParser\Node\Name\FullyQualified; | ||
use PhpStaticAnalysis\Attributes\Impure; | ||
|
||
class ImpureAttributeNodeVisitorTest extends AttributeNodeVisitorTestBase | ||
{ | ||
public function testAddsImpurePHPDoc(): void | ||
{ | ||
$node = new Node\Stmt\ClassMethod('Test'); | ||
$this->addImpureAttributeToNode($node); | ||
$this->nodeVisitor->enterNode($node); | ||
$docText = $this->getDocText($node); | ||
$this->assertEquals("/**\n * @impure\n */", $docText); | ||
} | ||
|
||
private function addImpureAttributeToNode(Node\Stmt\ClassMethod $node): void | ||
{ | ||
$attributeName = new FullyQualified(Impure::class); | ||
$attribute = new Attribute($attributeName); | ||
$node->attrGroups = [new AttributeGroup([$attribute])]; | ||
} | ||
} |
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\NodeVisitor; | ||
|
||
use PhpParser\Node; | ||
use PhpParser\Node\Attribute; | ||
use PhpParser\Node\AttributeGroup; | ||
use PhpParser\Node\Name\FullyQualified; | ||
use PhpStaticAnalysis\Attributes\Pure; | ||
|
||
class PureAttributeNodeVisitorTest extends AttributeNodeVisitorTestBase | ||
{ | ||
public function testAddsPurePHPDoc(): void | ||
{ | ||
$node = new Node\Stmt\ClassMethod('Test'); | ||
$this->addPureAttributeToNode($node); | ||
$this->nodeVisitor->enterNode($node); | ||
$docText = $this->getDocText($node); | ||
$this->assertEquals("/**\n * @pure\n */", $docText); | ||
} | ||
|
||
private function addPureAttributeToNode(Node\Stmt\ClassMethod $node): void | ||
{ | ||
$attributeName = new FullyQualified(Pure::class); | ||
$attribute = new Attribute($attributeName); | ||
$node->attrGroups = [new AttributeGroup([$attribute])]; | ||
} | ||
} |