fixed phpdoc controller to not crash on non-instantiable classes

this happens with codeception classes that are auto generated, they
shoud not be changed by phpdoc controller anyway.
This commit is contained in:
Carsten Brandt
2016-10-20 14:39:57 +02:00
parent 2233d75927
commit dc7c3779a0

View File

@ -479,9 +479,15 @@ class PhpDocController extends Controller
protected function updateClassPropertyDocs($file, $className, $propertyDoc) protected function updateClassPropertyDocs($file, $className, $propertyDoc)
{ {
try {
$ref = new \ReflectionClass($className); $ref = new \ReflectionClass($className);
} catch (\Exception $e) {
$this->stderr("[ERR] Unable to create ReflectionClass for class '$className': " . $e->getMessage() . "\n", Console::FG_RED);
return false;
}
if ($ref->getFileName() != $file) { if ($ref->getFileName() != $file) {
$this->stderr("[ERR] Unable to create ReflectionClass for class: $className loaded class is not from file: $file\n", Console::FG_RED); $this->stderr("[ERR] Unable to create ReflectionClass for class: $className loaded class is not from file: $file\n", Console::FG_RED);
return false;
} }
if (!$ref->isSubclassOf('yii\base\Object') && $className != 'yii\base\Object') { if (!$ref->isSubclassOf('yii\base\Object') && $className != 'yii\base\Object') {