From b8c26357e0577d1d7214ce5a15e6395556b126fc Mon Sep 17 00:00:00 2001 From: ywisax Date: Wed, 15 May 2024 17:07:08 +0800 Subject: [PATCH] Cast object to string with object hash In general php exception backtrack print, it will cast object to string like `Object(App\Entity\User)`. If someone wants to manage huge of objects(like doctrone/orm entity manager), it will be helpful to print with the object hash like `Object(App\Entity\User@00000000000000020000000000000000)` --- src/helpers/Represent.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers/Represent.php b/src/helpers/Represent.php index 1194ff9..f449c8d 100644 --- a/src/helpers/Represent.php +++ b/src/helpers/Represent.php @@ -21,7 +21,7 @@ public static function arg(mixed $value): string 'NULL' => 'NULL', 'boolean' => $value ? 'true' : 'false', 'array' => 'Array', - 'object' => 'Object(' . get_class($value) . ')', + 'object' => 'Object(' . get_class($value) . '@' . spl_object_hash($value) .')', 'string' => "'" . self::cutString((string)$value) . "'", default => (string)$value, };