Re: [PHP-DEV] T_PAAMAYIM_NEKUDOTAYIM

2002-12-17 Thread Andi Gutmans
It won't be supported but you can use eval() if you really need to.

Andi

At 08:47 PM 12/16/2002 +0100, Bertrand Mansion wrote:

<[EMAIL PROTECTED]> wrote :

> On Mon, 16 Dec 2002, Bertrand Mansion wrote:
>
>> <[EMAIL PROTECTED]> wrote :
>>
>>> Its neither, its a fact of the language, the following:
>>>
>>> $classname::method is illegal, you recieved a parse error to that
>>> effect.  the best thing to do is::
>>
>> I don't understand why it is illegal...
>
> It's just not supported by PHP.

Will it be supported ?
This would allow
>>
>>> call_user_func(array($className, 'method'), $param1, $param2);
>>
>> This won't work because, in my case, I don't want to make an instance of
>> $className but rather use $className methods as if they were plugged 
inside
>> my main object.
>
> This doesn't make an instance at all.

Sorry, I didn't choose the right way to explain. :)

I meant that call_user_func needs an instanciated object which I can't
provide as what I really want to do is use a method from a class, not from
an instanciated object. (not sure it's clearer ?)
And keep an access to $this from inside the object calling the external
method because my parsing is actually recursive.

For an example of my current code, you can have a look at Container.php in
the Config package of PEAR (in CVS only). I am having hard time to figure
out what would be the best way to implement this in PHP.

Bertrand Mansion
Mamasam





--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] T_PAAMAYIM_NEKUDOTAYIM

2002-12-17 Thread Markus Fischer
On Tue, Dec 17, 2002 at 09:57:08AM +0100, Bertrand Mansion wrote : 
> <[EMAIL PROTECTED]> wrote :
> 
> > On Tue, 17 Dec 2002, Bertrand Mansion wrote:
> > 
> >> If this behaviour could be extended to support $className::method(), that
> >> would be just great.
> > 
> > Search the archives, it was brought up before, conclusion: it will not
> > happen.
> 
> I only found this:
> http://marc.theaimsgroup.com/?l=php-dev&m=96271776302715&w=2
> which is a very interesting feature request. In there, there is a request
> for this : $className::method(). I am not the only one.
> 
> 
> Personally, I still don't understand why this will not happen. Why would you
> allow class::method() in the first place ? If you have any pointers to your
> previous discussions, please let me know.

I am not exactly sure, but I hardly remember a discussion
which about this (don't know where it was) that it would slow
down performance. Maybe this was on the engine2 list.

- Markus

-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] T_PAAMAYIM_NEKUDOTAYIM

2002-12-17 Thread Bertrand Mansion
<[EMAIL PROTECTED]> wrote :

> On Tue, 17 Dec 2002, Bertrand Mansion wrote:
> 
>> If this behaviour could be extended to support $className::method(), that
>> would be just great.
> 
> Search the archives, it was brought up before, conclusion: it will not
> happen.

I only found this:
http://marc.theaimsgroup.com/?l=php-dev&m=96271776302715&w=2
which is a very interesting feature request. In there, there is a request
for this : $className::method(). I am not the only one.


Personally, I still don't understand why this will not happen. Why would you
allow class::method() in the first place ? If you have any pointers to your
previous discussions, please let me know.

TIA,

Bertrand Mansion
Mamasam


--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] T_PAAMAYIM_NEKUDOTAYIM

2002-12-16 Thread Derick Rethans
On Tue, 17 Dec 2002, Bertrand Mansion wrote:

> If this behaviour could be extended to support $className::method(), that
> would be just great.

Search the archives, it was brought up before, conclusion: it will not 
happen.

Derick

-- 

-
 Derick Rethans http://derickrethans.nl/ 
 PHP Magazine - PHP Magazine for Professionals   http://php-mag.net/
-


-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] T_PAAMAYIM_NEKUDOTAYIM

2002-12-16 Thread Brad LaFountain

