forked from yiisoft/yii2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved common help parsing code into HelpParser. Action methods now ha…
…ve default implementation.
- Loading branch information
Showing
4 changed files
with
119 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
/** | ||
* @link http://www.yiiframework.com/ | ||
* @copyright Copyright (c) 2008 Yii Software LLC | ||
* @license http://www.yiiframework.com/license/ | ||
*/ | ||
|
||
namespace yii\console; | ||
|
||
use yii\helpers\Console; | ||
|
||
/** | ||
* HelpParser contains methods used to get help information from phpDoc. | ||
* | ||
* @author Alexander Makarov <[email protected]> | ||
* @since 2.0 | ||
*/ | ||
class HelpParser | ||
{ | ||
/** | ||
* Returns the first line of docblock. | ||
* | ||
* @param \Reflector $reflector | ||
* @return string | ||
*/ | ||
public static function getSummary(\Reflector $reflector) | ||
{ | ||
$docLines = preg_split('~\R~', $reflector->getDocComment()); | ||
if (isset($docLines[1])) { | ||
return trim($docLines[1], ' *'); | ||
} | ||
return ''; | ||
} | ||
|
||
/** | ||
* Returns full description from the docblock. | ||
* | ||
* @param \Reflector $reflector | ||
* @return string | ||
*/ | ||
public static function getFull(\Reflector $reflector) | ||
{ | ||
$comment = strtr(trim(preg_replace('/^\s*\**( |\t)?/m', '', trim($reflector->getDocComment(), '/'))), "\r", ''); | ||
if (preg_match('/^\s*@\w+/m', $comment, $matches, PREG_OFFSET_CAPTURE)) { | ||
$comment = trim(substr($comment, 0, $matches[0][1])); | ||
} | ||
if ($comment !== '') { | ||
return rtrim(Console::renderColoredString(Console::markdownToAnsi($comment))); | ||
} | ||
return ''; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters