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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: Jim dot Moores at quickstone dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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: Thu Dec 26 11:01:30 2024 UTC