Skip to content

Conversation

hikari-no-yume
Copy link
Contributor

Since Closure::call() has been merged into php-src master (php/php-src#775), so too should we document it in the master spec.

@@ -1704,6 +1705,7 @@ Name | Purpose
-----|--------
`bind` | Duplicates closure `$closure` with a specific bound object `$newthis` and class scope `$newscope`. If `$newthis` is `NULL` then the closure is to be unbound if no scope is specified, or static if a scope is specified. `$newscope` is the scope the closure is to be given (either a string containing the name of a class, or an object whose class will be used), or `"static"` to keep the current one. Returns a new `Closure` object or `FALSE` on failure. This function must not violate the invariant that closures must either be both scoped and bound or static, or otherwise both unscoped and unbound. This function must prevent binding an object to the new closure if the `$closure` is static, however the new closure may have a different scope.
`bindTo` | Duplicates the closure designated by the current instance with a new-bound object and class scope. This method is an instance version of bind.
`call` | Calls the closure (the current instance) with `$this` bound to `$newthis`, the class scope of the class of `$newthis`, and the parameters specified by `$parameters`. This function must fail if `$newthis` is NULL, or if the closure is static.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the error case be descripted in more detail? What does the function must fail mean? Exception? Return false/null? Fatal error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In PHP I think it's a fatal or recoverable just now. If I'd meant return NULL, I would've said it. I agree this could be clearer.

@smalyshev smalyshev added the RFC label Nov 5, 2014
@php-pulls php-pulls merged commit f5cf82d into php:master Nov 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants