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


PHP last_key函数代码示例

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


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


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