--- Bertrand Mansion <[EMAIL PROTECTED]> wrote:
> <[EMAIL PROTECTED]> wrote :
> 
> > 
> > --- Bertrand Mansion <[EMAIL PROTECTED]> wrote:
> >> <[EMAIL PROTECTED]> wrote?:
> >> 
> >>> $classname::method() === call_user_func(array($classname,'method'));
> >> 
> >> No. $classname::method() is illegal and is in no case === to
> >> call_user_func(array($classname,'method')) as you state it.
> >> 
> >> Class foo {
> >> function bar() {
> >> echo $this->param;
> >> }
> >> }
> >> 
> >> Class MyObject {
> >> var $param;
> >> function MyObject($param) {
> >> $this->param = $param;
> >> foo::bar();
> >> }
> >> }
> >> 
> >> $obj = new MyObject('out of this');
> >> 
> >> will print 'from MyObject'.
> > 
> > 
> > This SHOULDN'T print 'out of this', This seems like a bug, and you
> SHOULDN'T
> > depend on this functionality. The scope of $this inside class foo method
> bar,
> > Should be to foo::bar NOT MyObject::MyObject. Which if my memory serves me
> > right $this inside a static method will just be the string of the current
> > class?
> 
> Hi Brad,
> 
> Are you sure about that ? The manual states that this is the normal
> behaviour which I find very handy and useful in many cases. I see a lot of
> possibilities with this feature, for instance a way to develop some kind of
> plug-ins for existing classes without having to extend them.

 Where in the manual do you see this? 

> 
> This can probably lead to some dangerous code but this goes far beyond my
> knowledge.

 besides dangerous code if you find yourself doing this, you probally aren't
designing it correct. Your creating a static method of a class to access local
properties of another class thru the use of $this. If you want a way to access
member variables from a class in a static method, pass the object refrence into
the method.

 Class foo {
 function bar($obj) {
 echo $obj->param;
 /* $this should referr to the foo refrence, not another class refrence
*/
 }
 }
 
 Class MyObject {
 var $param;
 function MyObject($param) {
 $this->param = $param;
 foo::bar($this);
}
}

 - Brad



__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] T_PAAMAYIM_NEKUDOTAYIM

2002-12-16 Thread Bertrand Mansion
<[EMAIL PROTECTED]> wrote :

> 
> --- Bertrand Mansion <[EMAIL PROTECTED]> wrote:
>> <[EMAIL PROTECTED]> wrote?:
>> 
>>> $classname::method() === call_user_func(array($classname,'method'));
>> 
>> No. $classname::method() is illegal and is in no case === to
>> call_user_func(array($classname,'method')) as you state it.
>> 
>> Class foo {
>> function bar() {
>> echo $this->param;
>> }
>> }
>> 
>> Class MyObject {
>> var $param;
>> function MyObject($param) {
>> $this->param = $param;
>> foo::bar();
>> }
>> }
>> 
>> $obj = new MyObject('out of this');
>> 
>> will print 'from MyObject'.
> 
> 
> This SHOULDN'T print 'out of this', This seems like a bug, and you SHOULDN'T
> depend on this functionality. The scope of $this inside class foo method bar,
> Should be to foo::bar NOT MyObject::MyObject. Which if my memory serves me
> right $this inside a static method will just be the string of the current
> class?

Hi Brad,

Are you sure about that ? The manual states that this is the normal
behaviour which I find very handy and useful in many cases. I see a lot of
possibilities with this feature, for instance a way to develop some kind of
plug-ins for existing classes without having to extend them.

This can probably lead to some dangerous code but this goes far beyond my
knowledge.

Anyway, if someone aware could give some clarifications on should I rely or
not on this behaviour, that would be very appreciated.

If this behaviour could be extended to support $className::method(), that
would be just great.

>> 
>> While,
>> 
>> Class MyObject {
>> var $option;
>> function MyObject($option) {
>> $this->option = $option;
>> call_user_func(array('foo', 'bar'));
>> }
>> }
>> 
>> will return 'Undefined variable: this'...
> 
> This should be the way that both examples function.
> 
> $this is a refrence to the current object. inside a static method like
> foo::bar() there is no $this defined because its static.
> 
> 
> - Brad


--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] T_PAAMAYIM_NEKUDOTAYIM

2002-12-16 Thread Brad LaFountain

