| From | Sent On | Attachments |
|---|---|---|
| Hannes Magnusson | Jun 6, 2011 12:41 pm | .txt |
| Stas Malyshev | Jun 6, 2011 1:35 pm | |
| Hannes Magnusson | Jun 6, 2011 1:48 pm | |
| Christopher Jones | Jun 6, 2011 1:49 pm | |
| Stas Malyshev | Jun 6, 2011 2:16 pm | |
| Matthew Weier O'Phinney | Jun 6, 2011 3:15 pm | |
| Pierre Joye | Jun 6, 2011 3:26 pm | |
| Matthew Weier O'Phinney | Jun 6, 2011 3:32 pm | |
| Etienne Kneuss | Jun 6, 2011 3:41 pm | |
| Chris Stockton | Jun 6, 2011 3:51 pm | |
| Chris Stockton | Jun 6, 2011 3:52 pm | |
| Ferenc Kovacs | Jun 6, 2011 4:01 pm | |
| Stas Malyshev | Jun 6, 2011 4:01 pm | |
| Chris Stockton | Jun 6, 2011 4:20 pm | |
| Derick Rethans | Jun 6, 2011 4:30 pm | |
| Martin Scotta | Jun 6, 2011 7:50 pm | |
| Jordi Boggiano | Jun 7, 2011 3:08 am | |
| Hannes Magnusson | Jun 7, 2011 6:59 am | |
| Richard Quadling | Jun 7, 2011 7:03 am | |
| Hannes Magnusson | Jun 7, 2011 7:21 am | |
| Jaroslav Hanslik | Jun 7, 2011 8:22 am | |
| Matthew Weier O'Phinney | Jun 7, 2011 9:10 am | |
| Stas Malyshev | Jun 7, 2011 11:50 am | |
| David Zülke | Jun 7, 2011 12:03 pm | |
| Stas Malyshev | Jun 7, 2011 12:12 pm | |
| David Zülke | Jun 7, 2011 12:28 pm | |
| Anthony Ferrara | Jun 7, 2011 12:37 pm | |
| Martin Scotta | Jun 7, 2011 1:28 pm | |
| Stas Malyshev | Jun 7, 2011 1:31 pm | |
| David Zülke | Jun 7, 2011 1:32 pm | |
| Pierre Joye | Jun 7, 2011 1:36 pm | |
| Mike van Riel | Jun 7, 2011 1:43 pm | |
| Matthew Weier O'Phinney | Jun 7, 2011 1:44 pm | |
| dukeofgaming | Jun 7, 2011 2:15 pm | |
| Matthew Weier O'Phinney | Jun 7, 2011 2:41 pm | |
| dukeofgaming | Jun 7, 2011 3:38 pm | |
| Johannes Schlüter | Jun 7, 2011 4:39 pm | |
| David Zülke | Jun 7, 2011 5:04 pm | |
| Alexey Shein | Jun 7, 2011 10:24 pm | |
| Hannes Magnusson | Jun 8, 2011 1:31 am | |
| Hannes Magnusson | Jun 8, 2011 1:38 am | |
| Alexey Shein | Jun 8, 2011 1:47 am | |
| Johannes Schlüter | Jun 8, 2011 3:04 am | |
| Hannes Magnusson | Jun 8, 2011 3:17 am | |
| Richard Quadling | Jun 8, 2011 3:27 am | |
| Johannes Schlüter | Jun 8, 2011 3:28 am | |
| Hannes Magnusson | Jun 8, 2011 3:30 am | |
| Johannes Schlüter | Jun 8, 2011 3:31 am | |
| Richard Quadling | Jun 8, 2011 3:31 am | |
| Anthony Ferrara | Jun 8, 2011 6:31 am | |
| Martin Scotta | Jun 8, 2011 7:42 am | |
| Martin Scotta | Jun 8, 2011 7:48 am | |
| David Zülke | Jun 8, 2011 8:53 am | |
| Johannes Schlüter | Jul 10, 2011 12:02 pm | |
| Stas Malyshev | Jul 10, 2011 12:57 pm | |
| Hannes Magnusson | Jul 11, 2011 1:21 am | |
| Stas Malyshev | Jul 11, 2011 1:27 am | |
| Peter Cowburn | Jul 11, 2011 1:37 am | |
| Hannes Magnusson | Jul 11, 2011 1:38 am | |
| Stas Malyshev | Jul 11, 2011 1:43 am | |
| Ferenc Kovacs | May 27, 2013 10:59 pm | |
| Peter Cowburn | May 27, 2013 11:47 pm | |
| Ferenc Kovacs | May 28, 2013 1:21 am |
| Subject: | Re: [PHP-DEV] Callable typehint | |
|---|---|---|
| From: | Matthew Weier O'Phinney (weie...@php.net) | |
| Date: | Jun 6, 2011 3:32:45 pm | |
| List: | net.php.lists.internals | |
On 2011-06-06, Pierre Joye <pier...@gmail.com> wrote:
--0016e6de0029ddc06f04a5129914 Content-Type: text/plain; charset=ISO-8859-1
How is this argument different than the one in favor of type hinting (or whatever was what ended in trunk)?
I was simply voicing my support for Hannes' patch, and trying to clarify my understanding of it for Stas.
If you're comparing it to the scalar typehinting patch, I think it's a far cry from that -- this is about providing a unified typehint for functionality represented over multiple constructs in PHP, in order to reduce code in applications. If it offers no BC issues, and allows developers to simplify code and remove boilerplate (which can easily introduce new errors on each iteration), then why wouldn't it be a good idea?
On 7 Jun 2011 00:16, "Matthew Weier O'Phinney" <weie...@php.net> wrote:
On 2011-06-06, Stas Malyshev <smal...@sugarcrm.com> wrote:
Like I mentioned in the other thread (which I probably should had repeated here), a lot of libs/frameworks are using the 'Closure' typehint for callbacks.
Well, they are wrong (unless they mean to use only closures and not callbacks). But that's no reason to do wrong thing in the language too.
The problem with that is a function name as a string and array("classname", "functionname") are considered is_callable(). To get through the intentions of the Closure hint, I would have to wrap the actual callback in a closure - which doesn't make any sense.
"callable" is not actually even a type. If we make it a language construct, then why 'authenticated DB connection', 'name of readable file', 'valid stream URL', 'validated XML', 'string in UTF-8 no longer than 255 characters' or 'balanced binary tree' is not a language construct? I don't think we need to put every data check into the language, especially that it actually makes it worse - you can gracefully handle user-space check, but not a strict typing error.
The point, though, is that with such a typehint available, we can reduce boilerplate code like the following:
public function addCallback($callback) { if (!is_callback($callback)) { throw new InvalidArgumentException(); }
The typehint makes this simpler:
public function addCallback(callback $callback)
which allows us to rely on PHP's native error handling. I, for one, would love to see this.
-- Matthew Weier O'Phinney Project Lead | matt...@zend.com Zend Framework | http://framework.zend.com/ PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
--0016e6de0029ddc06f04a5129914--
-- Matthew Weier O'Phinney Project Lead | matt...@zend.com Zend Framework | http://framework.zend.com/ PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php






.txt