Categories > TinyButStrong general >

Objects, public Properties and static Functions

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Sven Jansen
Date: 2007-03-26
Time: 15:41

Objects, public Properties and static Functions

I've postet some time ago this Thread: http://www.tinybutstrong.com/forum.php?msg_id=6024#

Now I found another interesting problem. If one object has a public property named "Position" AND also a static function named "Position" TBS calls on merging e.g. [var.~Position] the static function instead of the public property.

Ok, maybe it isn't a good idea to have a public property and a static function with the same name, but I named it like that :)

It would be great when TBS returns the public property and NOT the static function, but I think this would be complicated, because the used function for determining if a function exists is the PHP function "method_exists", which can't differ between public, private, protected and static functions.

So as a hint for everyone with the same problem, think about the naming conventing for your functions :)
By: Sven Jansen
Date: 2007-03-26
Time: 15:43

Re: Objects, public Properties and static Functions

sorry...naming convention.... I hope everyone understands what I wanna say... *g*
By: Skrol29
Date: 2007-03-26
Time: 20:55

Re: Objects, public Properties and static Functions

Did you tried [var.~Position()] ?
No yet tested, bu it could maybe work.

> It would be great when TBS returns the public property
> and NOT the static function,

Why one is better than the other ?

By: Sven Jansen
Date: 2007-03-27
Time: 19:26

Re: Objects, public Properties and static Functions

I think your question is a rhetorical one, but I will answer yet.

I think it would be better to get the public property first. Normally you have an object when your using [var.~XYZ]. I don't think that static functions are the first target for calls with [var.~XYZ]. So it's primary a question of TBS philosophy :)

The problem with php is you can't overload methods, but you can have a property "public $Position;" AND a static function "static function Position($Var1, $Var2) {}". With TBS you're only checking if there's a method, without investigating if there are arguments. This works without problems, but with this little example TBS don't really know what to do :)

Maybe you can built in a "config" which lets the developer decide which sequence the [var.~XYZ] call will have, eg. SEQUENCE = array('property','method','static');

Did I say that I really admire your work? TBS is great :)
By: Skrol29
Date: 2007-03-30
Time: 11:35

Re: Objects, public Properties and static Functions

Hi,

Giving the choice of the order with a property would be the more smart solution. But for TBS I think it would be an extra property for such a specific feature.
Refering to the perperty first, and allow to referer to the method using parentheses is ok I think. I'll check in order to add it in next version.