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

PHP last_key函数代码示例

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

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



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

示例1: execute

 public function execute(PhutilArgumentParser $args)
 {
     $console = PhutilConsole::getConsole();
     $ids = $args->getArg('id');
     if (!$ids) {
         throw new PhutilArgumentUsageException(pht("Use the '%s' flag to specify one or more SMS messages to show.", '--id'));
     }
     $messages = id(new PhabricatorSMS())->loadAllWhere('id IN (%Ld)', $ids);
     if ($ids) {
         $ids = array_fuse($ids);
         $missing = array_diff_key($ids, $messages);
         if ($missing) {
             throw new PhutilArgumentUsageException(pht('Some specified SMS messages do not exist: %s', implode(', ', array_keys($missing))));
         }
     }
     $last_key = last_key($messages);
     foreach ($messages as $message_key => $message) {
         $info = array();
         $info[] = pht('PROPERTIES');
         $info[] = pht('ID: %d', $message->getID());
         $info[] = pht('Status: %s', $message->getSendStatus());
         $info[] = pht('To: %s', $message->getToNumber());
         $info[] = pht('From: %s', $message->getFromNumber());
         $info[] = null;
         $info[] = pht('BODY');
         $info[] = $message->getBody();
         $info[] = null;
         $console->writeOut('%s', implode("\n", $info));
         if ($message_key != $last_key) {
             $console->writeOut("\n%s\n\n", str_repeat('-', 80));
         }
     }
 }
开发者ID:pugong,项目名称:phabricator,代码行数:33,代码来源:PhabricatorSMSManagementShowOutboundWorkflow.php


示例2: getPathArgumentForLinterFuture

 protected function getPathArgumentForLinterFuture($path)
 {
     $full_path = Filesystem::resolvePath($path);
     $ret = array($full_path);
     // The |path| we get fed needs to be made relative to the project_root,
     // otherwise the |engine| won't recognise it.
     $relative_path = Filesystem::readablePath($full_path, $this->getProjectRoot());
     $changed = $this->getEngine()->getPathChangedLines($relative_path);
     if ($changed !== null) {
         // Convert the ordered set of changed lines to a list of ranges.
         $changed_lines = array_keys(array_filter($changed));
         $ranges = array(array($changed_lines[0], $changed_lines[0]));
         foreach (array_slice($changed_lines, 1) as $line) {
             $range = last($ranges);
             if ($range[1] + 1 === $line) {
                 ++$range[1];
                 $ranges[last_key($ranges)] = $range;
             } else {
                 $ranges[] = array($line, $line);
             }
         }
         foreach ($ranges as $range) {
             $ret[] = sprintf('--lines=%d-%d', $range[0], $range[1]);
         }
     }
     return csprintf('%Ls', $ret);
 }
开发者ID:nickhutchinson,项目名称:morefas-phabricator,代码行数:27,代码来源:FnYAPFLinter.php


示例3: __construct

 public function __construct(AphrontDatabaseConnection $conn, $pattern)
 {
     $this->conn = $conn;
     $args = func_get_args();
     $args = array_slice($args, 2);
     $this->query = vqsprintf($conn, $pattern, $args);
     self::$futures[] = $this;
     $this->id = last_key(self::$futures);
 }
开发者ID:chaozhang80,项目名称:tool-package,代码行数:9,代码来源:QueryFuture.php


