Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
adb28dee
Commit
adb28dee
authored
Mar 07, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added support for basic `@inheritDoc` tags
parent
31a1eca5
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
0 deletions
+43
-0
Context.php
extensions/apidoc/models/Context.php
+43
-0
No files found.
extensions/apidoc/models/Context.php
View file @
adb28dee
...
@@ -109,6 +109,10 @@ class Context extends Component
...
@@ -109,6 +109,10 @@ class Context extends Component
}
}
}
}
}
}
// inherit docs
foreach
(
$this
->
classes
as
$class
)
{
$this
->
inheritDocs
(
$class
);
}
// 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
)
{
$this
->
updateSubclassInheritance
(
$class
);
$this
->
updateSubclassInheritance
(
$class
);
...
@@ -152,6 +156,45 @@ class Context extends Component
...
@@ -152,6 +156,45 @@ class Context extends Component
}
}
/**
/**
* Inhertit docsblocks using `@inheritDoc` tag.
* @param ClassDoc $class
* @see http://phpdoc.org/docs/latest/guides/inheritance.html
*/
protected
function
inheritDocs
(
$class
)
{
// TODO also for properties?
foreach
(
$class
->
methods
as
$m
)
{
$inheritedMethod
=
$this
->
inheritMethodRecursive
(
$m
,
$class
);
foreach
([
'shortDescription'
,
'description'
,
'params'
,
'return'
,
'returnType'
,
'returnTypes'
,
'exceptions'
]
as
$property
)
{
if
(
empty
(
$m
->
$property
))
{
$m
->
$property
=
$inheritedMethod
->
$property
;
}
}
}
}
/**
* @param MethodDoc $method
* @param ClassDoc $parent
*/
private
function
inheritMethodRecursive
(
$method
,
$class
)
{
if
(
!
isset
(
$this
->
classes
[
$class
->
parentClass
]))
{
return
$method
;
}
$parent
=
$this
->
classes
[
$class
->
parentClass
];
foreach
(
$method
->
tags
as
$tag
)
{
if
(
strtolower
(
$tag
->
getName
())
==
'inheritdoc'
||
strtolower
(
$tag
->
getName
())
==
'inheritdocs'
)
{
if
(
isset
(
$parent
->
methods
[
$method
->
name
]))
{
$method
=
$parent
->
methods
[
$method
->
name
];
}
return
$this
->
inheritMethodRecursive
(
$method
,
$parent
);
}
}
return
$method
;
}
/**
* 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
*/
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment