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

2009-11-21 Thread Lukas Kahwe Smith
On 18.11.2009, at 09:23, Jingcheng Zhang wrote: > Hello internals, > > I've just occured a syntax problem in the following script: > > class C { >public $n = 1; > } > $o = new C(); > $o->f = function () use ($o) { >echo $o->n; > }; > $o->f(); > ?> > > The result of this script is "Fat

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

2009-11-19 Thread Stanislav Malyshev
Hi! call_user_func(array($o,'f')); leads to fatal error, I think the same Of course, since you again asked to call method 'f'. Try: call_user_func($o->f); Ah, didn't notice you already wrote that. Anyway, the difference is that methods and properties in PHP, unlike Javascript, live in diffe

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

2009-11-19 Thread Stanislav Malyshev
Hi! call_user_func(array($o,'f')); leads to fatal error, I think the same Of course, since you again asked to call method 'f'. Try: call_user_func($o->f); -- Stanislav Malyshev, Zend Software Architect s...@zend.com http://www.zend.com/ (408)253-8829 MSN: s...@zend.com -- PHP Internals -

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

2009-11-19 Thread Julien Pauli
On Wed, Nov 18, 2009 at 8:59 PM, Stanislav Malyshev wrote: > Hi! > >> I've just occured a syntax problem in the following script: >> >> > class C { >>    public $n = 1; >> } >> $o = new C(); >> $o->f = function () use ($o) { >>    echo $o->n; >> }; >> $o->f(); >> ?> >> >> The result of this script

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

2009-11-19 Thread Stanislav Malyshev
Hi! $methodName)) instead, which is ugly and verbose. Since PHP 5.3 adds closure support, I think the syntax "$o->f()" should also check whether "f" is a closure, if it is, then call it. That creates a myriad of problems due to the fact that if the class defines both __call and __get it is n

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

2009-11-18 Thread Jingcheng Zhang
Hello Stanislav, 2009/11/19 Stanislav Malyshev > 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 > use a

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: 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. After trying more tests of Yes, this is the expecte

[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: 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. After trying more tests of adding/removing