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
 [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-2018 The PHP Group
All rights reserved.
Last updated: Fri Nov 16 11:01:25 2018 UTC