Skip to content

Commit

Permalink
Update DefinedTargetClass.php
Browse files Browse the repository at this point in the history
Signed-off-by: Nathanael Esayeas <nathanael.esayeas@protonmail.com>
  • Loading branch information
ghostwriter committed Apr 23, 2023
1 parent b64176d commit e0ecc27
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions library/Mockery/Generator/DefinedTargetClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,25 @@
namespace Mockery\Generator;

use ReflectionAttribute;
use ReflectionClass;
use function array_map;
use function array_unique;
use const PHP_VERSION_ID;

class DefinedTargetClass implements TargetClassInterface
{
private $rfc;
private $name;

public function __construct(\ReflectionClass $rfc, $alias = null)
public function __construct(ReflectionClass $rfc, $alias = null)
{
$this->rfc = $rfc;
$this->name = $alias === null ? $rfc->getName() : $alias;
}

public static function factory($name, $alias = null)
{
return new self(new \ReflectionClass($name), $alias);
return new self(new ReflectionClass($name), $alias);
}

public function getAttributes()
Expand All @@ -44,10 +48,10 @@ public function getAttributes()
return [];
}

return array_map(
return array_unique(['AllowDynamicProperties', ...array_map(
static fn (ReflectionAttribute $attribute): string => $attribute->getName(),
$this->rfc->getAttributes()
);
)]);
}

public function getName()
Expand Down

0 comments on commit e0ecc27

Please sign in to comment.