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
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:
39 + 14 = ?
Subscribe to this entry?

 
 [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 16:01:31 2024 UTC