[PHP-DEV] The inconsistencies/flaws of PHP5's object model

2009-11-18 Thread Jingcheng Zhang
Hello internals, I've just occured a syntax problem in the following script: ?php class C { public $n = 1; } $o = new C(); $o-f = function () use ($o) { echo $o-n; }; $o-f(); ? The result of this script is Fatal Error: Call to undefined method C::f(). I don't know this is the expected

Re: [PHP-DEV] Closures and $this

2009-11-18 Thread Richard Quadling
2009/11/16 Christian Seiler chris...@gmx.net: Hi, since a few months have passed since the last discussion on this topic and perhaps people had time to gather some experience with the current closure implementation in PHP 5.3 I'd like to restart the debate on $this in closures and object

[PHP-DEV] RFC: Custom Factories (SPL)

2009-11-18 Thread Robert Lemke
Hi folks, after discussing the idea with various PHP developers I now felt safe enough that it's not a completely stupid idea to post an RFC for it. The idea is to add support the registration of custom factories which are responsible for instantiating certain classes. Here is the first draft

Re: [PHP-DEV] RFC: Custom Factories (SPL)

2009-11-18 Thread Alexey Zakhlestin
On 18.11.2009, at 19:06, Robert Lemke wrote: Hi folks, after discussing the idea with various PHP developers I now felt safe enough that it's not a completely stupid idea to post an RFC for it. The idea is to add support the registration of custom factories which are responsible for

Re: [PHP-DEV] RFC: Custom Factories (SPL)

2009-11-18 Thread Mathieu Suen
Robert Lemke a écrit : Hi folks, after discussing the idea with various PHP developers I now felt safe enough that it's not a completely stupid idea to post an RFC for it. The idea is to add support the registration of custom factories which are responsible for instantiating certain classes.

Re: [PHP-DEV] RFC: Custom Factories (SPL)

2009-11-18 Thread Etienne Kneuss
Hello, On Wed, Nov 18, 2009 at 5:54 PM, Mathieu Suen mathieu.s...@easyflirt.comwrote: Robert Lemke a écrit : Hi folks, after discussing the idea with various PHP developers I now felt safe enough that it's not a completely stupid idea to post an RFC for it. The idea is to add support the

Re: [PHP-DEV] RFC: Custom Factories (SPL)

2009-11-18 Thread Robert Lemke
Hi Alexey, Am 18.11.2009 um 17:27 schrieb Alexey Zakhlestin: So, from the high-level point of view, you want to introduce mechanism, which would allow instantiate objects by their interface, instead of their class-name. And this mechanism should use user-provided rules for choosing

Re: [PHP-DEV] RFC: Custom Factories (SPL)

2009-11-18 Thread Mathieu Suen
Etienne Kneuss a écrit : Hello, On Wed, Nov 18, 2009 at 5:54 PM, Mathieu Suen mathieu.s...@easyflirt.comwrote: Robert Lemke a écrit : Hi folks, after discussing the idea with various PHP developers I now felt safe enough that it's not a completely stupid idea to post an RFC for it. The

Re: [PHP-DEV] RFC: Custom Factories (SPL)

