Commit 193bc501 by Carsten Brandt

added interface methods to abstract classes

parent 26218953
...@@ -11,6 +11,7 @@ use phpDocumentor\Reflection\FileReflector; ...@@ -11,6 +11,7 @@ use phpDocumentor\Reflection\FileReflector;
use TokenReflection\ReflectionFile; use TokenReflection\ReflectionFile;
use yii\apidoc\templates\BaseRenderer; use yii\apidoc\templates\BaseRenderer;
use yii\console\Controller; use yii\console\Controller;
use yii\helpers\ArrayHelper;
use yii\helpers\Console; use yii\helpers\Console;
use yii\helpers\FileHelper; use yii\helpers\FileHelper;
use yii\apidoc\components\OfflineRenderer; use yii\apidoc\components\OfflineRenderer;
...@@ -105,6 +106,7 @@ class RenderController extends Controller ...@@ -105,6 +106,7 @@ class RenderController extends Controller
// render models // render models
$renderer->renderApi($context, $this); $renderer->renderApi($context, $this);
ArrayHelper::multisort($context->errors, 'file');
print_r($context->errors); print_r($context->errors);
// render guide if specified // render guide if specified
......
...@@ -22,6 +22,9 @@ class ClassDoc extends TypeDoc ...@@ -22,6 +22,9 @@ class ClassDoc extends TypeDoc
public $isAbstract; public $isAbstract;
public $isFinal; public $isFinal;
/**
* @var string[]
*/
public $interfaces = []; public $interfaces = [];
public $traits = []; public $traits = [];
// will be set by Context::updateReferences() // will be set by Context::updateReferences()
......
...@@ -88,11 +88,6 @@ class Context extends Component ...@@ -88,11 +88,6 @@ class Context extends Component
} }
// update implementedBy and usedBy for interfaces and traits // update implementedBy and usedBy for interfaces and traits
foreach($this->classes as $class) { 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) { foreach($class->traits as $trait) {
if (isset($this->traits[$trait])) { if (isset($this->traits[$trait])) {
$trait = $this->traits[$trait]; $trait = $this->traits[$trait];
...@@ -101,6 +96,19 @@ class Context extends Component ...@@ -101,6 +96,19 @@ class Context extends Component
$class->methods = array_merge($trait->methods, $class->methods); $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 // inherit properties, methods, contants and events to subclasses
foreach($this->classes as $class) { foreach($this->classes as $class) {
...@@ -145,7 +153,7 @@ class Context extends Component ...@@ -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 * @param ClassDoc $class
*/ */
protected function handlePropertyFeature($class) protected function handlePropertyFeature($class)
......
...@@ -37,6 +37,10 @@ class InterfaceDoc extends TypeDoc ...@@ -37,6 +37,10 @@ class InterfaceDoc extends TypeDoc
$this->parentInterfaces[] = ltrim($interface, '\\'); $this->parentInterfaces[] = ltrim($interface, '\\');
} }
foreach($this->methods as $method) {
$method->isAbstract = true;
}
// interface can not have properties // interface can not have properties
$this->properties = null; $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