--- Bertrand Mansion <[EMAIL PROTECTED]> wrote:
> <[EMAIL PROTECTED]> wrote :
> 
>  I guess I am going to have to write stupid code such as:
>  
>  switch ($param1) {
>  case 'parser1':
>  return parser1::method();
>  case 'parser2':
>  return parser2::method();
>  }
> >>> 
> >>> call_user_func(array($param1, 'method'));
> >> 
> >> No. Undefined variable this in $param1. Get it ?
> >> 
> > No.  The code you displayed (in the switch block) is 100% identical to the
> > code Derick offered (except for the fact that Derick's example will handle
> > any class name while yours is limited).
> > 
> > $classname::method() === call_user_func(array($classname,'method'));
> 
> No. $classname::method() is illegal and is in no case === to
> call_user_func(array($classname,'method')) as you state it.
> 
> Class foo {
> function bar() {
> echo $this->param;
> }
> }
> 
> Class MyObject {
> var $param;
> function MyObject($param) {
> $this->param = $param;
> foo::bar();
> }
> }
> 
> $obj = new MyObject('out of this');
> 
> will print 'from MyObject'.


 This SHOULDN'T print 'out of this', This seems like a bug, and you SHOULDN'T
depend on this functionality. The scope of $this inside class foo method bar,
Should be to foo::bar NOT MyObject::MyObject. Which if my memory serves me
right $this inside a static method will just be the string of the current
class?

> 
> While,
> 
> Class MyObject {
> var $option;
> function MyObject($option) {
> $this->option = $option;
> call_user_func(array('foo', 'bar'));
> }
> }
> 
> will return 'Undefined variable: this'...

 This should be the way that both examples function.

 $this is a refrence to the current object. inside a static method like
foo::bar() there is no $this defined because its static.


 - Brad



__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DEV] T_PAAMAYIM_NEKUDOTAYIM

2002-12-16 Thread Mike Robinson

Just so you know, not so long ago a google search for
"T_PAAMAYIM_NEKUDOTAYIM" used to turn up just 1 matching result.

:P

Regards
Mike Robinson


Pierre-Alain Joye wrote:
> On Tue, 17 Dec 2002 00:17:47 +0100
> Pierre-Alain Joye <[EMAIL PROTECTED]> wrote:
> 
> > On Mon, 16 Dec 2002 23:56:03 +0100
> > Bertrand Mansion <[EMAIL PROTECTED]> wrote:
> > 
> > > will return 'Undefined variable: this'...
> > 
> > The syntax foo::bar() should be used for every method callable
> > directly(ex: a factory), without an instance of the parent object.
>^^
>without an instance of the object itself.


-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] T_PAAMAYIM_NEKUDOTAYIM

2002-12-16 Thread Pierre-Alain Joye
On Tue, 17 Dec 2002 00:17:47 +0100
Pierre-Alain Joye <[EMAIL PROTECTED]> wrote:

> On Mon, 16 Dec 2002 23:56:03 +0100
> Bertrand Mansion <[EMAIL PROTECTED]> wrote:
> 
> > will return 'Undefined variable: this'...
> 
> The syntax foo::bar() should be used for every method callable
> directly(ex: a factory), without an instance of the parent object.
   ^^
   without an instance of the object itself.

-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] T_PAAMAYIM_NEKUDOTAYIM

2002-12-16 Thread Pierre-Alain Joye
On Mon, 16 Dec 2002 23:56:03 +0100
Bertrand Mansion <[EMAIL PROTECTED]> wrote:

> will return 'Undefined variable: this'...

The syntax foo::bar() should be used for every method callable directly
(ex: a factory), without an instance of the parent object. The "$this"
variable represents the object who owns the current method. If this
method has been called directly, there is no object itself, neither
properties.

hth

pierre

-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] T_PAAMAYIM_NEKUDOTAYIM

2002-12-16 Thread Bertrand Mansion
<[EMAIL PROTECTED]> wrote :

> $obj = new MyObject('out of this');
> 
> will print 'from MyObject'.

Read "will print 'out of this'".
Thanks,

Bertrand Mansion
Mamasam


--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] T_PAAMAYIM_NEKUDOTAYIM

2002-12-16 Thread Bertrand Mansion
<[EMAIL PROTECTED]> wrote :

 I guess I am going to have to write stupid code such as:
 
 switch ($param1) {
 case 'parser1':
 return parser1::method();
 case 'parser2':
 return parser2::method();
 }
