Req #71654 [Opn->Csd]: $class instanceof myClass::class lead a parse error

From: Date: Tue, 22 Mar 2016 19:34:48 +0000
Subject: Req #71654 [Opn->Csd]: $class instanceof myClass::class lead a parse error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-200042@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
+Status:             Closed
 Type:               Feature/Change Request
 Package:            Scripting Engine problem
 Operating System:   Debian/Wheezy
 PHP Version:        7.0.4RC1
 Block user comment: N
 Private report:     N

 New Comment:

Will probably never get fixed :(


Previous Comments:
------------------------------------------------------------------------
[2016-02-28 00:25:58] contact at geolim4 dot com

Does a patch is planned for this one ?

------------------------------------------------------------------------
[2016-02-23 19:12:16] 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 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 (#200042) next »