Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/SourceLocator/Type/MemoizingSourceLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Roave\BetterReflection\Reflector\Reflector;

use function array_key_exists;
use function spl_object_hash;
use function spl_object_id;
use function sprintf;

final class MemoizingSourceLocator implements SourceLocator
Expand Down Expand Up @@ -52,7 +52,7 @@ public function locateIdentifiersByType(Reflector $reflector, IdentifierType $id

private function reflectorCacheKey(Reflector $reflector): string
{
return sprintf('type:%s#oid:%s', $reflector::class, spl_object_hash($reflector));
return sprintf('type:%s#oid:%d', $reflector::class, spl_object_id($reflector));
}

private function identifierToCacheKey(Identifier $identifier): string
Expand Down
4 changes: 2 additions & 2 deletions test/unit/SourceLocator/Ast/Parser/MemoizingParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use function array_unique;
use function count;
use function range;
use function spl_object_hash;
use function spl_object_id;
use function uniqid;

#[CoversClass(MemoizingParser::class)]
Expand Down Expand Up @@ -50,7 +50,7 @@ public function testParse(): void
}

$nodeIdentifiers = array_map(
static fn (array $nodes): string => spl_object_hash($nodes[0]),
static fn (array $nodes): int => spl_object_id($nodes[0]),
$producedNodes,
);

Expand Down
8 changes: 4 additions & 4 deletions test/unit/SourceLocator/Type/MemoizingSourceLocatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
use function in_array;
use function random_int;
use function range;
use function spl_object_hash;
use function spl_object_id;
use function uniqid;

#[CoversClass(MemoizingSourceLocator::class)]
Expand Down Expand Up @@ -189,8 +189,8 @@ private function assertMemoization(
) use (
&$fetchedSymbolsCount,
): Reflection|null {
$identifierId = spl_object_hash($identifier);
$reflectorId = spl_object_hash($reflector);
$identifierId = spl_object_id($identifier);
$reflectorId = spl_object_id($reflector);
$hash = $reflectorId . $identifierId;

$fetchedSymbolsCount[$hash] = ($fetchedSymbolsCount[$hash] ?? 0) + 1;
Expand All @@ -212,7 +212,7 @@ private function assertMemoization(

self::assertSame($memoizedSymbols, $cachedSymbols);

$memoizedSymbolsIds = array_map('spl_object_hash', array_filter($memoizedSymbols));
$memoizedSymbolsIds = array_map('spl_object_id', array_filter($memoizedSymbols));
self::assertCount(count($memoizedSymbolsIds), array_unique($memoizedSymbolsIds), 'No duplicate symbols');
}

Expand Down