Skip to content

Commit

Permalink
Enable AllowDynamicProperties for the LazyAdvisorAccessor to avoid de…
Browse files Browse the repository at this point in the history
…precation notices for PHP8.2
  • Loading branch information
lisachenko committed Feb 18, 2024
1 parent 8b0786e commit f75614d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Core/LazyAdvisorAccessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@

namespace Go\Core;

use AllowDynamicProperties;
use Go\Aop\Advice;
use Go\Aop\Advisor;
use InvalidArgumentException;

/**
* Provides an interface for loading of advisors from the container
*/
#[AllowDynamicProperties]
class LazyAdvisorAccessor
{
/**
Expand Down Expand Up @@ -47,16 +49,14 @@ public function __construct(AspectContainer $container, AspectLoader $loader)
*/
public function __get(string $name): Advice
{
if ($this->container->has($name)) {
$advisor = $this->container->get($name);
} else {
if (!$this->container->has($name)) {
list(, $advisorName) = explode('.', $name);
list($aspect) = explode('->', $advisorName);
$aspectInstance = $this->container->getAspect($aspect);
list($aspect) = explode('->', $advisorName);
$aspectInstance = $this->container->getAspect($aspect);
$this->loader->loadAndRegister($aspectInstance);

$advisor = $this->container->get($name);
}
$advisor = $this->container->get($name);

if (!$advisor instanceof Advisor) {
throw new InvalidArgumentException("Reference {$name} is not an advisor");
Expand Down

0 comments on commit f75614d

Please sign in to comment.