|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 09:00:01 2025 UTC |
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(); } }