pesu / php-makecomment
从输入文本行构建PHP注释。
Requires
- php: >=5.3.0
This package is not auto-updated.
Last update: 2024-09-18 19:12:30 UTC
README
PHP MakePhpComment 2015年11月
由 Per Sundberg
介绍
这是一个使用框架 Anax-MVC Content CTextFilter 格式化文本字符串为 PHP 注释的模块。
要求
此库包需要PHP 5.3或更高版本。
用法
在地址:git clone https://github.com/mosbth/Anax-MVC.git 上安装 ANAX-MVC
将模块 php-makecomment 安装到文件夹 ANAX-MVC\3pp 中。
php-makecomment 旨在与类自动加载一起使用。因此,需要将 Anax-MVC\app\config\autoloader.php 更新为:->addNameSpace('pesu', ANAX_INSTALL_PATH . '3pp/php-makecomment/pesu')
需要在 Anax-MVC\src\Content\CTextFilter.php 文件中在 'shortcode' => 'shortCode' 行之后添加 'phpcomment' => 'phpcomment',
需要在 Anax-MVC\src\Content\CTextFilter.php 文件中添加函数。
/**
- 根据注释格式化文本。
- @param string $text 需要格式化的文本。
- @return string 格式化的HTML文本。 */ public function phpcomment($text) { return \pesu\MakePhpComment::makephpcomment($text); }
在 $app->views->add('welcome/hello_world'); 后添加到 ANAX-MVC/webroot/hello_view.php 中:$app->router->add('', function() use ($app) {
$content = $app->textFilter->doFilter('Function: Test php comment\n\n@param
string $text xxxx\n\n@return string text xxxx','shortcode, phpcomment');
$app->views->add('welcome/page', [
'content' => $content,
]);
}); $app->router->handle();
将页面模板 page.tpl.php 添加到 Anax-MVC\app\view\welcome 中
错误
请发送电子邮件到: sundberg_p@yahoo.com 提交错误报告
开发和测试
此模块在瑞典卡尔斯基罗纳的 Blekinge Tekniska Högskola 开发,是课程 DV14886 PHP MVC 的一部分。
我在 hello_view.php 中使用不同的字符串测试了该函数,测试 1 使用空字符串 $content = $app->textFilter->doFilter('','shortcode, phpcomment'); 结果:/** * */
测试 2 使用单行字符串(无 \n) $content = $app->textFilter->doFilter('Function: Test php comment','shortcode, phpcomment'); 结果:/**
- Function: Test php comment */
测试 3 使用两行字符串(一行 \n) $content = $app->textFilter->doFilter('Function: Test php comment\n','shortcode, phpcomment'); 结果:/**
- Function: Test php comment */
测试 4 使用三行字符串(两行 \n) $content = $app->textFilter->doFilter('Function: Test php comment\n\n','shortcode, phpcomment'); 结果:/**
- Function: Test php comment
*/
测试 5 使用五行字符串(四行 \n)
$content = $app->textFilter->doFilter('Function: Test php comment\n\n@param string $text xxxx\n\n@return string text xxxx','shortcode, phpcomment');
/**
- Function: Test php comment
- @param string $text xxxx
- @return string text xxxx */
版本历史
PHP Markdown Module 1.0.0 (22 Nov 2015)
版权和许可
PHP MakePhpComment 模块版权 (c) 2015 Per Sundberg