Req #71654 [Com]: $class instanceof myClass::class lead a parse error
| From: | contact at geolim4 dot com | Date: | Sun, 28 Feb 2016 00:25:58 +0000 |
| Subject: | Req #71654 [Com]: $class instanceof myClass::class lead a parse error | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-199506@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=71654&edit=1
ID: 71654
Comment by: contact at geolim4 dot com
Reported by: contact at geolim4 dot com
Summary: $class instanceof myClass::class lead a parse error
Status: Open
Type: Feature/Change Request
Package: Scripting Engine problem
Operating System: Debian/Wheezy
PHP Version: 7.0.4RC1
Block user comment: N
Private report: N
New Comment:
Does a patch is planned for this one ?
Previous Comments:
------------------------------------------------------------------------
[2016-02-23 19:12:16] contact at geolim4 dot com
My bad it's the working sample that i posted, here is the buggy sample:
Test script:
---------------
<?php
foreach(get_declared_classes() as $class) {
if($class instanceof AnExistingInterface::class){
$class::myImplementedMethod();
}
}
------------------------------------------------------------------------
[2016-02-23 19:10:41] contact at geolim4 dot com
Description:
------------
It seems that the lexer did not recognize a certain syntax with instanceof and ::class suffix.
Test script:
---------------
<?php
$interface = AnExistingInterface::class;// The behaviour is the same with a class
foreach(get_declared_classes() as $class) {
if($class instanceof $interface){
$class::myImplementedMethod();
}
}
Expected result:
----------------
No parse error
Actual result:
--------------
ParseError: syntax error, unexpected 'class' (T_CLASS), expecting variable (T_VARIABLE) or
'$' in absolute/path/to/that/file.php on line xxx
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=71654&edit=1