# Static vs. non static

- Thread: https://externals.io/message/21635
- Original archive: https://news-web.php.net/php.internals/21635
- Started by Marcus Boerger on 2006-01-22T18:32:18+00:00
- Messages: 6
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #21635 — Marcus Boerger — 2006-01-22T18:32:18+00:00

URL: https://externals.io/message/21635#21635

Hello internals,

right now we allow 'class::method()' like syntax but not 'class->method()
like. If noone comes up with a valid reason why i am forced to call
a parents method using static syntax i'll commit the little required
change. We could even add an `E_STRICT` when the old syntax is used where
not applicable. But right now i don't see that message as neccessary
unless people want to disallow misuse of the old synatx any time later.


Best regards,
 Marcus

---

## #21637 — Andi Gutmans — 2006-01-23T03:00:25+00:00

URL: https://externals.io/message/21635#21637 · In reply to: #21635

Yes, this was by design. Via class it should be ::method() and via 
object it should be ->method().
Why do you think this is wrong? I think it actually makes a lot of 
sense and don't see what we gain from allowing to call 
self->method(). If there's a good reason, I'd be open to it though.
And please next time give people a chance to reply to your email, 
especially on a weekend, before commiting a patch. Why do you send an 
email if you don't want to hear an answer?

Andi

At 10:32 AM 1/22/2006, Marcus Boerger wrote:
>Hello internals,
>
>right now we allow 'class::method()' like syntax but not 'class->method()
>like. If noone comes up with a valid reason why i am forced to call
>a parents method using static syntax i'll commit the little required
>change. We could even add an `E_STRICT` when the old syntax is used where
>not applicable. But right now i don't see that message as neccessary
>unless people want to disallow misuse of the old synatx any time later.
>
>
>Best regards,
>  Marcus

---

## #21643 — Lukas Smith — 2006-01-23T08:08:11+00:00

URL: https://externals.io/message/21635#21643 · In reply to: #21637

Andi Gutmans wrote:
> Yes, this was by design. Via class it should be ::method() and via 
> object it should be ->method().
> Why do you think this is wrong? I think it actually makes a lot of sense 
> and don't see what we gain from allowing to call self->method(). If 
> there's a good reason, I'd be open to it though.

I just gave a course in PHP5 OOP and this syntax overlap with static 
calls that do not end up being static seems confusing.

If I get Marcus proposal properly he would then allow changing things from:

parent::method();

to

parent->method();

This would add a totally separate syntax, which would make it clear to 
users that this is in fact not a static call. It looks ugly, but I 
understand what he is aiming at.

regards,
Lukas

---

## #21644 — Sebastian Bergmann — 2006-01-23T08:25:29+00:00

URL: https://externals.io/message/21635#21644 · In reply to: #21643

Lukas Smith schrieb:
> If I get Marcus proposal properly he would then allow changing things 
> from:
> parent::method();
> 
> to
> 
> parent->method();

 If that is the case, then it would be consistent to allow

   this->method()
   this->attribute
   parent->attribute

 too, no? (Note that I am not advocating the above, I am just being
 curious about consistency issues.)

-- 
Sebastian Bergmann                      http://www.sebastian-bergmann.de/
GnuPG Key: 0xB85B5D69 / 27A7 2B14 09E4 98CD 6277 0E5B 6867 C514 B85B 5D69

---

## #21660 — Marcus Boerger — 2006-01-23T19:27:55+00:00

URL: https://externals.io/message/21635#21660 · In reply to: #21644

Hello Andi, Sebastian,

Monday, January 23, 2006, 9:25:29 AM, Sebastian wrote:

> Lukas Smith schrieb:
> > […]

>  If that is the case, then it would be consistent to allow

>    this->method()
>    this->attribute
>    parent->attribute

parent->method() would work
attributes are more than discussable and i don'T think we need anything
more than $this->attibute for dynamic attibutes. And since you cannot
overload protected or public attibutes or hide base class attibutes there
is no need to provide a means of skipping hierarchy levels.

If i was very pedantic i'd not propose 'baseclass->method()' but the
formal correct '$this->baseclass::method()'. However i see the former as
a very handy and clear shortcut. Another reason to go with the shortcut
is that once we'd allow '$this->baseclass::method()' people would start
to ask for '$obj->classname::method()' which is at somepoints usefull
but is not exactly the KISS approach.

Best regards,
 Marcus

---

## #21678 — Andi Gutmans — 2006-01-25T06:55:18+00:00

URL: https://externals.io/message/21635#21678 · In reply to: #21643

As you're using this in the context of the object, I don't think it's 
too confusing. I actually find the latter more confusing and think 
it's best to stick to what we have today.

Andi

At 12:08 AM 1/23/2006, Lukas Smith wrote:
>Andi Gutmans wrote:
> > […]
>
>I just gave a course in PHP5 OOP and this syntax overlap with static 
>calls that do not end up being static seems confusing.
>
>If I get Marcus proposal properly he would then allow changing things from:
>
>parent::method();
>
>to
>
>parent->method();
>
>This would add a totally separate syntax, which would make it clear 
>to users that this is in fact not a static call. It looks ugly, but 
>I understand what he is aiming at.
>
>regards,
>Lukas
