Bug #71654 [Opn]: $class instanceof myClass::class lead a parse error

From: Date: Tue, 23 Feb 2016 19:12:17 +0000
Subject: Bug #71654 [Opn]: $class instanceof myClass::class lead a parse error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-199429@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
 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)

« previous php.bugs (#199429) next »