Skip to content

Commit c07799f

Browse files
authored
Merge pull request #80 from rosier/patch-1
Use spl_object_id() instead of spl_object_hash()
2 parents c0abeee + aa6493d commit c07799f

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/EventManager.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Doctrine\Common;
66

7-
use function spl_object_hash;
7+
use function spl_object_id;
88

99
/**
1010
* The EventManager is the central point of Doctrine's event listener system.
@@ -60,23 +60,23 @@ public function hasListeners(string $event): bool
6060
public function addEventListener(string|array $events, object $listener): void
6161
{
6262
// Picks the hash code related to that listener
63-
$hash = spl_object_hash($listener);
63+
$oid = spl_object_id($listener);
6464

6565
foreach ((array) $events as $event) {
6666
// Overrides listener if a previous one was associated already
6767
// Prevents duplicate listeners on same event (same instance only)
68-
$this->listeners[$event][$hash] = $listener;
68+
$this->listeners[$event][$oid] = $listener;
6969
}
7070
}
7171

7272
/** {@inheritDoc} */
7373
public function removeEventListener(string|array $events, object $listener): void
7474
{
7575
// Picks the hash code related to that listener
76-
$hash = spl_object_hash($listener);
76+
$oid = spl_object_id($listener);
7777

7878
foreach ((array) $events as $event) {
79-
unset($this->listeners[$event][$hash]);
79+
unset($this->listeners[$event][$oid]);
8080
}
8181
}
8282

0 commit comments

Comments
 (0)