php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76853 ::class blindly returns whatever string precedes it, even if clas doesn't exist
Submitted: 2018-09-09 16:15 UTC Modified: 2018-09-09 16:22 UTC
From: teo8976 at gmail dot com Assigned:
Status: Duplicate Package: *General Issues
PHP Version: 7.3.0beta3 OS: all
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: teo8976 at gmail dot com
New email:
PHP Version: OS:

 

 [2018-09-09 16:15 UTC] teo8976 at gmail dot com
Description:
------------
see below

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

echo \skljnsdkf\olsjdnvsjd::class;

Expected result:
----------------
Fatal error: Uncaught Error: Class 'skljnsdkf\olsjdnvsjd' not found

Actual result:
--------------
outputs this:
   \skljnsdkf\olsjdnvsjd

as if the class existed.

Not only is this wrong, it is not even documented.


The documentation about "::class" is pathetic. It's not easy to find in the first place; all I could find is here:

http://be2.php.net/manual/en/language.oop5.constants.php

"""
The special ::class constant are [sic] available as of PHP 5.5.0, and allows for fully qualified class name resolution at compile [time??], this is useful for namespaced classes:
"""

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-09-09 16:22 UTC] peehaa@php.net
-Status: Open +Status: Duplicate
 [2018-09-09 16:22 UTC] peehaa@php.net
Dupe of #67973
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 10:01:31 2024 UTC