php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69754 Use of ::class inside array causes fatal error.
Submitted: 2015-06-03 21:17 UTC Modified: 2015-06-03 21:17 UTC
From: salathe@php.net Assigned: bwoebi (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: master-Git-2015-06-03 (Git) OS:
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: salathe@php.net
New email:
PHP Version: OS:

 

 [2015-06-03 21:17 UTC] salathe@php.net
Description:
------------
Using ::class within an array appears to mistakenly cause a fatal error.

Looks to have been introduced by http://git.php.net/?p=php-src.git;a=commitdiff;h=69b54ba926b714dff0f8b54bea385e9a278c5849

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

class Example
{
    public function test()
    {
        $me = static::class; // OK
        $not_me = static::class . 'IsAwesome'; // OK
        $day_me = static::class . date('Ymd'); // OK
        $array_me = [static::class]; // BOOM
    }
}

?>

Expected result:
----------------
No output, no errors.

Actual result:
--------------
Fatal error: static::class cannot be used for compile-time class name resolution in /in/PMShY on line 10

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-06-03 21:17 UTC] salathe@php.net
-Assigned To: +Assigned To: bwoebi
 [2015-06-03 22:00 UTC] bwoebi@php.net
Automatic comment on behalf of bobwei9@hotmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=1d3f77d13d2b457bdf1bc52045da4679741e65cb
Log: Fix Bug #69754 (Compile failure with ::class in array)
 [2015-06-03 22:00 UTC] bwoebi@php.net
-Status: Assigned +Status: Closed
 [2016-07-20 11:38 UTC] davey@php.net
Automatic comment on behalf of bobwei9@hotmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=1d3f77d13d2b457bdf1bc52045da4679741e65cb
Log: Fix Bug #69754 (Compile failure with ::class in array)
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 17:01:33 2025 UTC