Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
Fix for #18843#18861
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Fix for #18843#18861
Uh oh!
There was an error while loading.Please reload this page.
Conversation
inso commentedMay 26, 2016
ping @symfony/deciders |
| */ | ||
| privatestaticfunctiondumpArray($value,$exceptionOnInvalidType,$objectSupport) | ||
| { | ||
| if ($value) { |
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.
I was intrigued by this problem:"how to detect if an array is associative or not" and I found two one-liners on StackOverflow. Maybe we can simplify this code?
$isMapping =array_keys($value) !==range(0,count($value) -1);$isMapping =count(array_filter(array_keys($value),'is_string')) >0;
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.
My solution uses less memory and is faster
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.
In theDumper class we usearray_keys($input) !== range(0, count($input) - 1) to detect the type of array. I am fine with changing the way we detect it, but then we should move the detection into a dedicated method an reuse it in both places.
inso commentedMay 26, 2016
Benchmark: |
nicolas-grekas commentedMay 29, 2016
👍 |
inso commentedMay 29, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@xabbuh comments addressed, but I'm not sure where isHash method should be placed. |
| * Check if given array is hash or just normal indexed array. | ||
| * | ||
| * @param array $value The PHP array to check | ||
| * |
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.
The method should be marked as@internal.
inso commentedMay 29, 2016
@xabbuh done. |
nicolas-grekas commentedMay 30, 2016
Thank you@inso. |
This PR was squashed before being merged into the 2.3 branch (closes#18861).Discussion----------Fix for#18843| Q | A| ------------- | ---| Branch? | 2.3| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#18843| License | MIT| Doc PR | -Commits-------7d78196 Fix for#18843
Uh oh!
There was an error while loading.Please reload this page.