From 512b448a09d9f57a2cc1939cbbcb67e07aea0122 Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Tue, 27 Aug 2024 03:10:24 +0900 Subject: [PATCH] Refactor AopPostfixClassName to include classDir Updated the AopPostfixClassName constructor to accept an additional classDir parameter, influencing the postfix generation process. Corresponding changes were made in Compiler and Weaver to pass this new parameter correctly. --- src/AopPostfixClassName.php | 4 ++-- src/Compiler.php | 2 +- src/Weaver.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/AopPostfixClassName.php b/src/AopPostfixClassName.php index a05c0f3f..3d332284 100644 --- a/src/AopPostfixClassName.php +++ b/src/AopPostfixClassName.php @@ -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; } } diff --git a/src/Compiler.php b/src/Compiler.php index 2cd72cb5..bb8b521f 100644 --- a/src/Compiler.php +++ b/src/Compiler.php @@ -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; } diff --git a/src/Weaver.php b/src/Weaver.php index 546de004..bf5c769c 100644 --- a/src/Weaver.php +++ b/src/Weaver.php @@ -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; }