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
 [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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 06:01:30 2024 UTC