示例4: buildMailSection

 public function buildMailSection()
 {
     $inlines = $this->getInlines();
     $comments = mpull($inlines, 'getComment');
     $comments = mpull($comments, null, 'getPHID');
     $parents = $this->loadParents($comments);
     $all_comments = $comments + $parents;
     $this->changesets = $this->loadChangesets($all_comments);
     $this->authors = $this->loadAuthors($all_comments);
     $groups = $this->groupInlines($inlines);
     $hunk_parser = new DifferentialHunkParser();
     $spacer_text = null;
     $spacer_html = phutil_tag('br');
     $section = new PhabricatorMetaMTAMailSection();
     $last_group_key = last_key($groups);
     foreach ($groups as $changeset_id => $group) {
         $changeset = $this->getChangeset($changeset_id);
         if (!$changeset) {
             continue;
         }
         $is_last_group = $changeset_id == $last_group_key;
         $last_inline_key = last_key($group);
         foreach ($group as $inline_key => $inline) {
             $comment = $inline->getComment();
             $parent_phid = $comment->getReplyToCommentPHID();
             $is_last_inline = $inline_key == $last_inline_key;
             $context_text = null;
             $context_html = null;
             if ($parent_phid) {
                 $parent = idx($parents, $parent_phid);
                 if ($parent) {
                     $context_text = $this->renderInline($parent, false, true);
                     $context_html = $this->renderInline($parent, true, true);
                 }
             } else {
                 $patch_text = $this->getPatch($hunk_parser, $comment, false);
                 $context_text = $this->renderPatch($comment, $patch_text, false);
                 $patch_html = $this->getPatch($hunk_parser, $comment, true);
                 $context_html = $this->renderPatch($comment, $patch_html, true);
             }
             $render_text = $this->renderInline($comment, false, false);
             $render_html = $this->renderInline($comment, true, false);
             $section->addPlaintextFragment($context_text);
             $section->addPlaintextFragment($spacer_text);
             $section->addPlaintextFragment($render_text);
             $html_fragment = $this->renderContentBox(array($context_html, $render_html));
             $section->addHTMLFragment($html_fragment);
             if (!$is_last_group || !$is_last_inline) {
                 $section->addPlaintextFragment($spacer_text);
                 $section->addHTMLFragment($spacer_html);
             }
         }
     }
     return $section;
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:55,代码来源:DifferentialInlineCommentMailView.php


示例5: popTime

 public static function popTime($key)
 {
     if ($key !== last_key(self::$stack)) {
         throw new Exception(pht('%s with bad key.', __METHOD__));
     }
     array_pop(self::$stack);
     if (empty(self::$stack)) {
         date_default_timezone_set(self::$originalZone);
     } else {
         $frame = end(self::$stack);
         date_default_timezone_set($frame['timezone']);
     }
 }
开发者ID:pugong,项目名称:phabricator,代码行数:13,代码来源:PhabricatorTime.php


示例6: popTime

 public static function popTime($key)
 {
     if ($key !== last_key(self::$stack)) {
         throw new Exception('PhabricatorTime::popTime with bad key.');
     }
     array_pop(self::$stack);
     if (empty(self::$stack)) {
         date_default_timezone_set(self::$originalZone);
     } else {
         $frame = end(self::$stack);
         date_default_timezone_set($frame['timezone']);
     }
 }
开发者ID:denghp,项目名称:phabricator,代码行数:13,代码来源:PhabricatorTime.php


示例7: markupText

 public function markupText($text)
 {
     $matches = array();
     $rows = array();
     foreach (explode("\n", $text) as $line) {
         // Ignore ending delimiters.
         $line = rtrim($line, '|');
         preg_match_all('/\\|([^|]*)/', $line, $matches);
         $headings = true;
         $cells = array();
         foreach ($matches[1] as $cell) {
             $cell = trim($cell);
             // Cell isn't empty and doesn't look like heading.
             if (!preg_match('/^(|--+)$/', $cell)) {
                 $headings = false;
             }
             $cells[] = array('type' => 'td', 'content' => $cell);
         }
         if (!$headings) {
             $rows[] = $cells;
         } else {
             if ($rows) {
                 // Mark previous row with headings.
                 foreach ($cells as $i => $cell) {
                     if ($cell['content']) {
                         $rows[last_key($rows)][$i]['type'] = 'th';
                     }
                 }
             }
         }
     }
     if (!$rows) {
         return $this->applyRules($text);
     }
     $out = array();
     $out[] = "<table class=\"remarkup-table\">\n";
     foreach ($rows as $cells) {
         $out[] = '<tr>';
         foreach ($cells as $cell) {
             $out[] = '<' . $cell['type'] . '>';
             $out[] = $this->applyRules($cell['content']);
             $out[] = '</' . $cell['type'] . '>';
         }
         $out[] = "</tr>\n";
     }
     $out[] = "</table>\n";
     return implode($out);
 }
开发者ID:relrod,项目名称:libphutil,代码行数:48,代码来源:PhutilRemarkupEngineRemarkupSimpleTableBlockRule.php


示例8: execute

 public function execute()
 {
     try {
         $cf = TransactionLog::cf();
         $entries = $cf->getSlice($this->_log, '', '', true, $this->_lines);
         if ($entries) {
             $since = last_key($entries);
             $this->outputEntriesSince($this->_log, $since);
         } else {
             echo "No data found\n";
         }
     } catch (\Exception $e) {
         if ($e->getCode() == 404) {
             echo "No log exists";
         }
         throw $e;
     }
 }
开发者ID:bundl,项目名称:lumberjack,代码行数:18,代码来源:Tail.php


示例9: __construct

 public function __construct($code)
 {
     // If this is the first time we're building a guard, push the default
     // locale onto the bottom of the stack. We'll never remove it.
     if (empty(self::$stack)) {
         self::$stack[] = PhabricatorEnv::getLocaleCode();
     }
     // If there's no locale, use the server default locale.
     if (!$code) {
         $code = self::$stack[0];
     }
     // Push this new locale onto the stack and set it as the active locale.
     // We keep track of which key this guard owns, in case guards are destroyed
     // out-of-order.
     self::$stack[] = $code;
     $this->key = last_key(self::$stack);
     PhabricatorEnv::setLocaleCode($code);
 }
开发者ID:pugong,项目名称:phabricator,代码行数:18,代码来源:PhabricatorLocaleScopeGuard.php


示例10: makeContent

 private final function makeContent($include)
 {
     $results = array();
     $lines = explode("\n", $this->changes);
     // NOTE: To determine whether the recomposed file should have a trailing
     // newline, we look for a "\ No newline at end of file" line which appears
     // after a line which we don't exclude. For example, if we're constructing
     // the "new" side of a diff (excluding "-"), we want to ignore this one:
     //
     //    - x
     //    \ No newline at end of file
     //    + x
     //
     // ...since it's talking about the "old" side of the diff, but interpret
     // this as meaning we should omit the newline:
     //
     //    - x
     //    + x
     //    \ No newline at end of file
     $n = strpos($include, '+') !== false ? $this->newOffset : $this->oldOffset;
     $use_next_newline = false;
     foreach ($lines as $line) {
         if (!isset($line[0])) {
             continue;
         }
         if ($line[0] == '\\') {
             if ($use_next_newline) {
                 $results[last_key($results)] = rtrim(end($results), "\n");
             }
         } else {
             if (strpos($include, $line[0]) === false) {
                 $use_next_newline = false;
             } else {
                 $use_next_newline = true;
                 $results[$n] = substr($line, 1) . "\n";
             }
         }
         if ($line[0] == ' ' || strpos($include, $line[0]) !== false) {
             $n++;
         }
     }
     return $results;
 }
开发者ID:nexeck,项目名称:phabricator,代码行数:43,代码来源:DifferentialHunk.php


示例11: render

 public function render()
 {
     require_celerity_resource('phabricator-source-code-view-css');
     require_celerity_resource('syntax-highlighting-css');
     Javelin::initBehavior('phabricator-oncopy', array());
     if ($this->canClickHighlight) {
         Javelin::initBehavior('phabricator-line-linker');
     }
     $line_number = 1;
     $rows = array();
     $lines = $this->lines;
     if ($this->truncatedFirstLines) {
         $lines[] = phutil_tag('span', array('class' => 'c'), pht('...'));
     } else {
         if ($this->truncatedFirstBytes) {
             $last_key = last_key($lines);
             $lines[$last_key] = hsprintf('%s%s', $lines[$last_key], phutil_tag('span', array('class' => 'c'), pht('...')));
         }
     }
     foreach ($lines as $line) {
         // NOTE: See phabricator-oncopy behavior.
         $content_line = hsprintf("​%s", $line);
         $row_attributes = array();
         if (isset($this->highlights[$line_number])) {
             $row_attributes['class'] = 'phabricator-source-highlight';
         }
         if ($this->canClickHighlight) {
             $line_uri = $this->uri . '$' . $line_number;
             $line_href = (string) new PhutilURI($line_uri);
             $tag_number = javelin_tag('a', array('href' => $line_href), $line_number);
         } else {
             $tag_number = javelin_tag('span', array(), $line_number);
         }
         $rows[] = phutil_tag('tr', $row_attributes, array(javelin_tag('th', array('class' => 'phabricator-source-line', 'sigil' => 'phabricator-source-line'), $tag_number), phutil_tag('td', array('class' => 'phabricator-source-code'), $content_line)));
         $line_number++;
     }
     $classes = array();
     $classes[] = 'phabricator-source-code-view';
     $classes[] = 'remarkup-code';
     $classes[] = 'PhabricatorMonospaced';
     return phutil_tag_div('phabricator-source-code-container', javelin_tag('table', array('class' => implode(' ', $classes), 'sigil' => 'phabricator-source'), phutil_implode_html('', $rows)));
 }
开发者ID:pugong,项目名称:phabricator,代码行数:42,代码来源:PhabricatorSourceCodeView.php


示例12: buildResponse

 private function buildResponse($title, $body)
 {
     $nav = $this->buildSideNavView();
     $nav->selectFilter('database/');
     if (!$title) {
         $title = pht('Database Status');
     }
     $ref = $this->ref;
     $database = $this->database;
     $table = $this->table;
     $column = $this->column;
     $key = $this->key;
     $links = array();
     $links[] = array(pht('Database Status'), 'database/');
     if ($database) {
         $links[] = array($database, "database/{$ref}/{$database}/");
     }
     if ($table) {
         $links[] = array($table, "database/{$ref}/{$database}/{$table}/");
     }
     if ($column) {
         $links[] = array($column, "database/{$ref}/{$database}/{$table}/col/{$column}/");
     }
     if ($key) {
         $links[] = array($key, "database/{$ref}/{$database}/{$table}/key/{$key}/");
     }
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->setBorder(true);
     $last_key = last_key($links);
     foreach ($links as $link_key => $link) {
         list($name, $href) = $link;
         if ($link_key == $last_key) {
             $crumbs->addTextCrumb($name);
         } else {
             $crumbs->addTextCrumb($name, $this->getApplicationURI($href));
         }
     }
     $doc_link = PhabricatorEnv::getDoclink('Managing Storage Adjustments');
     $header = id(new PHUIHeaderView())->setHeader($title)->setProfileHeader(true)->addActionLink(id(new PHUIButtonView())->setTag('a')->setIcon('fa-book')->setHref($doc_link)->setText(pht('Learn More')));
     $content = id(new PhabricatorConfigPageView())->setHeader($header)->setContent($body);
     return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->setNavigation($nav)->appendChild($content)->addClass('white-background');
 }
开发者ID:NeoArmageddon,项目名称:phabricator,代码行数:42,代码来源:PhabricatorConfigDatabaseStatusController.php


示例13: addFuture

 /**
  * Add another future to the set of futures. This is useful if you have a
  * set of futures to run mostly in parallel, but some futures depend on
  * others.
  *
  * @param Future  @{class:Future} to add to iterator
  * @task basics
  */
 public function addFuture(Future $future, $key = null)
 {
     if ($key === null) {
         $this->futures[] = $future;
         $this->wait[] = last_key($this->futures);
     } else {
         if (!isset($this->futures[$key])) {
             $this->futures[$key] = $future;
             $this->wait[] = $key;
         } else {
             throw new Exception("Invalid key {$key}");
         }
     }
     // Start running the future if we don't have $this->limit futures running
     // already. updateWorkingSet() won't start running the future if there's no
     // limit, so we'll manually poke it here in that case.
     $this->updateWorkingSet();
     if (!$this->limit) {
         $future->isReady();
     }
     return $this;
 }
开发者ID:lsubra,项目名称:libphutil,代码行数:30,代码来源:FutureIterator.php


示例14: markupText

 public function markupText($text, $children)
 {
     $lines = explode("\n", $text);
     $first_key = head_key($lines);
     $last_key = last_key($lines);
     while (trim($lines[$last_key]) === '') {
         unset($lines[$last_key]);
         $last_key = last_key($lines);
     }
     $matches = null;
     preg_match(self::START_BLOCK_PATTERN, head($lines), $matches);
     $argv = array();
     if (isset($matches[2])) {
         $argv = id(new PhutilSimpleOptions())->parse($matches[2]);
     }
     $interpreters = id(new PhutilSymbolLoader())->setAncestorClass('PhutilRemarkupBlockInterpreter')->loadObjects();
     foreach ($interpreters as $interpreter) {
         $interpreter->setEngine($this->getEngine());
     }
     $lines[$first_key] = preg_replace(self::START_BLOCK_PATTERN, '', $lines[$first_key]);
     $lines[$last_key] = preg_replace(self::END_BLOCK_PATTERN, '', $lines[$last_key]);
     if (trim($lines[$first_key]) === '') {
         unset($lines[$first_key]);
     }
     if (trim($lines[$last_key]) === '') {
         unset($lines[$last_key]);
     }
     $content = implode("\n", $lines);
     $interpreters = mpull($interpreters, null, 'getInterpreterName');
     if (isset($interpreters[$matches[1]])) {
         return $interpreters[$matches[1]]->markupContent($content, $argv);
     }
     $message = pht('No interpreter found: %s', $matches[1]);
     if ($this->getEngine()->isTextMode()) {
         return '(' . $message . ')';
     }
     return phutil_tag('div', array('class' => 'remarkup-interpreter-error'), $message);
 }
开发者ID:lsubra,项目名称:libphutil,代码行数:38,代码来源:PhutilRemarkupInterpreterBlockRule.php


示例15: markupText

 public function markupText($text, $children)
 {
     $matches = array();
     $rows = array();
     foreach (explode("\n", $text) as $line) {
         // Ignore ending delimiters.
         $line = rtrim($line, '|');
         // NOTE: The complexity in this regular expression allows us to match
         // a table like "| a | [[ href | b ]] | c |".
         preg_match_all('/\\|' . '(' . '(?:' . '(?:\\[\\[.*?\\]\\])' . '|' . '(?:[^|[]+)' . '|' . '(?:\\[[^\\|[])' . ')*' . ')/', $line, $matches);
         $headings = true;
         $cells = array();
         foreach ($matches[1] as $cell) {
             $cell = trim($cell);
             // Cell isn't empty and doesn't look like heading.
             if (!preg_match('/^(|--+)$/', $cell)) {
                 $headings = false;
             }
             $cells[] = array('type' => 'td', 'content' => $this->applyRules($cell));
         }
         if (!$headings) {
             $rows[] = array('type' => 'tr', 'content' => $cells);
         } else {
             if ($rows) {
                 // Mark previous row with headings.
                 foreach ($cells as $i => $cell) {
                     if ($cell['content']) {
                         $rows[last_key($rows)]['content'][$i]['type'] = 'th';
                     }
                 }
             }
         }
     }
     if (!$rows) {
         return $this->applyRules($text);
     }
     return $this->renderRemarkupTable($rows);
 }
开发者ID:jasteele12,项目名称:prb_lint_tests,代码行数:38,代码来源:PhutilRemarkupEngineRemarkupSimpleTableBlockRule.php


示例16: getSummaryParts

 /**
  * Get diff parts, but replace large blocks of unchanged text with "."
  * parts representing missing context.
  */
 public function getSummaryParts()
 {
     $parts = $this->getParts();
     $head_key = head_key($parts);
     $last_key = last_key($parts);
     $results = array();
     foreach ($parts as $key => $part) {
         $is_head = $key == $head_key;
         $is_last = $key == $last_key;
         switch ($part['type']) {
             case '=':
                 $pieces = $this->splitTextForSummary($part['text']);
                 if ($is_head || $is_last) {
                     $need = 2;
                 } else {
                     $need = 3;
                 }
                 // We don't have enough pieces to omit anything, so just continue.
                 if (count($pieces) < $need) {
                     $results[] = $part;
                     break;
                 }
                 if (!$is_head) {
                     $results[] = array('type' => '=', 'text' => head($pieces));
                 }
                 $results[] = array('type' => '.', 'text' => null);
                 if (!$is_last) {
                     $results[] = array('type' => '=', 'text' => last($pieces));
                 }
                 break;
             default:
                 $results[] = $part;
                 break;
         }
     }
     return $results;
 }
开发者ID:endlessm,项目名称:libphutil,代码行数:41,代码来源:PhutilProseDiff.php


示例17: renderBurn

 public function renderBurn()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $handle = null;
     $project_phid = $request->getStr('project');
     if ($project_phid) {
         $phids = array($project_phid);
         $handles = $this->loadViewerHandles($phids);
         $handle = $handles[$project_phid];
     }
     $table = new ManiphestTransaction();
     $conn = $table->establishConnection('r');
     $joins = '';
     if ($project_phid) {
         $joins = qsprintf($conn, 'JOIN %T t ON x.taskID = t.id
       JOIN %T p ON p.taskPHID = t.phid AND p.projectPHID = %s', id(new ManiphestTask())->getTableName(), id(new ManiphestTaskProject())->getTableName(), $project_phid);
     }
     $data = queryfx_all($conn, 'SELECT x.oldValue, x.newValue, x.dateCreated FROM %T x %Q
     WHERE transactionType = %s
     ORDER BY x.dateCreated ASC', $table->getTableName(), $joins, ManiphestTransactionType::TYPE_STATUS);
     $stats = array();
     $day_buckets = array();
     $open_tasks = array();
     foreach ($data as $key => $row) {
         // NOTE: Hack to avoid json_decode().
         $oldv = trim($row['oldValue'], '"');
         $newv = trim($row['newValue'], '"');
         $old_is_open = $oldv === (string) ManiphestTaskStatus::STATUS_OPEN;
         $new_is_open = $newv === (string) ManiphestTaskStatus::STATUS_OPEN;
         $is_open = $new_is_open && !$old_is_open;
         $is_close = $old_is_open && !$new_is_open;
         $data[$key]['_is_open'] = $is_open;
         $data[$key]['_is_close'] = $is_close;
         if (!$is_open && !$is_close) {
             // This is either some kind of bogus event, or a resolution change
             // (e.g., resolved -> invalid). Just skip it.
             continue;
         }
         $day_bucket = phabricator_format_local_time($row['dateCreated'], $user, 'Yz');
         $day_buckets[$day_bucket] = $row['dateCreated'];
         if (empty($stats[$day_bucket])) {
             $stats[$day_bucket] = array('open' => 0, 'close' => 0);
         }
         $stats[$day_bucket][$is_close ? 'close' : 'open']++;
     }
     $template = array('open' => 0, 'close' => 0);
     $rows = array();
     $rowc = array();
     $last_month = null;
     $last_month_epoch = null;
     $last_week = null;
     $last_week_epoch = null;
     $week = null;
     $month = null;
     $last = last_key($stats) - 1;
     $period = $template;
     foreach ($stats as $bucket => $info) {
         $epoch = $day_buckets[$bucket];
         $week_bucket = phabricator_format_local_time($epoch, $user, 'YW');
         if ($week_bucket != $last_week) {
             if ($week) {
                 $rows[] = $this->formatBurnRow('Week of ' . phabricator_date($last_week_epoch, $user), $week);
                 $rowc[] = 'week';
             }
             $week = $template;
             $last_week = $week_bucket;
             $last_week_epoch = $epoch;
         }
         $month_bucket = phabricator_format_local_time($epoch, $user, 'Ym');
         if ($month_bucket != $last_month) {
             if ($month) {
                 $rows[] = $this->formatBurnRow(phabricator_format_local_time($last_month_epoch, $user, 'F, Y'), $month);
                 $rowc[] = 'month';
             }
             $month = $template;
             $last_month = $month_bucket;
             $last_month_epoch = $epoch;
         }
         $rows[] = $this->formatBurnRow(phabricator_date($epoch, $user), $info);
         $rowc[] = null;
         $week['open'] += $info['open'];
         $week['close'] += $info['close'];
         $month['open'] += $info['open'];
         $month['close'] += $info['close'];
         $period['open'] += $info['open'];
         $period['close'] += $info['close'];
     }
     if ($week) {
         $rows[] = $this->formatBurnRow('Week To Date', $week);
         $rowc[] = 'week';
     }
     if ($month) {
         $rows[] = $this->formatBurnRow('Month To Date', $month);
         $rowc[] = 'month';
     }
     $rows[] = $this->formatBurnRow('All Time', $period);
     $rowc[] = 'aggregate';
     $rows = array_reverse($rows);
     $rowc = array_reverse($rowc);
//.........这里部分代码省略.........
开发者ID:rudimk,项目名称:phabricator,代码行数:101,代码来源:ManiphestReportController.php


示例18: run


//.........这里部分代码省略.........
         $lint_future = $conduit->callMethod('diffusion.getlintmessages', array('repositoryPHID' => idx($this->loadProjectRepository(), 'phid'), 'branch' => '', 'commit' => $api->getBaseCommit(), 'files' => array_keys($all_paths)));
     }
     $failed = null;
     try {
         $engine->run();
     } catch (Exception $ex) {
         $failed = $ex;
     }
     $results = $engine->getResults();
     if ($this->getArgument('only-new')) {
         $total = 0;
         foreach ($results as $result) {
             $total += count($result->getMessages());
         }
         // Don't wait for response with default value of --only-new.
         $timeout = null;
         if ($this->getArgument('only-new') === null || !$total) {
             $timeout = 0;
         }
         $raw_messages = $this->resolveCall($lint_future, $timeout);
         if ($raw_messages && $total) {
             $old_messages = array();
             $line_maps = array();
             foreach ($raw_messages as $message) {
                 $path = $all_paths[$message['path']];
                 $line = $message['line'];
                 $code = $message['code'];
                 if (!isset($line_maps[$path])) {
                     $line_maps[$path] = $this->getChange($path)->buildLineMap();
                 }
                 $new_lines = idx($line_maps[$path], $line);
                 if (!$new_lines) {
                     // Unmodified lines after last hunk.
                     $last_old = $line_maps[$path] ? last_key($line_maps[$path]) : 0;
                     $news = array_filter($line_maps[$path]);
                     $last_new = $news ? last(end($news)) : 0;
                     $new_lines = array($line + $last_new - $last_old);
                 }
                 $error = array($code => array(true));
                 foreach ($new_lines as $new) {
                     if (isset($old_messages[$path][$new])) {
                         $old_messages[$path][$new][$code][] = true;
                         break;
                     }
                     $old_messages[$path][$new] =& $error;
                 }
                 unset($error);
             }
             foreach ($results as $result) {
                 foreach ($result->getMessages() as $message) {
                     $path = str_replace(DIRECTORY_SEPARATOR, '/', $message->getPath());
                     $line = $message->getLine();
                     $code = $message->getCode();
                     if (!empty($old_messages[$path][$line][$code])) {
                         $message->setObsolete(true);
                         array_pop($old_messages[$path][$line][$code]);
                     }
                 }
                 $result->sortAndFilterMessages();
             }
         }
     }
     if ($this->getArgument('never-apply-patches')) {
         $apply_patches = false;
     } else {
         $apply_patches = true;
开发者ID:barcelonascience,项目名称:arcanist,代码行数:67,代码来源:ArcanistLintWorkflow.php


示例19: splitTextIntoBlocks

 private function splitTextIntoBlocks($text, $depth = 0)
 {
     // Apply basic block and paragraph normalization to the text. NOTE: We don't
     // strip trailing whitespace because it is semantic in some contexts,
     // notably inlined diffs that the author intends to show as a code block.
     $text = phutil_split_lines($text, true);
     $block_rules = $this->blockRules;
     $blocks = array();
     $cursor = 0;
     $prev_block = array();
     while (isset($text[$cursor])) {
         $starting_cursor = $cursor;
         foreach ($block_rules as $block_rule) {
             $num_lines = $block_rule->getMatchingLineCount($text, $cursor);
             if ($num_lines) {
                 if ($blocks) {
                     $prev_block = last($blocks);
                 }
                 $curr_block = array('start' => $cursor, 'num_lines' => $num_lines, 'rule' => $block_rule, 'is_empty' => self::isEmptyBlock($text, $cursor, $num_lines), 'children' => array());
                 if ($prev_block && self::shouldMergeBlocks($text, $prev_block, $curr_block)) {
                     $blocks[last_key($blocks)]["num_lines"] += $curr_block["num_lines"];
                     $blocks[last_key($blocks)]["is_empty"] = $blocks[last_key($blocks)]["is_empty"] && $curr_block["is_empty"];
                 } else {
                     $blocks[] = $curr_block;
                 }
                 $cursor += $num_lines;
                 break;
             }
         }
         if ($starting_cursor === $cursor) {
             throw new Exception("Block in text did not match any block rule.");
         }
     }
     foreach ($blocks as $key => $block) {
         $lines = array_slice($text, $block['start'], $block['num_lines']);
         $blocks[$key]['text'] = implode('', $lines);
     }
     // Stop splitting child blocks apart if we get too deep. This arrests
     // any blocks which have looping child rules, and stops the stack from
     // exploding if someone writes a hilarious comment with 5,000 levels of
     // quoted text.
     if ($depth < self::MAX_CHILD_DEPTH) {
         foreach ($blocks as $key => $block) {
             $rule = $block['rule'];
             if (!$rule->supportsChildBlocks()) {
                 continue;
             }
             list($parent_text, $child_text) = $rule->extractChildText($block['text']);
             $blocks[$key]['text'] = $parent_text;
             $blocks[$key]['children'] = $this->splitTextIntoBlocks($child_text, $depth + 1);
         }
     }
     return $blocks;
 }
开发者ID:jasteele12,项目名称:prb_lint_tests,代码行数:54,代码来源:PhutilRemarkupEngine.php


示例20: renderBurn

 public function renderBurn()
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $handle = null;
     $project_phid = $request->getStr('project');
     if ($project_phid) {
         $phids = array($project_phid);
         $handles = $this->loadViewerHandles($phids);
         $handle = $handles[$project_phid];
     }
     $table = new ManiphestTransaction();
     $conn = $table->establishConnection('r');
     $joins = '';
     if ($project_phid) {
         $joins = qsprintf($conn, 'JOIN %T t ON x.objectPHID = t.phid
       JOIN %T p ON p.src = t.phid AND p.type = %d AND p.dst = %s', id(new ManiphestTask())->getTableName(), PhabricatorEdgeConfig::TABLE_NAME_EDGE, PhabricatorProjectObjectHasProjectEdgeType::EDGECONST, $project_phid);
     }
     $data = queryfx_all($conn, 'SELECT x.oldValue, x.newValue, x.dateCreated FROM %T x %Q
     WHERE transactionType = %s
     ORDER BY x.dateCreated ASC', $table->getTableName(), $joins, ManiphestTransaction::TYPE_STATUS);
     $stats = array();
     $day_buckets = array();
     $open_tasks = array();
     foreach ($data as $key => $row) {
         // NOTE: Hack to avoid json_decode().
         $oldv = trim($row['oldValue'], '"');
         $newv = trim($row['newValue'], '"');
         if ($oldv == 'null') {
             $old_is_open = false;
         } else {
             $old_is_open = ManiphestTaskStatus::isOpenStatus($oldv);
         }
         $new_is_open = ManiphestTaskStatus::isOpenStatus($newv);
         $is_open = $new_is_open && !$old_is_open;
         $is_close = $old_is_open && !$new_is_open;
         $data[$key]['_is_open'] = $is_open;
         $data[$key]['_is_close'] = $is_close;
         if (!$is_open && !$is_close) {
             // This is either some kind of bogus event, or a resolution change
             // (e.g., resolved -> invalid). Just skip it.
             continue;
         }
         $day_bucket = phabricator_format_local_time($row['dateCreated'], $viewer, 'Yz');
         $day_buckets[$day_bucket] = $row['dateCreated'];
         if (empty($stats[$day_bucket])) {
             $stats[$day_bucket] = array('open' => 0, 'close' => 0);
         }
         $stats[$day_bucket][$is_close ? 'close' : 'open']++;
     }
     $template = array('open' => 0, 'close' => 0);
     $rows = array();
     $rowc = array();
     $last_month = null;
     $last_month_epoch = null;
     $last_week = null;
     $last_week_epoch = null;
     $week = null;
     $month = null;
     $last = last_key($stats) - 1;
     $period = $template;
     foreach ($stats as $bucket => $info) {
         $epoch = $day_buckets[$bucket];
         $week_bucket = phabricator_format_local_time($epoch, $viewer, 'YW');
         if ($week_bucket != $last_week) {
             if ($week) {
                 $rows[] = $this->formatBurnRow(pht('Week of %s', phabricator_date($last_week_epoch, $viewer)), $week);
                 $rowc[] = 'week';
             }
             $week = $template;
             $last_week = $week_bucket;
             $last_week_epoch = $epoch;
         }
         $month_bucket = phabricator_format_local_time($epoch, $viewer, 'Ym');
         if ($month_bucket != $last_month) {
             if ($month) {
                 $rows[] = $this->formatBurnRow(phabricator_format_local_time($last_month_epoch, $viewer, 'F, Y'), $month);
                 $rowc[] = 'month';
             }
             $month = $template;
             $last_month = $month_bucket;
             $last_month_epoch = $epoch;
         }
         $rows[] = $this->formatBurnRow(phabricator_date($epoch, $viewer), $info);
         $rowc[] = null;
         $week['open'] += $info['open'];
         $week['close'] += $info['close'];
         $month['open'] += $info['open'];
         $month['close'] += $info['close'];
         $period['open'] += $info['open'];
         $period['close'] += $info['close'];
     }
     if ($week) {
         $rows[] = $this->formatBurnRow(pht('Week To Date'), $week);
         $rowc[] = 'week';
     }
     if ($month) {
         $rows[] = $this->formatBurnRow(pht('Month To Date'), $month);
         $rowc[] = 'month';
     }
//.........这里部分代码省略.........
开发者ID:truSense,项目名称:phabricator,代码行数:101,代码来源:ManiphestReportController.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP last_visited_issue函数代码示例发布时间:2022-05-15
下一篇:
PHP last_id函数代码示例发布时间: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