php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64113 $this overriding
Submitted: 2013-01-31 12:25 UTC Modified: 2013-01-31 14:18 UTC
From: pavelpat at ya dot ru Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.4.11 OS: Linux 3.5.0 x64
Private report: No CVE-ID: None
 [2013-01-31 12:25 UTC] pavelpat at ya dot ru
Description:
------------
In any context impossible to override $this, so this code is incorrect:

$this = 123;

But possible to rewrite $this with this example:

$t = 'this';
$$t = 123;
var_dump($this); // int(123)

Test script:
---------------
$t = 'this';
$$t = 123;
var_dump($this); // int(123)

Expected result:
----------------
Runtime error

Actual result:
--------------
No runtime error

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-01-31 14:18 UTC] johannes@php.net
-Status: Open +Status: Not a bug
 [2013-01-31 14:18 UTC] johannes@php.net
We try to prevent mistakes. We don't prevent you from shooting in your foot. Adding the check to all potential cases would cause notable slowdowns.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 09:01:29 2024 UTC