2009-11-18 Thread Robert Lemke
Hi Mathieu, Am 18.11.2009 um 18:19 schrieb Mathieu Suen: Right!! I get confused with: $classNamme::getInstance(); So you can easily inject dependency: class Foo { protected $emailer; public function __construct($emailClass) { $this-emailer= $emailClass;

Re: [PHP-DEV] RFC: Custom Factories (SPL)

2009-11-18 Thread Eloy Bote Falcon
2009/11/18 Mathieu Suen mathieu.s...@easyflirt.com Etienne Kneuss a écrit : Hello, On Wed, Nov 18, 2009 at 5:54 PM, Mathieu Suen mathieu.s...@easyflirt.com wrote: Robert Lemke a écrit : Hi folks, after discussing the idea with various PHP developers I now felt safe enough that it's

Re: [PHP-DEV] Closures and $this

2009-11-18 Thread Stanislav Malyshev
Hi! As for public/protected/private ... $fn = function() use() bind() access(CLOSURE_PUBLIC | CLOSURE_PROTECTED | CLOSURE_PRIVATE) {}; I have very hard time imagining somebody that would be comfortable using such a construct. What happened to keeping it simple? And why every tiniest

Re: [PHP-DEV] RFC: Custom Factories (SPL)

2009-11-18 Thread Stanislav Malyshev
Hi! Here is the first draft of my RFC: http://wiki.php.net/rfc/customfactories Something I'm missing in this RFC: what's wrong with factory base class doing: public static function getInstance() { if(static::$instance === NULL) {

Re: [PHP-DEV] The inconsistencies/flaws of PHP5's object model

2009-11-18 Thread Stanislav Malyshev
Hi! I've just occured a syntax problem in the following script: ?php class C { public $n = 1; } $o = new C(); $o-f = function () use ($o) { echo $o-n; }; $o-f(); ? The result of this script is Fatal Error: Call to undefined method C::f(). I don't know this is the expected result.

Re: [PHP-DEV] Closures and $this

2009-11-18 Thread Chris Stockton
Hello, On Wed, Nov 18, 2009 at 11:44 AM, Stanislav Malyshev s...@zend.com wrote: I have very hard time imagining somebody that would be comfortable using such a construct. What happened to keeping it simple? And why every tiniest feature of every remotest imaginable use case has to be brought

Re: [PHP-DEV] Closures and $this

2009-11-18 Thread Stanislav Malyshev
Hi! That syntax made my eyes hurt, but I think really the problem is that people want to dynamically add methods with $this in the closure pointing the the object it has been attached too. Really I like A. but We can add method to Closure class to allow that. See Closure::bind and bindTo in

Re: [PHP-DEV] RFC: Custom Factories (SPL)

2009-11-18 Thread mm w
what you call factory objects are more proxy objects, please make the difference, semantics are sometimes important. anyway , what I can read this document is a bit a mess, it needs to be split by topic, your approach is really confuse. Best, On Wed, Nov 18, 2009 at 8:06 AM, Robert Lemke

RE: [PHP-DEV] RFC: Custom Factories (SPL)

2009-11-18 Thread Jared Williams
-Original Message- From: Robert Lemke [mailto:rob...@typo3.org] Sent: 18 November 2009 16:07 To: internals@lists.php.net Subject: [PHP-DEV] RFC: Custom Factories (SPL) Hi folks, after discussing the idea with various PHP developers I now felt safe enough that it's not a

Re: [PHP-DEV] The inconsistencies/flaws of PHP5's object model

2009-11-18 Thread Jingcheng Zhang
Hello Stanislav, 2009/11/19 Stanislav Malyshev s...@zend.com Hi! Yes, this is the expected result. PHP is not Javascript, sorry :) Methods and properties are different things in PHP, so the syntax assumes you refer to method when you call $o-f(). You could use other syntaxes if you need to

Re: [PHP-DEV] RFC: Custom Factories (SPL)

2009-11-18 Thread Alban
Le Thu, 19 Nov 2009 02:24:01 +, Jared Williams a écrit : -Original Message- From: Robert Lemke [mailto:rob...@typo3.org] Sent: 18 November 2009 16:07 To: internals@lists.php.net Subject: [PHP-DEV] RFC: Custom Factories (SPL) Hi folks, after discussing the idea with various

Re: [PHP-DEV] RFC: Custom Factories (SPL)

2009-11-18 Thread Mathieu Suen
Eloy Bote Falcon a écrit : 2009/11/18 Mathieu Suen mathieu.s...@easyflirt.com Etienne Kneuss a écrit : Hello, On Wed, Nov 18, 2009 at 5:54 PM, Mathieu Suen mathieu.s...@easyflirt.com wrote: Robert Lemke a écrit : Hi folks, after discussing the idea with various PHP developers I now