当前位置: 首页>>代码示例>>PHP>>正文


PHP phutil_split_lines函数代码示例

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


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


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