|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #71654 $class instanceof myClass::class lead a parse error
Submitted: 2016-02-23 19:10 UTC Modified: 2016-03-22 19:34 UTC
Avg. Score:3.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:0 (0.0%)
From: contact at geolim4 dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 7.0.4RC1 OS: Debian/Wheezy
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.
Block user comment
Status: Assign to:
Bug Type:
From: contact at geolim4 dot com
New email:
PHP Version: OS:


 [2016-02-23 19:10 UTC] contact at geolim4 dot com
It seems that the lexer did not recognize a certain syntax with instanceof and ::class suffix.

Test script:

$interface = AnExistingInterface::class;// The behaviour is the same with a class
foreach(get_declared_classes() as $class) {
	if($class instanceof $interface){

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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-02-23 19:12 UTC] contact at geolim4 dot com
My bad it's the working sample that i posted, here is the buggy sample:
Test script:

foreach(get_declared_classes() as $class) {
	if($class instanceof AnExistingInterface::class){
 [2016-02-23 20:37 UTC]
-Type: Bug +Type: Feature/Change Request -Package: Compile Failure +Package: Scripting Engine problem
 [2016-02-28 00:25 UTC] contact at geolim4 dot com
Does a patch is planned for this one ?
 [2016-03-22 19:34 UTC] contact at geolim4 dot com
-Status: Open +Status: Closed
 [2016-03-22 19:34 UTC] contact at geolim4 dot com
Will probably never get fixed :(
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sun Sep 25 17:05:53 2022 UTC