Commit e2aacad8 by Carsten Brandt

Added links to PHP.net to apidoc

parent f2797191
...@@ -179,6 +179,7 @@ class ApiMarkdown extends GithubMarkdown ...@@ -179,6 +179,7 @@ class ApiMarkdown extends GithubMarkdown
$offset $offset
]; ];
} }
if ($context !== null) { if ($context !== null) {
// Collection resolves relative types // Collection resolves relative types
$object = (new Collection([$object], $context->phpDocContext))->__toString(); $object = (new Collection([$object], $context->phpDocContext))->__toString();
...@@ -188,6 +189,11 @@ class ApiMarkdown extends GithubMarkdown ...@@ -188,6 +189,11 @@ class ApiMarkdown extends GithubMarkdown
static::$renderer->createTypeLink($type, null, $title), static::$renderer->createTypeLink($type, null, $title),
$offset $offset
]; ];
} elseif (strpos($typeLink = static::$renderer->createTypeLink($object, null, $title), '<a href') !== false) {
return [
$typeLink,
$offset
];
} }
static::$renderer->apiContext->errors[] = [ static::$renderer->apiContext->errors[] = [
'file' => ($context !== null) ? $context->sourceFile : null, 'file' => ($context !== null) ? $context->sourceFile : null,
......
...@@ -85,7 +85,30 @@ abstract class BaseRenderer extends Component ...@@ -85,7 +85,30 @@ abstract class BaseRenderer extends Component
} }
} }
if (!is_object($type)) { if (!is_object($type)) {
$links[] = $type; $linkText = ltrim($type, '\\');
if ($title !== null) {
$linkText = $title;
}
$phpTypes = [
'callable',
'array',
'string',
'boolean',
'integer',
'float',
'object',
'resource',
'null',
];
// check if it is PHP internal class
if (((class_exists($type, false) || interface_exists($type, false) || trait_exists($type, false)) &&
($reflection = new \ReflectionClass($type)) && $reflection->isInternal())) {
$links[] = $this->generateLink($linkText, 'http://www.php.net/class.' . strtolower(ltrim($type, '\\'))) . $postfix;
} elseif (in_array($type, $phpTypes)) {
$links[] = $this->generateLink($linkText, 'http://www.php.net/language.types.' . strtolower(ltrim($type, '\\'))) . $postfix;
} else {
$links[] = $type;
}
} else { } else {
$linkText = $type->name; $linkText = $type->name;
if ($title !== null) { if ($title !== null) {
......
...@@ -148,7 +148,7 @@ class ApiRenderer extends BaseApiRenderer implements ViewContextInterface ...@@ -148,7 +148,7 @@ class ApiRenderer extends BaseApiRenderer implements ViewContextInterface
$class = $this->apiContext->classes[$class->parentClass]; $class = $this->apiContext->classes[$class->parentClass];
$parents[] = $this->createTypeLink($class); $parents[] = $this->createTypeLink($class);
} else { } else {
$parents[] = $class->parentClass; // TODO link to php.net $parents[] = $this->createTypeLink($class->parentClass);
break; break;
} }
} }
...@@ -167,7 +167,7 @@ class ApiRenderer extends BaseApiRenderer implements ViewContextInterface ...@@ -167,7 +167,7 @@ class ApiRenderer extends BaseApiRenderer implements ViewContextInterface
if(isset($this->apiContext->interfaces[$interface])) { if(isset($this->apiContext->interfaces[$interface])) {
$interfaces[] = $this->createTypeLink($this->apiContext->interfaces[$interface]); $interfaces[] = $this->createTypeLink($this->apiContext->interfaces[$interface]);
} else { } else {
$interfaces[] = $interface; // TODO link to php.net $interfaces[] = $this->createTypeLink($interface);
} }
} }
return implode(', ', $interfaces); return implode(', ', $interfaces);
...@@ -185,7 +185,7 @@ class ApiRenderer extends BaseApiRenderer implements ViewContextInterface ...@@ -185,7 +185,7 @@ class ApiRenderer extends BaseApiRenderer implements ViewContextInterface
if(isset($this->apiContext->traits[$trait])) { if(isset($this->apiContext->traits[$trait])) {
$traits[] = $this->createTypeLink($this->apiContext->traits[$trait]); $traits[] = $this->createTypeLink($this->apiContext->traits[$trait]);
} else { } else {
$traits[] = $trait; // TODO link to php.net $traits[] = $this->createTypeLink($trait);
} }
} }
return implode(', ', $traits); return implode(', ', $traits);
...@@ -203,7 +203,7 @@ class ApiRenderer extends BaseApiRenderer implements ViewContextInterface ...@@ -203,7 +203,7 @@ class ApiRenderer extends BaseApiRenderer implements ViewContextInterface
if(isset($this->apiContext->classes[$class])) { if(isset($this->apiContext->classes[$class])) {
$classes[] = $this->createTypeLink($this->apiContext->classes[$class]); $classes[] = $this->createTypeLink($this->apiContext->classes[$class]);
} else { } else {
$classes[] = $class; // TODO link to php.net $classes[] = $this->createTypeLink($class);
} }
} }
return implode(', ', $classes); return implode(', ', $classes);
......
...@@ -99,7 +99,7 @@ class Query extends Component implements QueryInterface ...@@ -99,7 +99,7 @@ class Query extends Component implements QueryInterface
*/ */
public $params = []; public $params = [];
/** /**
* @var callback PHP callback, which should be used to fetch source data for the snippets. * @var callable PHP callback, which should be used to fetch source data for the snippets.
* Such callback will receive array of query result rows as an argument and must return the * Such callback will receive array of query result rows as an argument and must return the
* array of snippet source strings in the order, which match one of incoming rows. * array of snippet source strings in the order, which match one of incoming rows.
* For example: * For example:
...@@ -642,7 +642,7 @@ class Query extends Component implements QueryInterface ...@@ -642,7 +642,7 @@ class Query extends Component implements QueryInterface
/** /**
* Sets the PHP callback, which should be used to retrieve the source data * Sets the PHP callback, which should be used to retrieve the source data
* for the snippets building. * for the snippets building.
* @param callback $callback PHP callback, which should be used to fetch source data for the snippets. * @param callable $callback PHP callback, which should be used to fetch source data for the snippets.
* @return static the query object itself * @return static the query object itself
* @see snippetCallback * @see snippetCallback
*/ */
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
namespace yii\base; namespace yii\base;
/** /**
* ArrayAccessTrait provides the implementation for `IteratorAggregate`, `ArrayAccess` and `Countable`. * ArrayAccessTrait provides the implementation for [[\IteratorAggregate]], [[\ArrayAccess]] and [[\Countable]].
* *
* Note that ArrayAccessTrait requires the class using it contain a property named `data` which should be an array. * Note that ArrayAccessTrait requires the class using it contain a property named `data` which should be an array.
* The data will be exposed by ArrayAccessTrait to support accessing the class object like an array. * The data will be exposed by ArrayAccessTrait to support accessing the class object like an array.
......
...@@ -460,7 +460,7 @@ class Component extends Object ...@@ -460,7 +460,7 @@ class Component extends Object
* where `$event` is an [[Event]] object which includes parameters associated with the event. * where `$event` is an [[Event]] object which includes parameters associated with the event.
* *
* @param string $name the event name * @param string $name the event name
* @param callback $handler the event handler * @param callable $handler the event handler
* @param mixed $data the data to be passed to the event handler when the event is triggered. * @param mixed $data the data to be passed to the event handler when the event is triggered.
* When the event handler is invoked, this data can be accessed via [[Event::data]]. * When the event handler is invoked, this data can be accessed via [[Event::data]].
* @see off() * @see off()
...@@ -475,7 +475,7 @@ class Component extends Object ...@@ -475,7 +475,7 @@ class Component extends Object
* Detaches an existing event handler from this component. * Detaches an existing event handler from this component.
* This method is the opposite of [[on()]]. * This method is the opposite of [[on()]].
* @param string $name event name * @param string $name event name
* @param callback $handler the event handler to be removed. * @param callable $handler the event handler to be removed.
* If it is null, all handlers attached to the named event will be removed. * If it is null, all handlers attached to the named event will be removed.
* @return boolean if a handler is found and detached * @return boolean if a handler is found and detached
* @see on() * @see on()
......
...@@ -71,7 +71,7 @@ class Event extends Object ...@@ -71,7 +71,7 @@ class Event extends Object
* *
* @param string $class the fully qualified class name to which the event handler needs to attach. * @param string $class the fully qualified class name to which the event handler needs to attach.
* @param string $name the event name. * @param string $name the event name.
* @param callback $handler the event handler. * @param callable $handler the event handler.
* @param mixed $data the data to be passed to the event handler when the event is triggered. * @param mixed $data the data to be passed to the event handler when the event is triggered.
* When the event handler is invoked, this data can be accessed via [[Event::data]]. * When the event handler is invoked, this data can be accessed via [[Event::data]].
* @see off() * @see off()
...@@ -88,7 +88,7 @@ class Event extends Object ...@@ -88,7 +88,7 @@ class Event extends Object
* *
* @param string $class the fully qualified class name from which the event handler needs to be detached. * @param string $class the fully qualified class name from which the event handler needs to be detached.
* @param string $name the event name. * @param string $name the event name.
* @param callback $handler the event handler to be removed. * @param callable $handler the event handler to be removed.
* If it is null, all handlers attached to the named event will be removed. * If it is null, all handlers attached to the named event will be removed.
* @return boolean whether a handler is found and detached. * @return boolean whether a handler is found and detached.
* @see on() * @see on()
......
...@@ -63,7 +63,7 @@ class ActionColumn extends Column ...@@ -63,7 +63,7 @@ class ActionColumn extends Column
*/ */
public $buttons = []; public $buttons = [];
/** /**
* @var callback a callback that creates a button URL using the specified model information. * @var callable a callback that creates a button URL using the specified model information.
* The signature of the callback should be the same as that of [[createUrl()]]. * The signature of the callback should be the same as that of [[createUrl()]].
* If this property is not set, button URLs will be created using [[createUrl()]]. * If this property is not set, button URLs will be created using [[createUrl()]].
*/ */
......
...@@ -88,7 +88,7 @@ abstract class BaseMailer extends Component implements MailerInterface, ViewCont ...@@ -88,7 +88,7 @@ abstract class BaseMailer extends Component implements MailerInterface, ViewCont
*/ */
public $fileTransportPath = '@runtime/mail'; public $fileTransportPath = '@runtime/mail';
/** /**
* @var callback a PHP callback that will be called by [[send()]] when [[useFileTransport]] is true. * @var callable a PHP callback that will be called by [[send()]] when [[useFileTransport]] is true.
* The callback should return a file name which will be used to save the email message. * The callback should return a file name which will be used to save the email message.
* If not set, the file name will be generated based on the current timestamp. * If not set, the file name will be generated based on the current timestamp.
* *
......
...@@ -31,7 +31,7 @@ use yii\base\InvalidConfigException; ...@@ -31,7 +31,7 @@ use yii\base\InvalidConfigException;
class FilterValidator extends Validator class FilterValidator extends Validator
{ {
/** /**
* @var callback the filter. This can be a global function name, anonymous function, etc. * @var callable the filter. This can be a global function name, anonymous function, etc.
* The function signature must be as follows, * The function signature must be as follows,
* *
* ~~~ * ~~~
......
...@@ -54,7 +54,7 @@ use yii\base\ActionFilter; ...@@ -54,7 +54,7 @@ use yii\base\ActionFilter;
class AccessControl extends ActionFilter class AccessControl extends ActionFilter
{ {
/** /**
* @var callback a callback that will be called if the access should be denied * @var callable a callback that will be called if the access should be denied
* to the current user. If not set, [[denyAccess()]] will be called. * to the current user. If not set, [[denyAccess()]] will be called.
* *
* The signature of the callback should be as follows: * The signature of the callback should be as follows:
......
...@@ -61,7 +61,7 @@ class AccessRule extends Component ...@@ -61,7 +61,7 @@ class AccessRule extends Component
*/ */
public $verbs; public $verbs;
/** /**
* @var callback a callback that will be called to determine if the rule should be applied. * @var callable a callback that will be called to determine if the rule should be applied.
* The signature of the callback should be as follows: * The signature of the callback should be as follows:
* *
* ~~~ * ~~~
...@@ -73,7 +73,7 @@ class AccessRule extends Component ...@@ -73,7 +73,7 @@ class AccessRule extends Component
*/ */
public $matchCallback; public $matchCallback;
/** /**
* @var callback a callback that will be called if this rule determines the access to * @var callable a callback that will be called if this rule determines the access to
* the current action should be denied. If not set, the behavior will be determined by * the current action should be denied. If not set, the behavior will be determined by
* [[AccessControl]]. * [[AccessControl]].
* *
......
...@@ -46,7 +46,7 @@ use yii\base\Action; ...@@ -46,7 +46,7 @@ use yii\base\Action;
class HttpCache extends ActionFilter class HttpCache extends ActionFilter
{ {
/** /**
* @var callback a PHP callback that returns the UNIX timestamp of the last modification time. * @var callable a PHP callback that returns the UNIX timestamp of the last modification time.
* The callback's signature should be: * The callback's signature should be:
* *
* ~~~ * ~~~
...@@ -58,7 +58,7 @@ class HttpCache extends ActionFilter ...@@ -58,7 +58,7 @@ class HttpCache extends ActionFilter
*/ */
public $lastModified; public $lastModified;
/** /**
* @var callback a PHP callback that generates the Etag seed string. * @var callable a PHP callback that generates the Etag seed string.
* The callback's signature should be: * The callback's signature should be:
* *
* ~~~ * ~~~
......
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