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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
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-2021 The PHP Group
All rights reserved.
Last updated: Mon Dec 06 03:03:34 2021 UTC