Skip to content

Commit

Permalink
Merge pull request #217 from ray-di/aop-class-name-with-class-dir
Browse files Browse the repository at this point in the history
Refactor AopPostfixClassName to include classDir
  • Loading branch information
koriym authored Aug 27, 2024
2 parents 166768c + 512b448 commit 1b2d410
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/AopPostfixClassName.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ final class AopPostfixClassName
public $postFix;

/** @param class-string $class */
public function __construct(string $class, string $bindings)
public function __construct(string $class, string $bindings, string $classDir)
{
$fileTime = (string) filemtime((string) (new ReflectionClass($class))->getFileName());
$this->postFix = '_' . crc32($fileTime . $bindings);
$this->postFix = '_' . crc32($fileTime . $bindings . $classDir);
$this->fqn = $class . $this->postFix;
}
}
2 changes: 1 addition & 1 deletion src/Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function compile(string $class, BindInterface $bind): string
return $class;
}

$className = new AopPostfixClassName($class, (string) $bind);
$className = new AopPostfixClassName($class, (string) $bind, $this->classDir);
if (class_exists($className->fqn, false)) {
return $className->fqn;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Weaver.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function newInstance(string $class, array $args): object
*/
public function weave(string $class): string
{
$aopClass = new AopPostfixClassName($class, $this->bindName);
$aopClass = new AopPostfixClassName($class, $this->bindName, $this->classDir);
if (class_exists($aopClass->fqn, false)) {
return $aopClass->fqn;
}
Expand Down

0 comments on commit 1b2d410

Please sign in to comment.