• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP phutil_split_lines函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中phutil_split_lines函数的典型用法代码示例。如果您正苦于以下问题:PHP phutil_split_lines函数的具体用法?PHP phutil_split_lines怎么用?PHP phutil_split_lines使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了phutil_split_lines函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: parseLinterOutput

 protected function parseLinterOutput($path, $err, $stdout, $stderr)
 {
     $ok = $err == 0;
     $lines = phutil_split_lines($stdout, false);
     $messages = array();
     foreach ($lines as $line) {
         $matches = null;
         if (!preg_match('/^(.*?):(\\d+):((\\d+):)? (\\S+): ((\\s|\\w)+): (.*)$/', $line, $matches)) {
             continue;
         }
         foreach ($matches as $key => $match) {
             $matches[$key] = trim($match);
         }
         $message = new ArcanistLintMessage();
         $message->setPath($path);
         $message->setLine($matches[2]);
         if ($matches[4] != '') {
             $message->setChar($matches[4]);
         }
         $message->setCode($this->getLinterName());
         $message->setName($matches[6]);
         $message->setDescription($matches[8]);
         $message->setSeverity($this->getLintMessageSeverity($matches[5]));
         $messages[] = $message;
     }
     return $messages;
 }
开发者ID:vhbit,项目名称:swift-linter,代码行数:27,代码来源:SwiftLintLinter.php


示例2: parseLinterOutput

 protected function parseLinterOutput($path, $err, $stdout, $stderr)
 {
     $lines = phutil_split_lines($stdout, false);
     $messages = array();
     foreach ($lines as $line) {
         $matches = null;
         if (!preg_match('/^(.*?):(\\d+): (.*)$/', $line, $matches)) {
             continue;
         }
         foreach ($matches as $key => $match) {
             $matches[$key] = trim($match);
         }
         $severity = ArcanistLintSeverity::SEVERITY_WARNING;
         $description = $matches[3];
         $error_regexp = '/(^undefined|^duplicate|before assignment$)/';
         if (preg_match($error_regexp, $description)) {
             $severity = ArcanistLintSeverity::SEVERITY_ERROR;
         }
         $message = new ArcanistLintMessage();
         $message->setPath($path);
         $message->setLine($matches[2]);
         $message->setCode($this->getLinterName());
         $message->setDescription($description);
         $message->setSeverity($severity);
         $messages[] = $message;
     }
     return $messages;
 }
开发者ID:lewisf,项目名称:arcanist,代码行数:28,代码来源:ArcanistPyFlakesLinter.php


示例3: unfoldICSLines

 private function unfoldICSLines($data)
 {
     $lines = phutil_split_lines($data, $retain_endings = false);
     $this->lines = $lines;
     // ICS files are wrapped at 75 characters, with overlong lines continued
     // on the following line with an initial space or tab. Unwrap all of the
     // lines in the file.
     // This unwrapping is specifically byte-oriented, not character oriented,
     // and RFC5545 anticipates that simple implementations may even split UTF8
     // characters in the middle.
     $last = null;
     foreach ($lines as $idx => $line) {
         $this->cursor = $idx;
         if (!preg_match('/^[ \\t]/', $line)) {
             $last = $idx;
             continue;
         }
         if ($last === null) {
             $this->raiseParseFailure(self::PARSE_INITIAL_UNFOLD, pht('First line of ICS file begins with a space or tab, but this ' . 'marks a line which should be unfolded.'));
         }
         $lines[$last] = $lines[$last] . substr($line, 1);
         unset($lines[$idx]);
     }
     return $lines;
 }
开发者ID:endlessm,项目名称:libphutil,代码行数:25,代码来源:PhutilICSParser.php


