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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Mon May 06 06:01:31 2024 UTC