php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #76083 Add an ::interface magic constant similar to ::class
Submitted: 2018-03-12 16:07 UTC Modified: 2018-03-12 16:13 UTC
From: tpenepete at gmail dot com Assigned:
Status: Not a bug Package: PHP Language Specification
PHP Version: 7.2.3 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: tpenepete at gmail dot com
New email:
PHP Version: OS:

 

 [2018-03-12 16:07 UTC] tpenepete at gmail dot com
Description:
------------
---
From manual page:
http://www.php.net/language.oop5.interfaces
http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.class.class
---


Test script:
---------------
<?php
namespace Foo;

interface Bar
{

}

class SomeClass implements Bar
{

}

Expected result:
----------------
<?php
use Foo\Bar;
use Foo\SomeClass;

if(isset(class_implements(SomeClass::class)[Bar::interface]))) {
    echo 'Yupee!';
} else {
    echo 'Ugh :(';
}
?>

Expected output:
Yupee!

Actual result:
--------------
Undefined constant

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-03-12 16:13 UTC] daverandom@php.net
-Status: Open +Status: Not a bug
 [2018-03-12 16:13 UTC] daverandom@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

::class works fine with interfaces as well as classes https://3v4l.org/n6GIk
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 15:01:30 2024 UTC