示例4: renderResultList

 protected function renderResultList(array $pastes, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($pastes, 'PhabricatorPaste');
     $viewer = $this->requireViewer();
     $lang_map = PhabricatorEnv::getEnvConfig('pygments.dropdown-choices');
     $list = new PHUIObjectItemListView();
     $list->setUser($viewer);
     foreach ($pastes as $paste) {
         $created = phabricator_date($paste->getDateCreated(), $viewer);
         $author = $handles[$paste->getAuthorPHID()]->renderLink();
         $snippet_type = $paste->getSnippet()->getType();
         $lines = phutil_split_lines($paste->getSnippet()->getContent());
         $preview = id(new PhabricatorSourceCodeView())->setLines($lines)->setTruncatedFirstBytes($snippet_type == PhabricatorPasteSnippet::FIRST_BYTES)->setTruncatedFirstLines($snippet_type == PhabricatorPasteSnippet::FIRST_LINES)->setURI(new PhutilURI($paste->getURI()));
         $source_code = phutil_tag('div', array('class' => 'phabricator-source-code-summary'), $preview);
         $created = phabricator_datetime($paste->getDateCreated(), $viewer);
         $line_count = count($lines);
         $line_count = pht('%s Line(s)', new PhutilNumber($line_count));
         $title = nonempty($paste->getTitle(), pht('(An Untitled Masterwork)'));
         $item = id(new PHUIObjectItemView())->setObjectName('P' . $paste->getID())->setHeader($title)->setHref('/P' . $paste->getID())->setObject($paste)->addByline(pht('Author: %s', $author))->addIcon('none', $created)->addIcon('none', $line_count)->appendChild($source_code);
         if ($paste->isArchived()) {
             $item->setDisabled(true);
         }
         $lang_name = $paste->getLanguage();
         if ($lang_name) {
             $lang_name = idx($lang_map, $lang_name, $lang_name);
             $item->addIcon('none', $lang_name);
         }
         $list->addItem($item);
     }
     $result = new PhabricatorApplicationSearchResultView();
     $result->setObjectList($list);
     $result->setNoDataString(pht('No pastes found.'));
     return $result;
 }
开发者ID:andrewBackPlane,项目名称:phabricator,代码行数:34,代码来源:PhabricatorPasteSearchEngine.php


示例5: parseLinterOutput

 protected function parseLinterOutput($path, $err, $stdout, $stderr)
 {
     // Each line looks like this:
     // Line 46, E:0110: Line too long (87 characters).
     $regex = '/^Line (\\d+), (E:\\d+): (.*)/';
     $severity_code = ArcanistLintSeverity::SEVERITY_ERROR;
     $lines = phutil_split_lines($stdout, false);
     $messages = array();
     foreach ($lines as $line) {
         $line = trim($line);
         $matches = null;
         if (!preg_match($regex, $line, $matches)) {
             continue;
         }
         foreach ($matches as $key => $match) {
             $matches[$key] = trim($match);
         }
         $message = new ArcanistLintMessage();
         $message->setPath($path);
         $message->setLine($matches[1]);
         $message->setName($matches[2]);
         $message->setCode($this->getLinterName());
         $message->setDescription($matches[3]);
         $message->setSeverity($severity_code);
         $messages[] = $message;
     }
     return $messages;
 }
开发者ID:ivoryxiong,项目名称:arcanist,代码行数:28,代码来源:ArcanistClosureLinter.php


