laravel/framework — pull request #3742 by GrahamCampbell (2014-02-28 20:03:05+00:00)
Title: Array walk fixes

I've had a think since yesterday, and the current usage of array_walk is still incorrect.

#### What You Have Now

What this does is execute the intval function with 2 arguments: the value, and the key. This means we are setting the intval base to each array key each time. This is not the desired behaviour, and I am surprised this hasn't caused issues for people already! Currently we have is:

```
array_walk($detach, 'intval');
```

So the code you currently have basicly does this:

```
array_walk($detach, function(&$value, $key) { $value = intval($value, $key); });
```

#### My Proposed Fix

What would be better would be to make sure we are not setting the base by mistake:

```
array_walk($detach, function(&$n) { $n = intval($n); });
```

#### PHP Documentation

You can refer to the php [intval docs](http://uk3.php.net/intval) and [array_walk docs](http://uk3.php.net/array_walk) for more information.

---

Related to #3726 and https://github.com/facebook/hhvm/issues/1935.