Bug #71654 [Opn]: $class instanceof myClass::class lead a parse error
Edit report at https://bugs.php.net/bug.php?id=71654&edit=1
ID: 71654
User updated 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: Bug
Package: Compile Failure
Operating System: Debian/Wheezy
PHP Version: 7.0.4RC1
Block user comment: N
Private report: N
New Comment:
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();
}
}
Previous Comments:
------------------------------------------------------------------------
[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
Thread (4 messages)