Skip to content
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

Collection walk method bug fix when specific callback function #5742

Merged
merged 4 commits into from
Apr 13, 2017
Merged
Changes from 3 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
9 changes: 6 additions & 3 deletions lib/internal/Magento/Framework/Data/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -500,16 +500,19 @@ public function clear()
*/
public function walk($callback, array $args = [])
{
$results = [];
$results = [];
$useItemCallback = is_string($callback) && strpos($callback, '::') === false;
foreach ($this->getItems() as $id => $item) {
$params = $args;
if ($useItemCallback) {
$cb = [$item, $callback];
} else {
$cb = $callback;
array_unshift($args, $item);
array_unshift($params, $item);
}
$results[$id] = call_user_func_array($cb, $args);
//@codingStandardsIgnoreStart
$results[$id] = call_user_func_array($cb, $params);
//@codingStandardsIgnoreEnd
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What needs to be ignored here?

Copy link
Contributor Author

@jalogut jalogut Feb 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing, I was just getting a warning that you should not use "call_user_func_array". I removed these coding standard ignores

}
return $results;
}
Expand Down