Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 33 additions & 26 deletions src/phpDocumentor/Reflection/DocBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* phpDocumentor
*
* PHP Version 5
* PHP Version 5.3
*
* @author Mike van Riel <mike.vanriel@naenius.com>
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
Expand All @@ -15,24 +15,24 @@
/**
* Parses the DocBlock for any structure.
*
* @author Mike van Riel <mike.vanriel@naenius.com>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
* @author Mike van Riel <mike.vanriel@naenius.com>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
class DocBlock implements \Reflector
{
/** @var string The opening line for this docblock. */
protected $short_description = '';

/**
* @var \phpDocumentor\Reflection\DocBlock\LongDescription The actual description
* for this docblock.
* @var \phpDocumentor\Reflection\DocBlock\LongDescription The actual
* description for this docblock.
*/
protected $long_description = null;

/**
* @var \phpDocumentor\Reflection\DocBlock\Tags[] An array containing all the tags
* in this docblock; except inline.
* @var \phpDocumentor\Reflection\DocBlock\Tags[] An array containing all
* the tags in this docblock; except inline.
*/
protected $tags = array();

Expand All @@ -52,19 +52,21 @@ class DocBlock implements \Reflector
* For example the param and return tags use this to expand their type
* information.
*
* @param \Reflector|string $docblock A docblock comment (including asterisks)
* or reflector supporting the getDocComment method.
* @param string $namespace The namespace where this DocBlock resides in;
* defaults to `\`.
* @param string[] $namespace_aliases a list of namespace aliases as
* provided by the `use` keyword; the key of the array is the alias name
* or last part of the alias array if no alias name is provided.
* @param \Reflector|string $docblock A docblock comment (including
* asterisks) or reflector supporting the getDocComment method.
* @param string $namespace The namespace where this
* DocBlock resides in; defaults to `\`.
* @param string[] $namespace_aliases A list of namespace aliases
* as provided by the `use` keyword; the key of the array is the alias
* name or last part of the alias array if no alias name is provided.
*
* @throws \InvalidArgumentException if the given argument does not have the
* getDocComment method.
*/
public function __construct(
$docblock, $namespace = '\\', $namespace_aliases = array()
$docblock,
$namespace = '\\',
$namespace_aliases = array()
) {
if (is_object($docblock)) {
if (!method_exists($docblock, 'getDocComment')) {
Expand Down Expand Up @@ -99,7 +101,9 @@ protected function cleanInput($comment)
{
$comment = trim(
preg_replace(
'#[ \t]*(?:\/\*\*|\*\/|\*)?[ \t]{0,1}(.*)?#u', '$1', $comment
'#[ \t]*(?:\/\*\*|\*\/|\*)?[ \t]{0,1}(.*)?#u',
'$1',
$comment
)
);

Expand All @@ -121,7 +125,7 @@ protected function cleanInput($comment)
* @param string $comment Comment to split into the sub-parts.
*
* @author RichardJ Special thanks to RichardJ for the regex responsible
* for the split/
* for the split.
*
* @return string[] containing the short-, long description and an element
* containing the tags.
Expand Down Expand Up @@ -173,7 +177,9 @@ protected function splitDocBlock($comment)
)
)?
(\s+ [\s\S]*)? # everything that follows
/u', $comment, $matches
/u',
$comment,
$matches
);
array_shift($matches);
}
Expand Down Expand Up @@ -306,9 +312,10 @@ public function hasTag($name)
* @param string $type Type to expand into full namespaced
* equivalent.
* @param string[] $ignore_keywords Whether to ignore given keywords, when
* null it will use the default keywords: 'string', 'int', 'integer',
* 'bool', 'boolean', 'float', 'double', 'object', 'mixed', 'array',
* 'resource', 'void', 'null', 'callback', 'false', 'true'.
* null it will use the default keywords:
* 'string', 'int', 'integer', 'bool', 'boolean', 'float', 'double',
* 'object', 'mixed', 'array', 'resource', 'void', 'null', 'callback',
* 'false', 'true', 'self', '$this', 'callable'.
* Default value for this parameter is null.
*
* @return string
Expand All @@ -321,9 +328,9 @@ public function expandType($type, $ignore_keywords = null)

if ($ignore_keywords === null) {
$ignore_keywords = array(
'string', 'int', 'integer', 'bool', 'boolean', 'float', 'double',
'object', 'mixed', 'array', 'resource', 'void', 'null',
'callback', 'false', 'true', 'self', '$this', 'callable'
'string', 'int', 'integer', 'bool', 'boolean', 'float',
'double', 'object', 'mixed', 'array', 'resource', 'void',
'null', 'callback', 'false', 'true', 'self', '$this', 'callable'
);
}

Expand Down Expand Up @@ -382,7 +389,7 @@ public function expandType($type, $ignore_keywords = null)
*
* @return string
*/
static public function export()
public static function export()
{
throw new \Exception('Not yet implemented');
}
Expand Down
27 changes: 15 additions & 12 deletions src/phpDocumentor/Reflection/DocBlock/LongDescription.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
/**
* Parses a Long Description of a DocBlock.
*
* @author Mike van Riel <mike.vanriel@naenius.com>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
* @author Mike van Riel <mike.vanriel@naenius.com>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
class LongDescription implements \Reflector
{
Expand Down Expand Up @@ -51,18 +51,20 @@ public function getContents()
return $this->contents;
}

/*
/**
* Returns the parsed text of this description.
*
* @return array An array of strings and tag objects, in the order they
* occur within the description.
* occur within the description.
*/
public function getParsedContents()
{
if (null === $this->parsedContents) {
$this->parsedContents = preg_split(
'/\{(\@.*?)\}/uS', $this->contents,
null, PREG_SPLIT_DELIM_CAPTURE
'/\{(\@.*?)\}/uS',
$this->contents,
null,
PREG_SPLIT_DELIM_CAPTURE
);
for ($i=1, $l = count($this->parsedContents); $i<$l; $i += 2) {
$this->parsedContents[$i] = Tag::createInstance(
Expand Down Expand Up @@ -97,8 +99,8 @@ public function getFormattedContents()
}

if (class_exists('dflydev\markdown\MarkdownExtraParser')) {
$md = new \dflydev\markdown\MarkdownExtraParser();
$result = $md->transformMarkdown($result);
$markdown = new \dflydev\markdown\MarkdownExtraParser();
$result = $markdown->transformMarkdown($result);
}

return trim($result);
Expand All @@ -107,11 +109,12 @@ public function getFormattedContents()
/**
* Builds a string representation of this object.
*
* @todo determine the exact format as used by PHP Reflection and implement it.
* @todo determine the exact format as used by PHP Reflection
* and implement it.
*
* @return void
*/
static public function export()
public static function export()
{
throw new \Exception('Not yet implemented');
}
Expand All @@ -126,4 +129,4 @@ public function __toString()
{
return 'Not yet implemented';
}
}
}
27 changes: 15 additions & 12 deletions src/phpDocumentor/Reflection/DocBlock/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* phpDocumentor
*
* PHP Version 5
* PHP Version 5.3
*
* @author Mike van Riel <mike.vanriel@naenius.com>
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
Expand All @@ -15,9 +15,9 @@
/**
* Parses a tag definition for a DocBlock.
*
* @author Mike van Riel <mike.vanriel@naenius.com>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
* @author Mike van Riel <mike.vanriel@naenius.com>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
class Tag implements \Reflector
{
Expand All @@ -29,7 +29,7 @@ class Tag implements \Reflector

/** @var string Description of the content of this tag */
protected $description = '';

/** @var array The description, as an array of strings and Tag objects. */
protected $parsedDescription = null;

Expand All @@ -51,7 +51,9 @@ class Tag implements \Reflector
public static function createInstance($tag_line)
{
if (!preg_match(
'/^@([\w\-\_\\\\]+)(?:\s*([^\s].*)|$)?/us', $tag_line, $matches
'/^@([\w\-\_\\\\]+)(?:\s*([^\s].*)|$)?/us',
$tag_line,
$matches
)) {
throw new \InvalidArgumentException(
'Invalid tag_line detected: ' . $tag_line
Expand All @@ -60,7 +62,9 @@ public static function createInstance($tag_line)

// support hypphen separated tag names
$tag_name = str_replace(
' ', '', ucwords(str_replace('-', ' ', $matches[1]))
' ',
'',
ucwords(str_replace('-', ' ', $matches[1]))
).'Tag';
$class_name = 'phpDocumentor\\Reflection\\DocBlock\\Tag\\' . $tag_name;

Expand Down Expand Up @@ -111,12 +115,12 @@ public function getDescription()
{
return $this->description;
}
/*

/**
* Returns the parsed text of this description.
*
* @return array An array of strings and tag objects, in the order they
* occur within the description.
* occur within the description.
*/
public function getParsedDescription()
{
Expand Down Expand Up @@ -170,7 +174,7 @@ public function setDocBlock($docblock)
*
* @return void
*/
static public function export()
public static function export()
{
throw new \Exception('Not yet implemented');
}
Expand All @@ -185,5 +189,4 @@ public function __toString()
{
return 'Not yet implemented';
}

}
18 changes: 9 additions & 9 deletions src/phpDocumentor/Reflection/DocBlock/Tag/AuthorTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
/**
* phpDocumentor
*
* PHP Version 5
* PHP Version 5.3
*
* @author Mike van Riel <mike.vanriel@naenius.com>
* @author Vasil Rangelov <boen.robot@gmail.com>
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
Expand All @@ -17,18 +17,18 @@
/**
* Reflection class for an @author tag in a Docblock.
*
* @author Mike van Riel <mike.vanriel@naenius.com>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
* @author Mike van Riel <mike.vanriel@naenius.com>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
class AuthorTag extends Tag
{
/** @var string The name of the author */
protected $name = '';

/** @var string The email of the author */
protected $email = '';

/**
* Parses a tag and populates the member variables.
*
Expand All @@ -45,7 +45,7 @@ public function __construct($type, $content)
}
}
}

/**
* Gets the author's name.
*
Expand All @@ -55,7 +55,7 @@ public function getAuthorName()
{
return $this->name;
}

/**
* Gets the author's email.
*
Expand Down
9 changes: 4 additions & 5 deletions src/phpDocumentor/Reflection/DocBlock/Tag/CoversTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* phpDocumentor
*
* PHP Version 5
* PHP Version 5.3
*
* @author Mike van Riel <mike.vanriel@naenius.com>
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
Expand All @@ -15,11 +15,10 @@
/**
* Reflection class for a @covers tag in a Docblock.
*
* @author Mike van Riel <mike.vanriel@naenius.com>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
* @author Mike van Riel <mike.vanriel@naenius.com>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
class CoversTag extends SeeTag
{

}
9 changes: 5 additions & 4 deletions src/phpDocumentor/Reflection/DocBlock/Tag/LinkTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* phpDocumentor
*
* PHP Version 5
* PHP Version 5.3
*
* @author Ben Selby <benmatselby@gmail.com>
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
Expand All @@ -11,14 +11,15 @@
*/

namespace phpDocumentor\Reflection\DocBlock\Tag;

use phpDocumentor\Reflection\DocBlock\Tag;

/**
* Reflection class for a @link tag in a Docblock.
*
* @author Ben Selby <benmatselby@gmail.com>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
* @author Ben Selby <benmatselby@gmail.com>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
class LinkTag extends Tag
{
Expand Down
Loading