>>> 
>>> call_user_func(array($param1, 'method'));
>> 
>> No. Undefined variable this in $param1. Get it ?
>> 
> No.  The code you displayed (in the switch block) is 100% identical to the
> code Derick offered (except for the fact that Derick's example will handle
> any class name while yours is limited).
> 
> $classname::method() === call_user_func(array($classname,'method'));

No. $classname::method() is illegal and is in no case === to
call_user_func(array($classname,'method')) as you state it.

Class foo {
function bar() {
echo $this->param;
}
}

Class MyObject {
var $param;
function MyObject($param) {
$this->param = $param;
foo::bar();
}
}

$obj = new MyObject('out of this');

will print 'from MyObject'.

While,

Class MyObject {
var $option;
function MyObject($option) {
$this->option = $option;
call_user_func(array('foo', 'bar'));
}
}

will return 'Undefined variable: this'...

This is why, if you need to access $this, you will choose to use ::
But because of the weird limitation that does not allow you to use it in a
dynamic way ( $var::method() ), you will need to use stupid switch like I
did above. Get it ?

> Get it?
> 
> -Pollita
> 
> P.S. - This thread has gone on long enough, either TRY IT, or take it to
> [EMAIL PROTECTED] where it belongs so that they can tell you the
> same thing.

Well, if you think that this thread is too long and that this is not a
problem or a limitation of PHP, good on you. You probably never had to deal
with such a case.

I just wanted to make sure there was really no other way than using the
stupid switch scenario.

Bertrand Mansion
Mamasam


--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] T_PAAMAYIM_NEKUDOTAYIM

2002-12-16 Thread Sara Golemon
>>> I guess I am going to have to write stupid code such as:
>>>
>>> switch ($param1) {
>>> case 'parser1':
>>> return parser1::method();
>>> case 'parser2':
>>> return parser2::method();
>>> }
>>
>> call_user_func(array($param1, 'method'));
>
> No. Undefined variable this in $param1. Get it ?
>
No.  The code you displayed (in the switch block) is 100% identical to the
code Derick offered (except for the fact that Derick's example will handle
any class name while yours is limited).

$classname::method() === call_user_func(array($classname,'method'));

Get it?

-Pollita

P.S. - This thread has gone on long enough, either TRY IT, or take it to
[EMAIL PROTECTED] where it belongs so that they can tell you the
same thing.




-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] T_PAAMAYIM_NEKUDOTAYIM

2002-12-16 Thread Bertrand Mansion
<[EMAIL PROTECTED]> wrote :

> On Mon, 16 Dec 2002, Bertrand Mansion wrote:
> 
>> I guess I am going to have to write stupid code such as:
>> 
>> switch ($param1) {
>> case 'parser1':
>> return parser1::method();
>> case 'parser2':
>> return parser2::method();
>> }
> 
> call_user_func(array($param1, 'method'));

No. Undefined variable this in $param1. Get it ?

Bertrand Mansion
Mamasam




--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] T_PAAMAYIM_NEKUDOTAYIM

2002-12-16 Thread Derick Rethans
On Mon, 16 Dec 2002, Bertrand Mansion wrote:

> I guess I am going to have to write stupid code such as:
> 
> switch ($param1) {
> case 'parser1':
> return parser1::method();
> case 'parser2':
> return parser2::method();
> }

call_user_func(array($param1, 'method'));

Derick

-- 

-
 Derick Rethans http://derickrethans.nl/ 
 PHP Magazine - PHP Magazine for Professionals   http://php-mag.net/
-


-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] T_PAAMAYIM_NEKUDOTAYIM

2002-12-16 Thread Bertrand Mansion
<[EMAIL PROTECTED]> wrote :

> On Mon, 16 Dec 2002, Bertrand Mansion wrote:
> 
>> And keep an access to $this from inside the object calling the external
>> method because my parsing is actually recursive.
> 
> $this only works for instanciated classes, not static method calls.

>From the documentation,
http://www.php.net/manual/en/keyword.paamayim-nekudotayim.php
"...Thus, when used from WITHIN an object function, you may use $this and
object variables." This is the exact behaviour I need for my class to work.

:: is really one of the coolest features of PHP. I don't see why
$className::method() can't work, this is not very logical when you know that
$method() works and $a = new $b() works too. Even $className::$method()
should work :)

OK, I understood it's not implemented and won't be anytime soon. I guess
this is because of some obscure reasons that go far over my comprehension
but because of that, I am going to be stuck with this class.

