Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Feb 2, 2024
1 parent 64034b7 commit 5062543
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/ReflectionAttributesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,29 @@ class ReflectionAttributesTest extends TestCase
*/
protected $parsedRefFile;

public function testGetAttributeOnFunction()
{
$this->setUpFile(__DIR__ . '/Stub/FileWithFunction80.php');

$fileNamespace = $this->parsedRefFile->getFileNamespace('Go\ParserReflection\Stub');
$function = $fileNamespace->getFunction('function_with_attribute');
$attributes = $function->getAttributes();

$originalReflection = new \ReflectionFunction('Go\ParserReflection\Stub\function_with_attribute');

foreach ($attributes as $attribute) {
$originalAttribute = current($originalReflection->getAttributes($attribute->getName()));

$this->assertInstanceOf(ReflectionAttribute::class, $attribute);
$this->assertSame($originalAttribute->getName(), $attribute->getName());
$this->assertSame($originalAttribute->getName(), $attribute->getName());
$this->assertSame($originalAttribute->getTarget(), $attribute->getTarget());
$this->assertSame($originalAttribute->getTarget(), $attribute->getTarget());
$this->assertSame($originalAttribute->getArguments(), $attribute->getArguments());
$this->assertSame($originalAttribute->isRepeated(), $attribute->isRepeated());
}
}

public function testGetAttributeOnParameters()
{
$this->setUpFile(__DIR__ . '/Stub/FileWithParameters80.php');
Expand Down
17 changes: 17 additions & 0 deletions tests/Stub/FileWithFunction80.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
declare(strict_types=1);
/**
* Parser Reflection API
*
* @copyright Copyright 2015, Lisachenko Alexander <[email protected]>
*
* This source file is subject to the license that is bundled
* with this source code in the file LICENSE.
*/

namespace Go\ParserReflection\Stub;

#[SomeAttribute]
function function_with_attribute()
{
}

0 comments on commit 5062543

Please sign in to comment.