Bug #74222 [Nab]: $this value can be overwritten with a variable variable.
| From: | marco dot agnoli at me dot com | Date: | Wed, 08 Mar 2017 04:54:04 +0000 |
| Subject: | Bug #74222 [Nab]: $this value can be overwritten with a variable variable. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-207739@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
User updated by: marco dot agnoli at me dot com
Reported by: marco dot agnoli at me dot com
Summary: $this value can be overwritten with a variable
variable.
Status: Not a bug
Type: Bug
Package: *General Issues
Operating System: OS X
-PHP Version: Irrelevant
+PHP Version: PHP 7.0.x & PHP 5.x
Block user comment: N
Private report: N
New Comment:
Updated affected PHP versions.
Previous Comments:
------------------------------------------------------------------------
[2017-03-08 04:51:58] marco dot agnoli at me dot com
Sorry, I tested it again and saw the following behavior:
PHP 7.1.x is not affected while PHP 5.6.x and PHP 7.0.x are.
------------------------------------------------------------------------
[2017-03-08 04:47:21] pollita@php.net
PHP version *is* relevant. So is trying to reassign $this is a context where it matters.
See: https://3v4l.org/MpDOn
------------------------------------------------------------------------
[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