Commit 2245a7e3 by Carsten Brandt

short array syntax

parent 82f7937a
<?php
/**
*
*
* @author Carsten Brandt <mail@cebe.cc>
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\apidoc\helpers;
use phpDocumentor\Reflection\DocBlock\Type\Collection;
use yii\apidoc\models\MethodDoc;
use yii\apidoc\models\TypeDoc;
use yii\apidoc\templates\BaseRenderer;
use yii\helpers\Html;
/**
*
* @author Carsten Brandt <mail@cebe.cc>
* @since 2.0
*/
class Markdown extends \yii\helpers\Markdown
{
/**
......
<?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
......@@ -160,7 +160,7 @@ class Context extends Component
if (isset($class->properties[$propertyName])) {
$property = $class->properties[$propertyName];
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;
} else {
......@@ -184,7 +184,7 @@ class Context extends Component
if (isset($class->properties[$propertyName])) {
$property = $class->properties[$propertyName];
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;
} else {
......
......@@ -58,7 +58,8 @@ class FunctionDoc extends BaseDoc
} elseif ($tag instanceof ParamTag) {
$paramName = $tag->getVariableName();
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]->type = $tag->getType();
......
......@@ -7,6 +7,7 @@
namespace yii\apidoc\models;
use yii\apidoc\helpers\PrettyPrinter;
use yii\base\Object;
/**
......@@ -42,7 +43,11 @@ class ParamDoc extends Object
$this->name = $reflector->getName();
$this->typeHint = $reflector->getType();
$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();
}
}
\ No newline at end of file
......@@ -8,6 +8,7 @@
namespace yii\apidoc\models;
use phpDocumentor\Reflection\DocBlock\Tag\VarTag;
use yii\apidoc\helpers\PrettyPrinter;
/**
*
......@@ -55,7 +56,10 @@ class PropertyDoc extends BaseDoc
$this->visibility = $reflector->getVisibility();
$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) {
if ($tag instanceof VarTag) {
......
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