You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.
// does not worknamespaceProject;
abstractclass Config
{
protected$config = array();
publicfunctiongetConfig()
{
return$this->config;
}
abstractpublicfunctiongetKey();
}
and the following code:
$scanner = new \Zend\Code\Scanner\DirectoryScanner('Project');
$method = $scanner->getClasses()[0]->getMethod('getKey');
var_dump($method->isAbstract());
Calling $method->isAbstract() results in "Fatal error: Uncaught exception 'Zend\Code\Exception\RuntimeException' with message 'No tokens were provided'".
This case is only when class has any property or method along with an abstract method. For example, if I remove "getConfig()" method and $config property - the code provided works fine.
The text was updated successfully, but these errors were encountered:
alex-oleshkevich
changed the title
Zend\Code\ClassScanner cannot scan abstract method.
Zend\Code\ClassScanner cannot scan abstract method when class has properties and other methods.
Nov 18, 2014
@alex-oleshkevich Looking at the cause of the problem right now, it would seam the Zend\Code\Scanner\ClassScanner is failing to produce the end token for the method tokens segment.
@alex-oleshkevich a temporary workaround until this is resolved is to not have the abstract methods last. Because that is when the parser seams to be freaking out.
<?php// Works just fineabstractclass AbstractClass
{
protected$config = array();
abstractpublicfunctionhelloWorld();
publicfunctiongetConfig()
{
return$this->config;
}
}
I have a class:
and the following code:
Calling $method->isAbstract() results in "
Fatal error: Uncaught exception 'Zend\Code\Exception\RuntimeException' with message 'No tokens were provided'
".This case is only when class has any property or method along with an abstract method. For example, if I remove "getConfig()" method and $config property - the code provided works fine.
I found a closed issue #2471 but the bug still exists in zf2.3.3 or dev-master.
demo: https://github.com/alex-oleshkevich/zend-class-scanner-bug
The text was updated successfully, but these errors were encountered: