php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38317 "cannot reassign $this" outside object scope
Submitted: 2006-08-03 17:03 UTC Modified: 2006-08-04 07:48 UTC
From: giunta dot gaetano at sea-aeroportimilano dot it Assigned:
Status: Wont fix Package: Scripting Engine problem
PHP Version: 5.1.4 OS: windows 2000
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: giunta dot gaetano at sea-aeroportimilano dot it
New email:
PHP Version: OS:

 

 [2006-08-03 17:03 UTC] giunta dot gaetano at sea-aeroportimilano dot it
Description:
------------
It seems like php 5.1.4 does not like an assignment to variable '$this', regardless of the scope:
- objet method
- function
- global

Is this a real necessity or just a plain old bug???

Reproduce code:
---------------
<?php
function that($it){
    $this = '';
}
?>

or

<?php
    $this = '';
?>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-08-03 17:27 UTC] tony2001@php.net
This is a real necessity, since you can do <?php class test { function foo () { include "test.php"; }} ?> and reassign $this in test.php.
 [2006-08-04 07:48 UTC] giunta dot gaetano at sea-aeroportimilano dot it
That's just what I was afraid of (hence my asking for it).

I hoped that the engine would be smarter than that, and figure out the error 'just in time', ie. checking out the scope when finding the assignment and only flagging it as error when inside a class method...

BTW: maybe it should be marked mopre clearly in the manual?
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 17:01:31 2024 UTC