php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #4612 Too much of $this
Submitted: 2000-05-26 15:06 UTC Modified: 2004-06-14 10:53 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: Jim dot Moores at quickstone dot com Assigned:
Status: Wont fix Package: Feature/Change Request
PHP Version: 4.0.0 Release OS: All
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
48 - 43 = ?
Subscribe to this entry?

 
 [2000-05-26 15:06 UTC] Jim dot Moores at quickstone dot com
Could you consider making the class member namespace available to member functions?  I'm sick of typing: 

$this->foo()

for every variable that is a class member.  I did have a look at the code myself, but, as always with compilers, it's difficult to know where to start (and what the knock on effects of your changes will be).  So I thought I'd beg you guys.

Go on.  You know you want to. :)

Thanks for listening,

Jim Moores.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-05-26 17:31 UTC] Jim dot Moores at quickstone dot com
There are several options:

 1) When you come across an identifier you haven't seen before - see if it is already 
    declared as a symbol in the containing class and assume it refer's to that if it
    is.  This has the problem that it is not compatible with previous versions of PHP.

 2) Make it compulsary to declare local variables, then use the normal strategy, which
    is to treat as a local variable if one is declared, else treat as a class variable, 
    else treat as a global.  This is also not backwards compatible.

 3) Introduce a new keyword - similar in concept to global - that declares an
    identifier as refering to a member: the keyword `member' would be a good 
    candidate - this would also be backwards compatible.  The disadvantage of this
    scheme is that it'd be a pain (but probably not as much as $this).

 4) Introduce some sort of pragma indicating to the compiler that this function is
    aware that you are using strategy 1) or 2).  For example you could delcare
    functions:

       member function get_property($x) { ... }

    or come up with a replacement new keyword:

       method get_property($x) { ... }

    that has this different property - its better to declare variables anyway :)

I think option 4) is most desirable, and option 3) is the easiest to do.  I doubt you guys would even consider breaking compatibility.  Option 4 also gives you the option of introducing other OO things such as public/private/package if you like that sort of thing.  And you can still support all the legacy code.

 [2000-07-31 23:07 UTC] waldschrott@php.net
*If* PHP will be extended the way to improve OO and force
the OO coder who wants to use this to take care of more
things at compile time, then this will possibly included...
 [2004-06-14 10:53 UTC] magnus@php.net
This will not be changed.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 29 11:01:32 2024 UTC