php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71193 old bug has reappeared
Submitted: 2015-12-22 05:00 UTC Modified: 2015-12-22 05:47 UTC
From: iam4webwork at hotmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 7.0.1 OS: n/a
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: iam4webwork at hotmail dot com
New email:
PHP Version: OS:

 

 [2015-12-22 05:00 UTC] iam4webwork at hotmail dot com
Description:
------------
Cannot statically call a method if its name is in an array.  Last time this was an issue was apparently back in 2004 (see bug #27669).  This bug effects PHP versions 7.0.0alpha2 - 7.0.1, 7.1@2015-11 (see https://3v4l.org/8MTtD)

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

class A {
   static function hello(){
      echo "Hello World\n";
   }
}

$x = 'hello';
$y[0] = 'hello';

A::$x();
A::$y[0]();

Expected result:
----------------
Hello World
Hello World

Actual result:
--------------
Hello World

Fatal error: Uncaught Error: Access to undeclared static property: A::$y in /in/8MTtD:11
Stack trace:
#0 {main}
  thrown in /in/8MTtD on line 11

Process exited with code 255.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-12-22 05:47 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2015-12-22 05:47 UTC] requinix@php.net
PHP 7 changed how expressions like those are evaluated.
https://wiki.php.net/rfc/uniform_variable_syntax

Use A::{$y[0]}()
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 13:00:02 2026 UTC