# Revise callback Psuedo-type to support new Closure class ?

- Thread: https://externals.io/message/50476
- Original archive: https://news-web.php.net/php.internals/50476
- Started by Nathan Nobbe on 2010-11-24T18:00:23+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #50476 — Nathan Nobbe — 2010-11-24T18:00:23+00:00

URL: https://externals.io/message/50476#50476

Hi all,

I had a thought this morning and would like some feedback.  Don't you think
it would make sense to allow the callback psuedo-type to also allow the new
Closure class to be an acceptable data type?  A simple example that would be
nice to have working would be

<?php
$fClosure = function($val, $key) {
    echo "$key => $val" . PHP_EOL;
}

$aNumbers = array(5, 4, 3, 2, 1);

array_walk($aNumbers, $fClosure);
?>

Thoughts ?

-nathan

---

## #50477 — Nathan Nobbe — 2010-11-24T18:03:45+00:00

URL: https://externals.io/message/50476#50477 · In reply to: #50476

Ummm... never mind!

Sorry for the noise!

-nathan

On Wed, Nov 24, 2010 at 11:00 AM, Nathan Nobbe <quickshiftin@gmail.com>wrote:

> Hi all,
>
> I had a thought this morning and would like some feedback.  Don't you think
> it would make sense to allow the callback psuedo-type to also allow the new
> Closure class to be an acceptable data type?  A simple example that would be
> nice to have working would be
>
> <?php
> $fClosure = function($val, $key) {
>     echo "$key => $val" . PHP_EOL;
> }
>
> $aNumbers = array(5, 4, 3, 2, 1);
>
> array_walk($aNumbers, $fClosure);
> ?>
>
> Thoughts ?
>
> -nathan

---

## #50527 — Richard Quadling — 2010-11-25T14:24:25+00:00

URL: https://externals.io/message/50476#50527 · In reply to: #50477

> Ummm... never mind!
>
> Sorry for the noise!
>
> -nathan
>
> On Wed, Nov 24, 2010 at 11:00 AM, Nathan Nobbe <quickshiftin@gmail.com>wrote:
>
> > […]
>

I bet you thought you had something there... Ha!

It is a pity that the error is tagged as being on line 6 and not line 4.

I can see why. It isn't an error until the first non ; following the
closing brace (excluding comments).

So ...

$fn = function()
// comment
;

is valid.

Having the error on the same line as the closing brace would be nice though.


Richard.
-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY
