Hi,
A couple of days ago I proposed the package PEAR_Callback;
see http://pear.php.net/pepr/pepr-proposal-show.php?id=468
It addresses three major limitations of the callback
pseudo-type:
- By looking at a callback pseudo-type variable you
cannot tell if it really is a callback.
- The callback pseudo-type does not allow you to specify
arguments at the time you create the callback.
- There is no way to force a user to pass only callback
functions to your API, that meet certain requirements
(i.e. accept certain arguments and have a certain
return type)
The core features of PEAR_Callback are:
- "Static" arguments can be specified when calling
the
constructor.
- "Dynamic" arguments can be specified when
calling
PEAR_Callback::execute().
- The callback definition passed to the constructor
allows you to specify the number, order and type of
static and dynamic arguments.
- It is already the constructor that will throw a
PEAR_Callback_Exception if the callback function is
not callable; it is therefore impossible to create a
callback that is not callable.
- If the callback definition contains type specifications
for the dynamic arguments, execute() will enforce these
constraints.
- PEAR_Callback::checkSignature() can be used to ensure
that the callback function accepts certain arguments and
has a certain return type before calling
PEAR_Callback::execute().
- The PEAR_Callback constructor can interpret a traditional
callback pseudo-type.
- in-depth documentation: tutorials and API documentation
- 89 phpt unit tests
Cheers,
Lukas
--
PEAR Development Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php
|