php.net |  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
Votes:2
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: contact at geolim4 dot com
New email:
PHP Version: OS:

 

 [2016-02-23 19:10 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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:
---------------
<?php

foreach(get_declared_classes() as $class) {
	if($class instanceof AnExistingInterface::class){
		$class::myImplementedMethod();
	}
}
 [2016-02-23 20:37 UTC] requinix@php.net
-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-2020 The PHP Group
All rights reserved.
Last updated: Tue Jan 28 20:01:25 2020 UTC