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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
26 - 4 = ?
Subscribe to this entry?

 
 [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-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 01:01:30 2024 UTC