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
2245a7e3
Commit
2245a7e3
authored
Jan 06, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
short array syntax
parent
82f7937a
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
66 additions
and
10 deletions
+66
-10
Markdown.php
extensions/yii/apidoc/helpers/Markdown.php
+8
-5
PrettyPrinter.php
extensions/yii/apidoc/helpers/PrettyPrinter.php
+42
-0
Context.php
extensions/yii/apidoc/models/Context.php
+2
-2
FunctionDoc.php
extensions/yii/apidoc/models/FunctionDoc.php
+2
-1
ParamDoc.php
extensions/yii/apidoc/models/ParamDoc.php
+7
-1
PropertyDoc.php
extensions/yii/apidoc/models/PropertyDoc.php
+5
-1
No files found.
extensions/yii/apidoc/helpers/Markdown.php
View file @
2245a7e3
<?php
<?php
/**
/**
*
*
@link http://www.yiiframework.com/
*
*
@copyright Copyright (c) 2008 Yii Software LLC
* @
author Carsten Brandt <mail@cebe.cc>
* @
license http://www.yiiframework.com/license/
*/
*/
namespace
yii\apidoc\helpers
;
namespace
yii\apidoc\helpers
;
use
phpDocumentor\Reflection\DocBlock\Type\Collection
;
use
phpDocumentor\Reflection\DocBlock\Type\Collection
;
use
yii\apidoc\models\MethodDoc
;
use
yii\apidoc\models\MethodDoc
;
use
yii\apidoc\models\TypeDoc
;
use
yii\apidoc\models\TypeDoc
;
use
yii\apidoc\templates\BaseRenderer
;
use
yii\apidoc\templates\BaseRenderer
;
use
yii\helpers\Html
;
/**
*
* @author Carsten Brandt <mail@cebe.cc>
* @since 2.0
*/
class
Markdown
extends
\yii\helpers\Markdown
class
Markdown
extends
\yii\helpers\Markdown
{
{
/**
/**
...
...
extensions/yii/apidoc/helpers/PrettyPrinter.php
0 → 100644
View file @
2245a7e3
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\apidoc\helpers
;
use
PHPParser_Node_Expr
;
use
PHPParser_Node_Expr_Array
;
/**
* Enhances the phpDocumentor PrettyPrinter with short array syntax
*
* @author Carsten Brandt <mail@cebe.cc>
* @since 2.0
*/
class
PrettyPrinter
extends
\phpDocumentor\Reflection\PrettyPrinter
{
public
function
pExpr_Array
(
PHPParser_Node_Expr_Array
$node
)
{
return
'['
.
$this
->
pCommaSeparated
(
$node
->
items
)
.
']'
;
}
/**
* Returns a simple human readable output for a value.
*
* @param PHPParser_Node_Expr $value The value node as provided by PHP-Parser.
* @return string
*/
public
static
function
getRepresentationOfValue
(
PHPParser_Node_Expr
$value
)
{
if
(
$value
===
null
)
{
return
''
;
}
$printer
=
new
static
();
return
$printer
->
prettyPrintExpr
(
$value
);
}
}
\ No newline at end of file
extensions/yii/apidoc/models/Context.php
View file @
2245a7e3
...
@@ -160,7 +160,7 @@ class Context extends Component
...
@@ -160,7 +160,7 @@ class Context extends Component
if
(
isset
(
$class
->
properties
[
$propertyName
]))
{
if
(
isset
(
$class
->
properties
[
$propertyName
]))
{
$property
=
$class
->
properties
[
$propertyName
];
$property
=
$class
->
properties
[
$propertyName
];
if
(
$property
->
getter
===
null
&&
$property
->
setter
===
null
)
{
if
(
$property
->
getter
===
null
&&
$property
->
setter
===
null
)
{
echo
"Property
$propertyName
conflicts with a defined getter
{
$method
->
name
}
in
{
$class
->
name
}
."
;
// TODO log these messages somewhere
echo
"Property
$propertyName
conflicts with a defined getter
{
$method
->
name
}
in
{
$class
->
name
}
.
\n
"
;
// TODO log these messages somewhere
}
}
$property
->
getter
=
$method
;
$property
->
getter
=
$method
;
}
else
{
}
else
{
...
@@ -184,7 +184,7 @@ class Context extends Component
...
@@ -184,7 +184,7 @@ class Context extends Component
if
(
isset
(
$class
->
properties
[
$propertyName
]))
{
if
(
isset
(
$class
->
properties
[
$propertyName
]))
{
$property
=
$class
->
properties
[
$propertyName
];
$property
=
$class
->
properties
[
$propertyName
];
if
(
$property
->
getter
===
null
&&
$property
->
setter
===
null
)
{
if
(
$property
->
getter
===
null
&&
$property
->
setter
===
null
)
{
echo
"Property
$propertyName
conflicts with a defined setter
{
$method
->
name
}
in
{
$class
->
name
}
."
;
// TODO log these messages somewhere
echo
"Property
$propertyName
conflicts with a defined setter
{
$method
->
name
}
in
{
$class
->
name
}
.
\n
"
;
// TODO log these messages somewhere
}
}
$property
->
setter
=
$method
;
$property
->
setter
=
$method
;
}
else
{
}
else
{
...
...
extensions/yii/apidoc/models/FunctionDoc.php
View file @
2245a7e3
...
@@ -58,7 +58,8 @@ class FunctionDoc extends BaseDoc
...
@@ -58,7 +58,8 @@ class FunctionDoc extends BaseDoc
}
elseif
(
$tag
instanceof
ParamTag
)
{
}
elseif
(
$tag
instanceof
ParamTag
)
{
$paramName
=
$tag
->
getVariableName
();
$paramName
=
$tag
->
getVariableName
();
if
(
!
isset
(
$this
->
params
[
$paramName
]))
{
if
(
!
isset
(
$this
->
params
[
$paramName
]))
{
echo
'undefined parameter documented: '
.
$paramName
.
' in '
.
$this
->
name
.
"
\n
"
;
// todo add this to a log file
echo
'undefined parameter documented: '
.
$paramName
.
' in '
.
$this
->
name
.
"()
\n
"
;
// TODO log these messages somewhere
continue
;
}
}
$this
->
params
[
$paramName
]
->
description
=
ucfirst
(
$tag
->
getDescription
());
$this
->
params
[
$paramName
]
->
description
=
ucfirst
(
$tag
->
getDescription
());
$this
->
params
[
$paramName
]
->
type
=
$tag
->
getType
();
$this
->
params
[
$paramName
]
->
type
=
$tag
->
getType
();
...
...
extensions/yii/apidoc/models/ParamDoc.php
View file @
2245a7e3
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
namespace
yii\apidoc\models
;
namespace
yii\apidoc\models
;
use
yii\apidoc\helpers\PrettyPrinter
;
use
yii\base\Object
;
use
yii\base\Object
;
/**
/**
...
@@ -42,7 +43,11 @@ class ParamDoc extends Object
...
@@ -42,7 +43,11 @@ class ParamDoc extends Object
$this
->
name
=
$reflector
->
getName
();
$this
->
name
=
$reflector
->
getName
();
$this
->
typeHint
=
$reflector
->
getType
();
$this
->
typeHint
=
$reflector
->
getType
();
$this
->
isOptional
=
$reflector
->
getDefault
()
!==
null
;
$this
->
isOptional
=
$reflector
->
getDefault
()
!==
null
;
$this
->
defaultValue
=
$reflector
->
getDefault
();
// bypass $reflector->getDefault() for short array syntax
if
(
$reflector
->
getNode
()
->
default
)
{
$this
->
defaultValue
=
PrettyPrinter
::
getRepresentationOfValue
(
$reflector
->
getNode
()
->
default
);
}
$this
->
isPassedByReference
=
$reflector
->
isByRef
();
$this
->
isPassedByReference
=
$reflector
->
isByRef
();
}
}
}
}
\ No newline at end of file
extensions/yii/apidoc/models/PropertyDoc.php
View file @
2245a7e3
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
namespace
yii\apidoc\models
;
namespace
yii\apidoc\models
;
use
phpDocumentor\Reflection\DocBlock\Tag\VarTag
;
use
phpDocumentor\Reflection\DocBlock\Tag\VarTag
;
use
yii\apidoc\helpers\PrettyPrinter
;
/**
/**
*
*
...
@@ -55,7 +56,10 @@ class PropertyDoc extends BaseDoc
...
@@ -55,7 +56,10 @@ class PropertyDoc extends BaseDoc
$this
->
visibility
=
$reflector
->
getVisibility
();
$this
->
visibility
=
$reflector
->
getVisibility
();
$this
->
isStatic
=
$reflector
->
isStatic
();
$this
->
isStatic
=
$reflector
->
isStatic
();
$this
->
defaultValue
=
$reflector
->
getDefault
();
// bypass $reflector->getDefault() for short array syntax
if
(
$reflector
->
getNode
()
->
default
)
{
$this
->
defaultValue
=
PrettyPrinter
::
getRepresentationOfValue
(
$reflector
->
getNode
()
->
default
);
}
foreach
(
$this
->
tags
as
$i
=>
$tag
)
{
foreach
(
$this
->
tags
as
$i
=>
$tag
)
{
if
(
$tag
instanceof
VarTag
)
{
if
(
$tag
instanceof
VarTag
)
{
...
...
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