Skip to content

Commit

Permalink
Update method and dependency management
Browse files Browse the repository at this point in the history
Refactor `generateParameterCode` to handle attributes irrespective of PHP version. Update composer dependencies to the latest versions for improved compatibility and security.
  • Loading branch information
koriym committed Nov 15, 2024
1 parent 7f1328f commit 1c78735
Show file tree
Hide file tree
Showing 4 changed files with 408 additions and 246 deletions.
6 changes: 1 addition & 5 deletions src/MethodSignatureString.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,7 @@ private function formatArg($name, $value): string
private function generateParameterCode(ReflectionParameter $param): string
{
// Support attributes
$attributesStr = '';
if (PHP_MAJOR_VERSION >= 8) {
$attributesStr = $this->getAttributeStr($param);
}

$attributesStr = $this->getAttributeStr($param);
$typeStr = ($this->typeString)($param->getType());
$typeStrWithSpace = $typeStr ? $typeStr . ' ' : $typeStr;
$variadicStr = $param->isVariadic() ? '...' : '';
Expand Down
2 changes: 1 addition & 1 deletion tests/AopCodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function method22()', $code);
public function method23()', $code);
$this->assertStringContainsString('#[\\Ray\\Aop\\Annotation\\FakeMarker6(fruit1: \\Ray\\Aop\\FakePhp81Enum::Apple, fruit2: \\Ray\\Aop\\FakePhp81Enum::Orange)]
public function method24()', $code);
$this->assertStringContainsString('public function method25(#[Ray\Aop\Attribute\FakeAttr1] $a, #[Ray\Aop\FakeAttri1] #[Ray\Aop\FakeAttr2] $b): void', $code);
$this->assertStringContainsString('public function method25(#[Ray\Aop\Attribute\FakeAttr1] $a, #[Ray\Aop\Attribute\FakeAttr1] #[Ray\Aop\Attribute\FakeAttr2] $b): void', $code);
}

/** @requires PHP 8.2 */
Expand Down
3 changes: 2 additions & 1 deletion tests/Fake/FakePhp8Types.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Ray\Aop\Annotation\FakeMarker6;
use Ray\Aop\Annotation\FakeMarkerName;
use Ray\Aop\Attribute\FakeAttr1;
use Ray\Aop\Attribute\FakeAttr2;

class FakePhp8Types implements FakeNullInterface, \Ray\Aop\FakeNullInterface1
{
Expand Down Expand Up @@ -75,7 +76,7 @@ public function method24() {}
public function method25(
#[FakeAttr1]
$a,
#[FakeAttri1, FakeAttr2]
#[FakeAttr1, FakeAttr2]
$b
): void {}
}
Loading

0 comments on commit 1c78735

Please sign in to comment.