I guess I am going to have to write stupid code such as:

switch ($param1) {
case 'parser1':
return parser1::method();
case 'parser2':
return parser2::method();
}

Don't laugh at me, it's not funny :)

Bertrand Mansion
Mamasam


--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] T_PAAMAYIM_NEKUDOTAYIM

2002-12-16 Thread Pierre-Alain Joye
On Mon, 16 Dec 2002 20:55:49 +0100 (CET)
Derick Rethans <[EMAIL PROTECTED]> wrote:

> > And keep an access to $this from inside the object calling the
> > external method because my parsing is actually recursive.
> 
> $this only works for instanciated classes, not static method calls.

Indeed, you may change the call inside the class using foo::bar() too,
and you can still not access to the object properties.

Auth and HTML_Javascript use this kind of calls.

pierre

-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] T_PAAMAYIM_NEKUDOTAYIM

2002-12-16 Thread Derick Rethans
On Mon, 16 Dec 2002, Bertrand Mansion wrote:

> <[EMAIL PROTECTED]> wrote :
> 
> > It's just not supported by PHP.
> 
> Will it be supported ?

Not anytime soon.

> This would allow
> >> 
> >>> call_user_func(array($className, 'method'), $param1, $param2);
> >> 
> >> This won't work because, in my case, I don't want to make an instance of
> >> $className but rather use $className methods as if they were plugged inside
> >> my main object.
> > 
> > This doesn't make an instance at all.
> 
> Sorry, I didn't choose the right way to explain. :)
> 
> I meant that call_user_func needs an instanciated object which I can't
> provide as what I really want to do is use a method from a class, not from
> an instanciated object. (not sure it's clearer ?)

It's as clear as the first try, still, it does not need an instantiated 
object. but just a classname, see this example:



(prints 'foo')

> And keep an access to $this from inside the object calling the external
> method because my parsing is actually recursive.

$this only works for instanciated classes, not static method calls.

Derick
-- 

-
 Derick Rethans http://derickrethans.nl/ 
 PHP Magazine - PHP Magazine for Professionals   http://php-mag.net/
-


-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] T_PAAMAYIM_NEKUDOTAYIM

2002-12-16 Thread Bertrand Mansion
<[EMAIL PROTECTED]> wrote :

> On Mon, 16 Dec 2002, Bertrand Mansion wrote:
> 
>> <[EMAIL PROTECTED]> wrote :
>> 
>>> Its neither, its a fact of the language, the following:
>>> 
>>> $classname::method is illegal, you recieved a parse error to that
>>> effect.  the best thing to do is::
>> 
>> I don't understand why it is illegal...
> 
> It's just not supported by PHP.

Will it be supported ?
This would allow
>> 
>>> call_user_func(array($className, 'method'), $param1, $param2);
>> 
>> This won't work because, in my case, I don't want to make an instance of
>> $className but rather use $className methods as if they were plugged inside
>> my main object.
> 
> This doesn't make an instance at all.

Sorry, I didn't choose the right way to explain. :)

I meant that call_user_func needs an instanciated object which I can't
provide as what I really want to do is use a method from a class, not from
an instanciated object. (not sure it's clearer ?)
And keep an access to $this from inside the object calling the external
method because my parsing is actually recursive.

For an example of my current code, you can have a look at Container.php in
the Config package of PEAR (in CVS only). I am having hard time to figure
out what would be the best way to implement this in PHP.

Bertrand Mansion
Mamasam





--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] T_PAAMAYIM_NEKUDOTAYIM

2002-12-16 Thread Derick Rethans
On Mon, 16 Dec 2002, Bertrand Mansion wrote:

> <[EMAIL PROTECTED]> wrote :
> 
> > Its neither, its a fact of the language, the following:
> > 
> > $classname::method is illegal, you recieved a parse error to that
> > effect.  the best thing to do is::
> 
> I don't understand why it is illegal...

It's just not supported by PHP.

> 
> > call_user_func(array($className, 'method'), $param1, $param2);
> 
> This won't work because, in my case, I don't want to make an instance of
> $className but rather use $className methods as if they were plugged inside
> my main object.

This doesn't make an instance at all.

Derick

-- 

-
 Derick Rethans http://derickrethans.nl/ 
 PHP Magazine - PHP Magazine for Professionals   http://php-mag.net/
