Req #76083 [Opn->Nab]: Add an ::interface magic constant similar to ::class

[email protected] Mon, 12 Mar 2018 16:13:22 GMT
Newsgroups php.standards
Message-ID <[email protected]>
Edit report at https://bugs.php.net/bug.php?id=76083&edit=1

 ID:                 76083
 Updated by:         [email protected]
 Reported by:        tpenepete at gmail dot com
 Summary:            Add an ::interface magic constant similar to ::class
-Status:             Open
+Status:             Not a bug
 Type:               Feature/Change Request
 Package:            PHP Language Specification
 Operating System:   All
 PHP Version:        7.2.3
 Block user comment: N
 Private report:     N

 New Comment:

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


Previous Comments:
------------------------------------------------------------------------
[2018-03-12 16:07:10] 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


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=76083&edit=1