Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
phpunit-recursion-context
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Debian PHP Team
PEAR
phpunit-recursion-context
Commits
c04cec4d
Commit
c04cec4d
authored
1 year ago
by
Markus Staab
Committed by
Sebastian Bergmann
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Use more efficient `spl_object_id()` over `spl_object_hash()`
parent
396fdbbd
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Context.php
+5
-5
5 additions, 5 deletions
src/Context.php
tests/ContextTest.php
+5
-5
5 additions, 5 deletions
tests/ContextTest.php
with
10 additions
and
10 deletions
src/Context.php
+
5
−
5
View file @
c04cec4d
...
...
@@ -17,7 +17,7 @@ use function array_slice;
use
function
count
;
use
function
is_array
;
use
function
random_int
;
use
function
spl_object_
hash
;
use
function
spl_object_
id
;
use
SplObjectStorage
;
final
class
Context
...
...
@@ -114,13 +114,13 @@ final class Context
return
$key
;
}
private
function
addObject
(
object
$object
):
str
in
g
private
function
addObject
(
object
$object
):
in
t
{
if
(
!
$this
->
objects
->
contains
(
$object
))
{
$this
->
objects
->
attach
(
$object
);
}
return
spl_object_
hash
(
$object
);
return
spl_object_
id
(
$object
);
}
private
function
containsArray
(
array
$array
):
false
|
int
...
...
@@ -130,10 +130,10 @@ final class Context
return
isset
(
$end
[
1
])
&&
$end
[
1
]
===
$this
->
objects
?
$end
[
0
]
:
false
;
}
private
function
containsObject
(
object
$value
):
false
|
str
in
g
private
function
containsObject
(
object
$value
):
false
|
in
t
{
if
(
$this
->
objects
->
contains
(
$value
))
{
return
spl_object_
hash
(
$value
);
return
spl_object_
id
(
$value
);
}
return
false
;
...
...
This diff is collapsed.
Click to expand it.
tests/ContextTest.php
+
5
−
5
View file @
c04cec4d
...
...
@@ -10,7 +10,7 @@
namespace
SebastianBergmann\RecursionContext
;
use
const
PHP_INT_MAX
;
use
function
spl_object_
hash
;
use
function
spl_object_
id
;
use
PHPUnit\Framework\Attributes\CoversClass
;
use
PHPUnit\Framework\Attributes\DataProvider
;
use
PHPUnit\Framework\TestCase
;
...
...
@@ -49,10 +49,10 @@ final class ContextTest extends TestCase
$storage
->
attach
(
$obj2
);
return
[
[
$obj
,
spl_object_
hash
(
$obj
)],
[
$obj2
,
spl_object_
hash
(
$obj2
)],
[
$obj3
,
spl_object_
hash
(
$obj3
)],
[
$storage
,
spl_object_
hash
(
$storage
)],
[
$obj
,
spl_object_
id
(
$obj
)],
[
$obj2
,
spl_object_
id
(
$obj2
)],
[
$obj3
,
spl_object_
id
(
$obj3
)],
[
$storage
,
spl_object_
id
(
$storage
)],
[
$obj
->
array
,
0
],
[
$obj
->
array2
,
0
],
[
$obj
->
array3
,
0
],
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment