php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39681 this assignment outside class breaks static function call (PHP4 only)
Submitted: 2006-11-29 11:55 UTC Modified: 2007-11-25 10:31 UTC
From: mail at jorgenhorstink dot nl Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 4.4.4 OS: FreeBSD
Private report: No CVE-ID: None
 [2006-11-29 11:55 UTC] mail at jorgenhorstink dot nl
Description:
------------
The code below shows the issue.

Reproduce code:
---------------
<?php

$this->bug = 'PHP Should not allow assignment of $this properties when used outside a class';


class A
{
  function B() {
  }
}

A::B();

?>

Expected result:
----------------
The engine should throw an error because setting a property on the $this object is senseless.

Actual result:
--------------
Warning: Problem with method call - please report this bug in xxx.php on line xx

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-11-23 00:58 UTC] felipe@php.net
In PHP 5.3:
Fatal error: Using $this when not in object context
 [2007-11-25 10:31 UTC] derick@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.

Can't reproduce this in 4.4.7 or any version after that.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Jul 05 22:01:31 2024 UTC