spl_object_hash
laravel/framework
Supported Versions: PHP 5 >= 5.2.0, PHP 7, PHP 8
Return hash id for given object
spl_object_hash
(
object $object
):
string
if (
is_string
(
$scope
) && (
$implementation
instanceof
Closure
||
$implementation
instanceof
Scope
)) {
return static::
$globalScopes
[static::class][
$scope
] =
$implementation
;
} elseif (
$scope
instanceof
Closure
) {
return static::
$globalScopes
[static::class][
spl_object_hash
(
$scope
)] =
$scope
;
} elseif (
$scope
instanceof
Scope
) {
return static::
$globalScopes
[static::class][
get_class
(
$scope
)] =
$scope
;
}
src/Illuminate/Database/Eloquent/Concerns/HasGlobalScopes.php
$duplicateFooInstance
=
$manager
->
instance
(
'foo'
);
$duplicateBarInstance
=
$manager
->
instance
(
'bar'
);
$this
->
assertEquals
(
spl_object_hash
(
$fooInstance
),
spl_object_hash
(
$duplicateFooInstance
));
$this
->
assertEquals
(
spl_object_hash
(
$barInstance
),
spl_object_hash
(
$duplicateBarInstance
));
}
tests/Integration/Support/MultipleInstanceManagerTest.php
$duplicateFooInstance
=
$manager
->
instance
(
'foo'
);
$duplicateBarInstance
=
$manager
->
instance
(
'bar'
);
$this
->
assertEquals
(
spl_object_hash
(
$fooInstance
),
spl_object_hash
(
$duplicateFooInstance
));
$this
->
assertEquals
(
spl_object_hash
(
$barInstance
),
spl_object_hash
(
$duplicateBarInstance
));
}
public function
test_unresolvable_isntances_throw_errors
()
tests/Integration/Support/MultipleInstanceManagerTest.php
});
$result
=
$resolver
->
resolve
(
'foo'
);
$this
->
assertEquals
(
spl_object_hash
(
$result
),
spl_object_hash
(
$resolver
->
resolve
(
'foo'
)));
}
public function
testResolverThrowsExceptionOnUnknownEngine
()
tests/View/ViewEngineResolverTest.php