示例6: summarizeCommitMessage

 public static function summarizeCommitMessage($message)
 {
     $summary = phutil_split_lines($message, $retain_endings = false);
     $summary = head($summary);
     $summary = id(new PhutilUTF8StringTruncator())->setMaximumBytes(self::SUMMARY_MAX_LENGTH)->truncateString($summary);
     return $summary;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:7,代码来源:PhabricatorRepositoryCommitData.php


示例7: parseLinterOutput

 protected function parseLinterOutput($path, $err, $stdout, $stderr)
 {
     $lines = phutil_split_lines($stdout, false);
     $messages = array();
     foreach ($lines as $line) {
         $matches = null;
         // stdin:2: W802 undefined name 'foo'  # pyflakes
         // stdin:3:1: E302 expected 2 blank lines, found 1  # pep8
         $regexp = '/^(.*?):(\\d+):(?:(\\d+):)? (\\S+) (.*)$/';
         if (!preg_match($regexp, $line, $matches)) {
             continue;
         }
         foreach ($matches as $key => $match) {
             $matches[$key] = trim($match);
         }
         $message = new ArcanistLintMessage();
         $message->setPath($path);
         $message->setLine($matches[2]);
         if (!empty($matches[3])) {
             $message->setChar($matches[3]);
         }
         $message->setCode($matches[4]);
         $message->setName($this->getLinterName() . ' ' . $matches[3]);
         $message->setDescription($matches[5]);
         $message->setSeverity($this->getLintMessageSeverity($matches[4]));
         $messages[] = $message;
     }
     return $messages;
 }
开发者ID:benchling,项目名称:arcanist,代码行数:29,代码来源:ArcanistFlake8Linter.php


示例8: getTextList

 public function getTextList()
 {
     if (!$this->textList) {
         return phutil_split_lines($this->getCorpus(), $retain_ends = false);
     }
     return $this->textList;
 }
开发者ID:denghp,项目名称:phabricator,代码行数:7,代码来源:DiffusionFileContent.php


示例9: markupText

 public function markupText($text, $children)
 {
     $text = trim($text);
     $lines = phutil_split_lines($text);
     if (count($lines) > 1) {
         $level = $lines[1][0] == '=' ? 1 : 2;
         $text = trim($lines[0]);
     } else {
         $level = 0;
         for ($ii = 0; $ii < min(5, strlen($text)); $ii++) {
             if ($text[$ii] == '=' || $text[$ii] == '#') {
                 ++$level;
             } else {
                 break;
             }
         }
         $text = trim($text, ' =#');
     }
     $engine = $this->getEngine();
     if ($engine->isTextMode()) {
         $char = $level == 1 ? '=' : '-';
         return $text . "\n" . str_repeat($char, phutil_utf8_strlen($text));
     }
     $use_anchors = $engine->getConfig('header.generate-toc');
     $anchor = null;
     if ($use_anchors) {
         $anchor = $this->generateAnchor($level, $text);
     }
     $text = phutil_tag('h' . ($level + 1), array('class' => 'remarkup-header'), array($anchor, $this->applyRules($text)));
     return $text;
 }
开发者ID:barcelonascience,项目名称:libphutil,代码行数:31,代码来源:PhutilRemarkupHeaderBlockRule.php


示例10: parseLinterOutput

 protected function parseLinterOutput($path, $err, $stdout, $stderr)
 {
     $lines = phutil_split_lines($stdout, false);
     $messages = array();
     foreach ($lines as $line) {
         $matches = explode('|', $line, 5);
         if (count($matches) < 5) {
             continue;
         }
         $message = id(new ArcanistLintMessage())->setPath($path)->setLine($matches[0])->setChar($matches[1])->setCode($this->getLinterName())->setName(ucwords(str_replace('_', ' ', $matches[3])))->setDescription(ucfirst($matches[4]));
         switch ($matches[2]) {
             case 'warning':
                 $message->setSeverity(ArcanistLintSeverity::SEVERITY_WARNING);
                 break;
             case 'error':
                 $message->setSeverity(ArcanistLintSeverity::SEVERITY_ERROR);
                 break;
             default:
                 $message->setSeverity(ArcanistLintSeverity::SEVERITY_ADVICE);
                 break;
         }
         $messages[] = $message;
     }
     return $messages;
 }
开发者ID:milindc2031,项目名称:Test,代码行数:25,代码来源:ArcanistPuppetLintLinter.php


示例11: markupText

 public function markupText($text, $children)
 {
     $text = $this->applyRules($text);
     if ($this->getEngine()->isTextMode()) {
         $children = phutil_split_lines($children, true);
         foreach ($children as $key => $child) {
             if (strlen(trim($child))) {
                 $children[$key] = '> ' . $child;
             } else {
                 $children[$key] = '>' . $child;
             }
         }
         $children = implode('', $children);
         return $text . "\n\n" . $children;
     }
     if ($this->getEngine()->isHTMLMailMode()) {
         $block_attributes = array('style' => 'border-left: 3px solid #8C98B8;
       color: #6B748C;
       font-style: italic;
       margin: 4px 0 12px 0;
       padding: 8px 12px;
       background-color: #F8F9FC;');
         $head_attributes = array('style' => 'font-style: normal;
       padding-bottom: 4px;');
         $reply_attributes = array('style' => 'margin: 0;
       padding: 0;
       border: 0;
       color: rgb(107, 116, 140);');
     } else {
         $block_attributes = array('class' => 'remarkup-reply-block');
         $head_attributes = array('class' => 'remarkup-reply-head');
         $reply_attributes = array('class' => 'remarkup-reply-body');
     }
     return phutil_tag('blockquote', $block_attributes, array("\n", phutil_tag('div', $head_attributes, $text), "\n", phutil_tag('div', $reply_attributes, $children), "\n"));
 }
开发者ID:barcelonascience,项目名称:libphutil,代码行数:35,代码来源:PhutilRemarkupReplyBlockRule.php


示例12: parseLinterOutput

 protected function parseLinterOutput($path, $err, $stdout, $stderr)
 {
     $lines = phutil_split_lines($stderr, false);
     $messages = array();
     foreach ($lines as $line) {
         $matches = explode(':', $line, 6);
         if (count($matches) === 6) {
             $message = new ArcanistLintMessage();
             $message->setPath($path);
             $message->setLine($matches[3]);
             $message->setChar($matches[4]);
             $code = "E00";
             $message->setCode($code);
             $message->setName($this->getLinterName());
             $message->setDescription(ucfirst(trim($matches[5])));
             $severity = $this->getLintMessageSeverity($code);
             $message->setSeverity($severity);
             $messages[] = $message;
         }
         if (count($matches) === 3) {
             $message = new ArcanistLintMessage();
             $message->setPath($path);
             $message->setLine($matches[1]);
             $code = "E01";
             $message->setCode($code);
             $message->setName($this->getLinterName());
             $message->setDescription(ucfirst(trim($matches[2])));
             $severity = $this->getLintMessageSeverity($code);
             $message->setSeverity($severity);
             $messages[] = $message;
         }
     }
     return $messages;
 }
开发者ID:kalbasit,项目名称:arcanist-go,代码行数:34,代码来源:ArcanistGoVetLinter.php


示例13: parseLinterOutput

 protected function parseLinterOutput($path, $err, $stdout, $stderr)
 {
     $lines = phutil_split_lines($stderr, false);
     $messages = array();
     foreach ($lines as $line) {
         $matches = null;
         if (!preg_match('/(.*?):(\\d+): (.*?)$/', $line, $matches)) {
             continue;
         }
         foreach ($matches as $key => $match) {
             $matches[$key] = trim($match);
         }
         $code = head(explode(',', $matches[3]));
         $message = new ArcanistLintMessage();
         $message->setPath($path);
         $message->setLine($matches[2]);
         $message->setCode($this->getLinterName());
         $message->setName(pht('Syntax Error'));
         $message->setDescription($matches[3]);
         $message->setSeverity($this->getLintMessageSeverity($code));
         $messages[] = $message;
     }
     if ($err && !$messages) {
         return false;
     }
     return $messages;
 }
开发者ID:ivoryxiong,项目名称:arcanist,代码行数:27,代码来源:ArcanistRubyLinter.php


示例14: run

 public function run()
 {
     $root = $this->getWorkingCopy()->getProjectRoot() . '/extension/';
     $start_time = microtime(true);
     id(new ExecFuture('phpize && ./configure && make -j4'))->setCWD($root)->resolvex();
     $out = id(new ExecFuture('make -f Makefile.local test_with_exit_status'))->setCWD($root)->setEnv(array('TEST_PHP_ARGS' => '-q'))->resolvex();
     // NOTE: REPORT_EXIT_STATUS doesn't seem to work properly in some versions
     // of PHP. Just "parse" stdout to approximate the results.
     list($stdout) = $out;
     $tests = array();
     foreach (phutil_split_lines($stdout) as $line) {
         $matches = null;
         // NOTE: The test script writes the name of the test originally, then
         // uses "\r" to erase it and write the result. This splits as a single
         // line.
         if (preg_match('/^TEST .*\\r(PASS|FAIL) (.*)/', $line, $matches)) {
             if ($matches[1] == 'PASS') {
                 $result = ArcanistUnitTestResult::RESULT_PASS;
             } else {
                 $result = ArcanistUnitTestResult::RESULT_FAIL;
             }
             $name = trim($matches[2]);
             $tests[] = id(new ArcanistUnitTestResult())->setName($name)->setResult($result)->setDuration(microtime(true) - $start_time);
         }
     }
     return $tests;
 }
开发者ID:heartshare,项目名称:VagrantForPhp,代码行数:27,代码来源:XHProfUnitTestEngine.php


示例15: stripQuotedText

 private function stripQuotedText($body)
 {
     // Look for "On <date>, <user> wrote:". This may be split across multiple
     // lines. We need to be careful not to remove all of a message like this:
     //
     //   On which day do you want to meet?
     //
     //   On <date>, <user> wrote:
     //   > Let's set up a meeting.
     $start = null;
     $lines = phutil_split_lines($body);
     foreach ($lines as $key => $line) {
         if (preg_match('/^\\s*>?\\s*On\\b/', $line)) {
             $start = $key;
         }
         if ($start !== null) {
             if (preg_match('/\\bwrote:/', $line)) {
                 $lines = array_slice($lines, 0, $start);
                 $body = implode('', $lines);
                 break;
             }
         }
     }
     // Outlook english
     $body = preg_replace('/^\\s*(> )?-----Original Message-----.*?/imsU', '', $body);
     // Outlook danish
     $body = preg_replace('/^\\s*(> )?-----Oprindelig Meddelelse-----.*?/imsU', '', $body);
     // See example in T3217.
     $body = preg_replace('/^________________________________________\\s+From:.*?/imsU', '', $body);
     return rtrim($body);
 }
开发者ID:denghp,项目名称:phabricator,代码行数:31,代码来源:PhabricatorMetaMTAEmailBodyParser.php


示例16: summarizeCommitMessage

 public static function summarizeCommitMessage($message)
 {
     $max_bytes = id(new PhabricatorRepositoryCommit())->getColumnMaximumByteLength('summary');
     $summary = phutil_split_lines($message, $retain_endings = false);
     $summary = head($summary);
     $summary = id(new PhutilUTF8StringTruncator())->setMaximumBytes($max_bytes)->setMaximumGlyphs(80)->truncateString($summary);
     return $summary;
 }
开发者ID:endlessm,项目名称:phabricator,代码行数:8,代码来源:PhabricatorRepositoryCommitData.php


示例17: strPadLines

 private static function strPadLines($text, $num_spaces = 2)
 {
     $text_lines = phutil_split_lines($text);
     foreach ($text_lines as $linenr => $line) {
         $text_lines[$linenr] = str_repeat(" ", $num_spaces) . $line;
     }
     return implode("", $text_lines);
 }
开发者ID:chaozhang80,项目名称:tool-package,代码行数:8,代码来源:PhutilContextFreeGrammar.php


示例18: markupText

 public function markupText($text, $children)
 {
     if ($this->getEngine()->isTextMode()) {
         $lines = phutil_split_lines($children);
         return '> ' . implode("\n> ", $lines);
     }
     return phutil_tag('blockquote', array(), $children);
 }
开发者ID:fengshao0907,项目名称:libphutil,代码行数:8,代码来源:PhutilRemarkupQuotesBlockRule.php


示例19: markupText

 public function markupText($text, $children)
 {
     $text = preg_replace('/%%%\\s*$/', '', substr($text, 3));
     if ($this->getEngine()->isTextMode()) {
         return $text;
     }
     $text = phutil_split_lines($text, $retain_endings = true);
     return phutil_implode_html(phutil_tag('br', array()), $text);
 }
开发者ID:lsubra,项目名称:libphutil,代码行数:9,代码来源:PhutilRemarkupLiteralBlockRule.php


示例20: receiveMessage

 public function receiveMessage(PhabricatorBotMessage $message)
 {
     switch ($message->getCommand()) {
         case 'MESSAGE':
             $matches = null;
             $text = $message->getBody();
             $target_name = $message->getTarget()->getName();
             if (empty($this->recentlyMentioned[$target_name])) {
                 $this->recentlyMentioned[$target_name] = array();
             }
             $pattern = '@^' . '(?:' . $this->getConfig('nick', 'phabot') . ')?' . '.?\\s*tell me about ' . '(.*)' . '$@';
             if (preg_match($pattern, $text, $matches)) {
                 $slug = $matches[1];
                 $quiet_until = idx($this->recentlyMentioned[$target_name], $slug, 0) + 60 * 10;
                 if (time() < $quiet_until) {
                     // Remain quiet on this channel.
                     break;
                 } else {
                     $this->recentlyMentioned[$target_name][$slug] = time();
                 }
                 try {
                     $result = $this->getConduit()->callMethodSynchronous('phriction.info', array('slug' => 'docbot/docs/' . $slug));
                 } catch (ConduitClientException $ex) {
                     phlog($ex);
                     $result = null;
                 }
                 $response = array();
                 if ($result) {
                     $content = phutil_split_lines($result['content'], $retain_newlines = false);
                     foreach ($content as $line) {
                         $response = array_merge($response, str_split($line, 400));
                         if (count($response) >= 3) {
                             break;
                         }
                     }
                 } else {
                     $response[] = "Nothing to say about " . $slug;
                 }
                 foreach (array_slice($response, 0, 3) as $output) {
                     $this->replyTo($message, html_entity_decode($output));
                 }
                 break;
             }
             $pattern = '@' . $this->getConfig('nick', 'phabot') . ' remember ' . '(.*?)' . ' as:' . '(.*)$' . '@';
             if (preg_match($pattern, $text, $matches)) {
                 $result = $this->getConduit()->callMethodSynchronous('phriction.edit', array('slug' => 'docbot/docs/' . $matches[1], 'content' => $matches[2]));
                 $slug = explode('/', trim($result['slug'], '/'), 3);
                 $output = "Saved as '{$slug[2]}' at {$result['uri']}";
                 $this->replyTo($message, $output);
                 unset($this->recentlyMentioned[$target_name][$slug[2]]);
                 unset($this->recentlyMentioned[$target_name][$matches[1]]);
                 break;
             }
             break;
     }
 }
开发者ID:fengshao0907,项目名称:disqus-arcanist,代码行数:56,代码来源:PhabricatorBotDocHandler.php



注:本文中的phutil_split_lines函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP phutil_tag函数代码示例发布时间:2022-05-15
下一篇:
PHP phutil_safe_html函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap