-
-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
282 discover all nested objects #287
282 discover all nested objects #287
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #287 +/- ##
============================================
+ Coverage 76.15% 80.93% +4.77%
+ Complexity 586 525 -61
============================================
Files 48 45 -3
Lines 2034 1783 -251
============================================
- Hits 1549 1443 -106
+ Misses 485 340 -145 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yet another test:
public function testAsJsonObjectsMapWithNestedObject(): void
{
$nested = new stdClass();
$nested->name = 'nested';
$nestedId = spl_object_id($nested);
$object = new stdClass();
$object->name = 'root';
$object->var = $nested;
$objectId = spl_object_id($object);
$this->assertSame(
<<<JSON
{
"stdClass#$objectId": {
"public \$name": "root",
"public \$var": "stdClass#$nestedId (...)"
}
}
JSON,
Dumper::create($object)->asJsonObjectsMap(1, true)
);
}
Both objects must be present in the expected result. |
No. Depth is 1, so second object don't must be in result. |
It's a trap. |
Explanaition of In this PR, the So this condition in the Additional calls of the |
Proposal for
But in the
The proposal is to skip
|
Can we make it in separate PR? |
Is it good to go? |
After discussion with @olegbaturin, we have suggestion.
@xepozz WDYT? |
Why? |
I don't mind if the name changed |
It's for your evaluation. If orphan lines for closures |
Variant 1. Consistent to to Level 0: "array (1 item) [...]" Level 1: {
"stdClass#2512": "stdClass#2512 (...)"
} Level 2: {
"stdClass#2512": {
"public $name": "nested1",
"public $var": "array (1 item) [...]"
}
} Variant 2. Based on object level. Level 0: {
"stdClass#2512": "stdClass#2512 (...)"
} Level 1: {
"stdClass#2512": {
"public $name": "nested1",
"public $var": "array (2 items) [...]"
}
} Level 2: {
"stdClass#2512": {
"public $name": "nested1",
"public $var": [
"test",
"array (2 items) [...]"
]
}
} Variant 3. Based on arrays. Level 0: {
"stdClass#2512": {
"public $name": "nested1",
"public $var": "array (1 item) [...]"
}
} Level 1: {
"stdClass#2512": {
"public $name": "nested1",
"public $var": [
"test",
"array (2 items) [...]"
]
}
} Level 2: {
"stdClass#2512": {
"public $name": "nested1",
"public $var": [
"test",
[
"hello",
"world"
]
]
}
} Does a result of {
"stdClass#2512": "stdClass#2512 (...)"
} ? If no, we can use "Variant 3. Based on arrays." or "Variant 1. Consistent to to |
#282
#286
buildObjectsCache()
to discover all nested objects only if required.4.1 Update
dumpNestedInternal()
to stop traverse deeper if object is not found in the cache. This prevents possible errors in the future.4.2 Fix
dumpNestedInternal()
to not stop dumping objects on the level 2*$depth.