Reputation: 4974
I am talking about Closures with some friends of a Group (from PHP 5.3).
When I do a var_dump(function(){});
the result is object(Closure)
. One of peoples said: but Closures are not Object.
I understand what when Anonymous Function implements Closure class, the result need to be a Object, nothing more or different.
Is a anonymous function a object?
UPDATE I have read "Anonymous functions are implemented using the Closure class." (http://php.net/manual/en/functions.anonymous.php), so, I think this is a Object.
Upvotes: 1
Views: 81
Reputation: 6687
Can you elaborate on what you're trying to do? In PHP Closure
is a final class
, so technically yes, it's an object.
Upvotes: 0
Reputation: 48284
Strongly worded in the manual:
Anonymous functions, implemented in PHP 5.3, yield objects of this type [Closure]. This fact used to be considered an implementation detail, but it can now be relied upon.
http://www.php.net/manual/en/class.closure.php
To be clear, the answer is: yes, they are objects.
Upvotes: 2