Commit 193bc501 by Carsten Brandt

added interface methods to abstract classes

parent 26218953
......@@ -11,6 +11,7 @@ use phpDocumentor\Reflection\FileReflector;
use TokenReflection\ReflectionFile;
use yii\apidoc\templates\BaseRenderer;
use yii\console\Controller;
use yii\helpers\ArrayHelper;
use yii\helpers\Console;
use yii\helpers\FileHelper;
use yii\apidoc\components\OfflineRenderer;
......@@ -105,6 +106,7 @@ class RenderController extends Controller
// render models
$renderer->renderApi($context, $this);
ArrayHelper::multisort($context->errors, 'file');
print_r($context->errors);
// render guide if specified
......
......@@ -22,6 +22,9 @@ class ClassDoc extends TypeDoc
public $isAbstract;
public $isFinal;
/**
* @var string[]
*/
public $interfaces = [];
public $traits = [];
// will be set by Context::updateReferences()
......
......@@ -88,11 +88,6 @@ class Context extends Component
}
// update implementedBy and usedBy for interfaces and traits
foreach($this->classes as $class) {
foreach($class->interfaces as $interface) {
if (isset($this->interfaces[$interface])) {
$this->interfaces[$interface]->implementedBy[] = $class->name;
}
}
foreach($class->traits as $trait) {
if (isset($this->traits[$trait])) {
$trait = $this->traits[$trait];
......@@ -101,6 +96,19 @@ class Context extends Component
$class->methods = array_merge($trait->methods, $class->methods);
}
}
foreach($class->interfaces as $interface) {
if (isset($this->interfaces[$interface])) {
$this->interfaces[$interface]->implementedBy[] = $class->name;
if ($class->isAbstract) {
// add not implemented interface methods
foreach($this->interfaces[$interface]->methods as $method) {
if (!isset($class->methods[$method->name])) {
$class->methods[$method->name] = $method;
}
}
}
}
}
}
// inherit properties, methods, contants and events to subclasses
foreach($this->classes as $class) {
......@@ -145,7 +153,7 @@ class Context extends Component
}
/**
* Add properties for getters and setters if class is subclass of [[yii\base\Object]].
* Add properties for getters and setters if class is subclass of [[\yii\base\Object]].
* @param ClassDoc $class
*/
protected function handlePropertyFeature($class)
......
......@@ -37,6 +37,10 @@ class InterfaceDoc extends TypeDoc
$this->parentInterfaces[] = ltrim($interface, '\\');
}
foreach($this->methods as $method) {
$method->isAbstract = true;
}
// interface can not have properties
$this->properties = null;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment