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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2022 The PHP Group
All rights reserved.
Last updated: Sat May 28 05:09:35 2022 UTC