Bug #74222 [Opn->Nab]: $this value can be overwritten with a variable variable.
| From: | pollita@php.net | Date: | Wed, 08 Mar 2017 04:47:22 +0000 |
| Subject: | Bug #74222 [Opn->Nab]: $this value can be overwritten with a variable variable. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-207737@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74222&edit=1
ID: 74222
Updated by: pollita@php.net
Reported by: marco dot agnoli at me dot com
Summary: $this value can be overwritten with a variable
variable.
-Status: Open
+Status: Not a bug
Type: Bug
Package: *General Issues
Operating System: OS X
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
PHP version *is* relevant. So is trying to reassign $this is a context where it matters.
See: https://3v4l.org/MpDOn
Previous Comments:
------------------------------------------------------------------------
[2017-03-08 03:56:06] marco dot agnoli at me dot com
Description:
------------
I don't know whether that's intentional behavior or not but the $this value can be
overwritten with a variable variable (see test code below).
Test script:
---------------
<?php
$var = 'this';
$$var = 10;
echo $this; // Echos 10
// Generates a fatal error
$this = 10;
Expected result:
----------------
A PHP Fatal error message.
Actual result:
--------------
$this gets silently overwritten.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74222&edit=1