Compare commits

..
9 Commits
Author SHA1 Message Date
Mike van Riel 60ba10fad1 Multiline @return statements were stripped from their newlines and indent
@return statements (and effectively others) were stripped from their newlines
and indentation. By tweaking the reflection a bit was this effect countered.
2012-09-10 16:50:44 +02:00
Mike van Riel 91ef535ae3 #544: Added self and $this to the exceptions where type expansion is not required 2012-07-27 06:56:37 +02:00
Mike van Riel c999e7d32a Removed the prefixing slash in a class_exists call because the autoloader of Composer
dies on that occasionally.
2012-07-26 17:09:50 +02:00
Mike van Riel 2b05ea3221 Fixing the other RegExes as well since they were also not using the u modifier 2012-07-13 20:07:51 +02:00
Mike van Riel 33a2e55cbc Merge pull request #4 from rvanvelzen/master
Add the u modifier to the regexes used.
2012-07-13 10:28:21 -07:00
Richard van Velzen 3d97a72bac Merge branch 'master' of git://github.com/phpDocumentor/ReflectionDocBlock 2012-07-13 13:43:29 +02:00
Richard van Velzen 51210b581e Add the u modifier to the regexes used.
Without the u modifier, PCRE does not recognize Unicode sequences, which breaks certain cases.
2012-07-13 13:42:49 +02:00
Mike van Riel cee3c0bc21 Namespace resolution did not work as intended
The algorithm to expand a class name into a FCQN contained seevral errors.
These are now gone and expansion should work as expected
2012-06-30 13:38:18 +02:00
Mike van Riel 731e797dd8 Added 'global' to the list of special namespace names indicating global space and adding namespace resolution to the param tags 'getType()' method 2012-06-29 23:04:12 +02:00
4 changed files with 12 additions and 22 deletions
+7 -18
View File
@@ -99,7 +99,7 @@ class DocBlock implements \Reflector
{ {
$comment = trim( $comment = trim(
preg_replace( preg_replace(
'#[ \t]*(?:\/\*\*|\*\/|\*)?[ \t]{0,1}(.*)?#', '$1', $comment '#[ \t]*(?:\/\*\*|\*\/|\*)?[ \t]{0,1}(.*)?#u', '$1', $comment
) )
); );
@@ -133,7 +133,7 @@ class DocBlock implements \Reflector
} else { } else {
// clears all extra horizontal whitespace from the line endings // clears all extra horizontal whitespace from the line endings
// to prevent parsing issues // to prevent parsing issues
$comment = preg_replace('~(?m)\h*$~', '', $comment); $comment = preg_replace('~(?m)\h*$~u', '', $comment);
/* /*
* Splits the docblock into a short description, long description and * Splits the docblock into a short description, long description and
@@ -173,7 +173,7 @@ class DocBlock implements \Reflector
) )
)? )?
(\s+ [\s\S]*)? # everything that follows (\s+ [\s\S]*)? # everything that follows
/', $comment, $matches /u', $comment, $matches
); );
array_shift($matches); array_shift($matches);
} }
@@ -199,8 +199,6 @@ class DocBlock implements \Reflector
continue; continue;
} }
$tag_line = ltrim($tag_line);
if (isset($tag_line[0]) && ($tag_line[0] === '@')) { if (isset($tag_line[0]) && ($tag_line[0] === '@')) {
$result[] = $tag_line; $result[] = $tag_line;
} else { } else {
@@ -325,12 +323,12 @@ class DocBlock implements \Reflector
$ignore_keywords = array( $ignore_keywords = array(
'string', 'int', 'integer', 'bool', 'boolean', 'float', 'double', 'string', 'int', 'integer', 'bool', 'boolean', 'float', 'double',
'object', 'mixed', 'array', 'resource', 'void', 'null', 'object', 'mixed', 'array', 'resource', 'void', 'null',
'callback', 'false', 'true' 'callback', 'false', 'true', 'self', '$this', 'callable'
); );
} }
$namespace = ''; $namespace = '';
if ($this->namespace != 'default') { if ($this->namespace != 'default' && $this->namespace != 'global') {
$namespace = rtrim($this->namespace, '\\') . '\\'; $namespace = rtrim($this->namespace, '\\') . '\\';
} }
@@ -350,21 +348,12 @@ class DocBlock implements \Reflector
) { ) {
$type_parts = explode('\\', $item); $type_parts = explode('\\', $item);
// if the first part is the keyword 'namespace', replace it
// with the current namespace
if ($type_parts[0] == 'namespace') {
$type_parts[0] = $this->getNamespace();
$item = implode('\\', $type_parts);
}
// if the first segment is an alias; replace with full name // if the first segment is an alias; replace with full name
if (isset($this->namespace_aliases[$type_parts[0]])) { if (isset($this->namespace_aliases[$type_parts[0]])) {
$type_parts[0] = $this->namespace_aliases[$type_parts[0]]; $type_parts[0] = $this->namespace_aliases[$type_parts[0]];
$item = implode('\\', $type_parts); $item = implode('\\', $type_parts);
} elseif (count($type_parts) == 1) { } else {
// prefix the item with the namespace if there is only one // otherwise prepend the current namespace
// part and no alias
$item = $namespace . $item; $item = $namespace . $item;
} }
} }
@@ -35,7 +35,7 @@ class LongDescription implements \Reflector
*/ */
public function __construct($content) public function __construct($content)
{ {
if (preg_match('/\{\@(.+?)\}/', $content, $matches)) { if (preg_match('/\{\@(.+?)\}/u', $content, $matches)) {
array_shift($matches); array_shift($matches);
foreach ($matches as $tag) { foreach ($matches as $tag) {
$this->tags[] = Tag::createInstance('@' . $tag); $this->tags[] = Tag::createInstance('@' . $tag);
@@ -78,7 +78,7 @@ class LongDescription implements \Reflector
); );
} }
if (class_exists('\dflydev\markdown\MarkdownExtraParser')) { if (class_exists('dflydev\markdown\MarkdownExtraParser')) {
$md = new \dflydev\markdown\MarkdownExtraParser(); $md = new \dflydev\markdown\MarkdownExtraParser();
$result = $md->transformMarkdown($result); $result = $md->transformMarkdown($result);
} }
@@ -79,7 +79,7 @@ class ParamTag extends Tag
*/ */
public function getType() public function getType()
{ {
return $this->type; return $this->docblock->expandType($this->type);
} }
/** /**
@@ -34,7 +34,8 @@ class ReturnTag extends ParamTag
{ {
$this->tag = $type; $this->tag = $type;
$this->content = $content; $this->content = $content;
$content = preg_split('/\s+/u', $content);
$content = preg_split('/[\ \t]+/u', $content, 2);
// any output is considered a type // any output is considered a type
$this->type = array_shift($content); $this->type = array_shift($content);