-


-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] T_PAAMAYIM_NEKUDOTAYIM

2002-12-16 Thread Bertrand Mansion
<[EMAIL PROTECTED]> wrote :

>> Hi,
>> 
>> Tell me if this is the wrong list to ask or if this has been answered
>> somewhere else before. Thanks :)
>> 
>> I am trying to make something like that:
>> 
>> $myClassName = 'MyClass';
>> return $myClassName::myMethod($param1, $param2);
>> 
>> And I get :
>> 
>> Parse error: parse error, unexpected T_PAAMAYIM_NEKUDOTAYIM
>> 
>> I found a way to get around this by using:
>> 
>> return eval(("return $myClassName:: myMethod('$param1', '$param2');");
>> 
>> This works except when one of the parameters is an array.
>> 
>> What is this ?
>> Is it a bug or a feature and will it change in ZE2 ?
>> Is there another way to get around this to let it accept arrays ?
>> 
> 
> Its neither, its a fact of the language, the following:
> 
> $classname::method is illegal, you recieved a parse error to that
> effect.  the best thing to do is::

I don't understand why it is illegal...

> call_user_func(array($className, 'method'), $param1, $param2);

This won't work because, in my case, I don't want to make an instance of
$className but rather use $className methods as if they were plugged inside
my main object.

To explain my problem:

I have a container object which is standardized and has a few get/set
methods as well as addChild, getParent and so on. This can be considered
like my MODEL.

My MODEL is created using different datasources in different formats. For
each of these formats, I have created a parser. I want to be able to call
this parser method from inside my MODEL and have it dynamically constructed
that way.

And because the parsing is often recursive, I need to be able to have a
reference to $this all the time, from the parsing method.

This is the reason why I used :: which allows to dynamically extend the
functionalities of my MODEL object while allowing it to access $this. This
was working very well (with eval), up to the point where I needed arrays
passed as parameters.

Now I wonder if there are some other ways or if the behaviour of :: for this
kind of plugin behaviour can be changed.

Thanks,

Bertrand Mansion
Mamasam



--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] T_PAAMAYIM_NEKUDOTAYIM

2002-12-16 Thread Attila Strauss
Bertrand Mansion wrote:

hi bertrand,

php-general would be the right list.

call_user_func_array();
http://www.php.net/call_user_func_array
is what you are looking for.

bye
attila


--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] T_PAAMAYIM_NEKUDOTAYIM

2002-12-16 Thread Sterling Hughes
> Hi,
> 
> Tell me if this is the wrong list to ask or if this has been answered
> somewhere else before. Thanks :)
> 
> I am trying to make something like that:
> 
> $myClassName = 'MyClass';
> return $myClassName::myMethod($param1, $param2);
> 
> And I get :
> 
> Parse error: parse error, unexpected T_PAAMAYIM_NEKUDOTAYIM
> 
> I found a way to get around this by using:
> 
> return eval(("return $myClassName:: myMethod('$param1', '$param2');");
> 
> This works except when one of the parameters is an array.
> 
> What is this ?
> Is it a bug or a feature and will it change in ZE2 ?
> Is there another way to get around this to let it accept arrays ?
> 

Its neither, its a fact of the language, the following:

$classname::method is illegal, you recieved a parse error to that 
effect.  the best thing to do is::

call_user_func(array($className, 'method'), $param1, $param2);

-Sterling

> TIA,
> 
> Bertrand Mansion
> Mamasam
> 
> 
> -- 
> PHP Development Mailing List 
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] T_PAAMAYIM_NEKUDOTAYIM

2002-12-16 Thread Bertrand Mansion
Hi,

Tell me if this is the wrong list to ask or if this has been answered
somewhere else before. Thanks :)

I am trying to make something like that:

$myClassName = 'MyClass';
return $myClassName::myMethod($param1, $param2);

And I get :

Parse error: parse error, unexpected T_PAAMAYIM_NEKUDOTAYIM

I found a way to get around this by using:

return eval(("return $myClassName:: myMethod('$param1', '$param2');");

This works except when one of the parameters is an array.

What is this ?
Is it a bug or a feature and will it change in ZE2 ?
Is there another way to get around this to let it accept arrays ?

TIA,

Bertrand Mansion
Mamasam


-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php