php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79069 Property name concatenation triggers deprecated warning
Submitted: 2020-01-06 10:13 UTC Modified: 2020-01-06 10:21 UTC
From: gwendal dot ledoussal at jymeo dot net Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 7.4.1 OS: MacOS
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: gwendal dot ledoussal at jymeo dot net
New email:
PHP Version: OS:

 

 [2020-01-06 10:13 UTC] gwendal dot ledoussal at jymeo dot net
Description:
------------
PHP 7.4 deprecated array and string offset access with curly braces but it also affect property name concatenation.

Test script:
---------------
<?php

class Foo {
  public function __construct() {
    $bar = "bar";
    $this->{'foo_' . $bar} = true; // Works
    $this->foo_{$bar} = true; // Triggers Array and string offset access syntax with curly braces is deprecated
  } 
}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-01-06 10:20 UTC] bugreports at gmail dot com
$this->{"foo_{$bar}"} = true;
 [2020-01-06 10:21 UTC] nikic@php.net
-Status: Open +Status: Not a bug
 [2020-01-06 10:21 UTC] nikic@php.net
$this->foo_{$bar} is an array access, as the deprecation warning correctly indicates. It does not concatenate property names.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue May 20 08:01:30 2025 UTC