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


PHP assert_instances_of函数代码示例

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


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

示例1: renderResultList

 protected function renderResultList(array $countdowns, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($countdowns, 'PhabricatorCountdown');
     $viewer = $this->requireViewer();
     $list = new PHUIObjectItemListView();
     $list->setUser($viewer);
     foreach ($countdowns as $countdown) {
         $id = $countdown->getID();
         $ended = false;
         $epoch = $countdown->getEpoch();
         if ($epoch <= PhabricatorTime::getNow()) {
             $ended = true;
         }
         $item = id(new PHUIObjectItemView())->setUser($viewer)->setObject($countdown)->setObjectName("C{$id}")->setHeader($countdown->getTitle())->setHref($this->getApplicationURI("{$id}/"))->addByline(pht('Created by %s', $handles[$countdown->getAuthorPHID()]->renderLink()));
         if ($ended) {
             $item->addAttribute(pht('Launched on %s', phabricator_datetime($epoch, $viewer)));
             $item->setDisabled(true);
         } else {
             $time_left = $epoch - PhabricatorTime::getNow();
             $num = round($time_left / (60 * 60 * 24));
             $noun = pht('Days');
             if ($num < 1) {
                 $num = round($time_left / (60 * 60), 1);
                 $noun = pht('Hours');
             }
             $item->setCountdown($num, $noun);
             $item->addAttribute(phabricator_datetime($epoch, $viewer));
         }
         $list->addItem($item);
     }
     $result = new PhabricatorApplicationSearchResultView();
     $result->setObjectList($list);
     $result->setNoDataString(pht('No countdowns found.'));
     return $result;
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:35,代码来源:PhabricatorCountdownSearchEngine.php

示例2: renderResultList

 protected function renderResultList(array $usertimes, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($usertimes, 'PhrequentUserTime');
     $viewer = $this->requireViewer();
     $view = id(new PHUIObjectItemListView())->setUser($viewer);
     foreach ($usertimes as $usertime) {
         $item = new PHUIObjectItemView();
         if ($usertime->getObjectPHID() === null) {
             $item->setHeader($usertime->getNote());
         } else {
             $obj = $handles[$usertime->getObjectPHID()];
             $item->setHeader($obj->getLinkName());
             $item->setHref($obj->getURI());
         }
         $item->setObject($usertime);
         $item->addByline(pht('Tracked: %s', $handles[$usertime->getUserPHID()]->renderLink()));
         $started_date = phabricator_date($usertime->getDateStarted(), $viewer);
         $item->addIcon('none', $started_date);
         $block = new PhrequentTimeBlock(array($usertime));
         $time_spent = $block->getTimeSpentOnObject($usertime->getObjectPHID(), PhabricatorTime::getNow());
         $time_spent = $time_spent == 0 ? 'none' : phutil_format_relative_time_detailed($time_spent);
         if ($usertime->getDateEnded() !== null) {
             $item->addAttribute(pht('Tracked %s', $time_spent));
             $item->addAttribute(pht('Ended on %s', phabricator_datetime($usertime->getDateEnded(), $viewer)));
         } else {
             $item->addAttribute(pht('Tracked %s so far', $time_spent));
             if ($usertime->getObjectPHID() !== null && $usertime->getUserPHID() === $viewer->getPHID()) {
                 $item->addAction(id(new PHUIListItemView())->setIcon('fa-stop')->addSigil('phrequent-stop-tracking')->setWorkflow(true)->setRenderNameAsTooltip(true)->setName(pht('Stop'))->setHref('/phrequent/track/stop/' . $usertime->getObjectPHID() . '/'));
             }
             $item->setBarColor('green');
         }
         $view->addItem($item);
     }
     return $view;
 }
开发者ID:denghp,项目名称:phabricator,代码行数:35,代码来源:PhrequentSearchEngine.php

示例3: setCaches

 /**
  * Set the caches which comprise this stack.
  *
  * @param   list<PhutilKeyValueCache> Ordered list of key-value caches.
  * @return  this
  * @task    config
  */
 public function setCaches(array $caches)
 {
     assert_instances_of($caches, 'PhutilKeyValueCache');
     $this->cachesForward = $caches;
     $this->cachesBackward = array_reverse($caches);
     return $this;
 }
开发者ID:barcelonascience,项目名称:libphutil,代码行数:14,代码来源:PhutilKeyValueCacheStack.php

示例4: loadMessagesForTags

 private function loadMessagesForTags(array $tags)
 {
     assert_instances_of($tags, 'DiffusionRepositoryTag');
     $drequest = $this->getDiffusionRequest();
     $repository = $drequest->getRepository();
     $futures = array();
     foreach ($tags as $key => $tag) {
         $futures[$key] = $repository->getLocalCommandFuture('cat-file tag %s', $tag->getName());
     }
     Futures($futures)->resolveAll();
     foreach ($tags as $key => $tag) {
         $future = $futures[$key];
         list($err, $stdout) = $future->resolve();
         $message = null;
         if ($err) {
             // Not all tags are actually "tag" objects: a "tag" object is only
             // created if you provide a message or sign the tag. Tags created with
             // `git tag x [commit]` are "lightweight tags" and `git cat-file tag`
             // will fail on them. This is fine: they don't have messages.
         } else {
             $parts = explode("\n\n", $stdout, 2);
             if (count($parts) == 2) {
                 $message = last($parts);
             }
         }
         $tag->attachMessage($message);
     }
     return $tags;
 }
开发者ID:denghp,项目名称:phabricator,代码行数:29,代码来源:DiffusionTagsQueryConduitAPIMethod.php

示例5: renderResultList

 protected function renderResultList(array $notifications, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($notifications, 'PhabricatorFeedStory');
     $viewer = $this->requireViewer();
     $image = id(new PHUIIconView())->setIconFont('fa-eye-slash');
     $button = id(new PHUIButtonView())->setTag('a')->addSigil('workflow')->setColor(PHUIButtonView::SIMPLE)->setIcon($image)->setText(pht('Mark All Read'));
     switch ($query->getQueryKey()) {
         case 'unread':
             $header = pht('Unread Notifications');
             $no_data = pht('You have no unread notifications.');
             break;
         default:
             $header = pht('Notifications');
             $no_data = pht('You have no notifications.');
             break;
     }
     $clear_uri = id(new PhutilURI('/notification/clear/'));
     if ($notifications) {
         $builder = id(new PhabricatorNotificationBuilder($notifications))->setUser($viewer);
         $view = $builder->buildView();
         $clear_uri->setQueryParam('chronoKey', head($notifications)->getChronologicalKey());
     } else {
         $view = phutil_tag_div('phabricator-notification no-notifications', $no_data);
         $button->setDisabled(true);
     }
     $button->setHref((string) $clear_uri);
     $view = id(new PHUIBoxView())->addPadding(PHUI::PADDING_MEDIUM)->addClass('phabricator-notification-list')->appendChild($view);
     $result = new PhabricatorApplicationSearchResultView();
     $result->addAction($button);
     $result->setContent($view);
     return $result;
 }
开发者ID:patelhardik,项目名称:phabricator,代码行数:32,代码来源:PhabricatorNotificationSearchEngine.php

示例6: renderResultList

 protected function renderResultList(array $polls, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($polls, 'PhabricatorSlowvotePoll');
     $viewer = $this->requireViewer();
     $list = id(new PHUIObjectItemListView())->setUser($viewer);
     $phids = mpull($polls, 'getAuthorPHID');
     foreach ($polls as $poll) {
         $date_created = phabricator_datetime($poll->getDateCreated(), $viewer);
         if ($poll->getAuthorPHID()) {
             $author = $handles[$poll->getAuthorPHID()]->renderLink();
         } else {
             $author = null;
         }
         $item = id(new PHUIObjectItemView())->setUser($viewer)->setObject($poll)->setObjectName('V' . $poll->getID())->setHeader($poll->getQuestion())->setHref('/V' . $poll->getID())->addIcon('none', $date_created);
         if ($poll->getIsClosed()) {
             $item->setStatusIcon('fa-ban grey');
             $item->setDisabled(true);
         } else {
             $item->setStatusIcon('fa-bar-chart');
         }
         $description = $poll->getDescription();
         if (strlen($description)) {
             $item->addAttribute(id(new PhutilUTF8StringTruncator())->setMaximumGlyphs(120)->truncateString($poll->getDescription()));
         }
         if ($author) {
             $item->addByline(pht('Author: %s', $author));
         }
         $list->addItem($item);
     }
     $result = new PhabricatorApplicationSearchResultView();
     $result->setObjectList($list);
     $result->setNoDataString(pht('No polls found.'));
     return $result;
 }
开发者ID:patelhardik,项目名称:phabricator,代码行数:34,代码来源:PhabricatorSlowvoteSearchEngine.php

示例7: didFilterPage

 protected function didFilterPage(array $books)
 {
     assert_instances_of($books, 'DivinerLiveBook');
     if ($this->needRepositories) {
         $repositories = id(new PhabricatorRepositoryQuery())->setViewer($this->getViewer())->withPHIDs(mpull($books, 'getRepositoryPHID'))->execute();
         $repositories = mpull($repositories, null, 'getPHID');
         foreach ($books as $key => $book) {
             if ($book->getRepositoryPHID() === null) {
                 $book->attachRepository(null);
                 continue;
             }
             $repository = idx($repositories, $book->getRepositoryPHID());
             if (!$repository) {
                 $this->didRejectResult($book);
                 unset($books[$key]);
                 continue;
             }
             $book->attachRepository($repository);
         }
     }
     if ($this->needProjectPHIDs) {
         $edge_query = id(new PhabricatorEdgeQuery())->withSourcePHIDs(mpull($books, 'getPHID'))->withEdgeTypes(array(PhabricatorProjectObjectHasProjectEdgeType::EDGECONST));
         $edge_query->execute();
         foreach ($books as $book) {
             $project_phids = $edge_query->getDestinationPHIDs(array($book->getPHID()));
             $book->attachProjectPHIDs($project_phids);
         }
     }
     return $books;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:30,代码来源:DivinerBookQuery.php

示例8: renderLastModifiedColumns

 public static function renderLastModifiedColumns(PhabricatorRepository $repository, array $handles, PhabricatorRepositoryCommit $commit = null, PhabricatorRepositoryCommitData $data = null)
 {
     assert_instances_of($handles, 'PhabricatorObjectHandle');
     if ($commit) {
         $epoch = $commit->getEpoch();
         $modified = DiffusionView::linkCommit($repository, $commit->getCommitIdentifier());
         $date = date('M j, Y', $epoch);
         $time = date('g:i A', $epoch);
     } else {
         $modified = '';
         $date = '';
         $time = '';
     }
     if ($data) {
         $author_phid = $data->getCommitDetail('authorPHID');
         if ($author_phid && isset($handles[$author_phid])) {
             $author = $handles[$author_phid]->renderLink();
         } else {
             $author = phutil_escape_html($data->getAuthorName());
         }
         $details = AphrontTableView::renderSingleDisplayLine(phutil_escape_html($data->getSummary()));
     } else {
         $author = '';
         $details = '';
     }
     return array('commit' => $modified, 'date' => $date, 'time' => $time, 'author' => $author, 'details' => $details);
 }
开发者ID:ramons03,项目名称:phabricator,代码行数:27,代码来源:DiffusionBrowseTableView.php

示例9: updateBranchStates

 private function updateBranchStates(PhabricatorRepository $repository, array $branches)
 {
     assert_instances_of($branches, 'DiffusionRepositoryRef');
     $all_cursors = id(new PhabricatorRepositoryRefCursorQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withRepositoryPHIDs(array($repository->getPHID()))->execute();
     $state_map = array();
     $type_branch = PhabricatorRepositoryRefCursor::TYPE_BRANCH;
     foreach ($all_cursors as $cursor) {
         if ($cursor->getRefType() !== $type_branch) {
             continue;
         }
         $raw_name = $cursor->getRefNameRaw();
         $hash = $cursor->getCommitIdentifier();
         $state_map[$raw_name][$hash] = $cursor;
     }
     foreach ($branches as $branch) {
         $cursor = idx($state_map, $branch->getShortName(), array());
         $cursor = idx($cursor, $branch->getCommitIdentifier());
         if (!$cursor) {
             continue;
         }
         $fields = $branch->getRawFields();
         $cursor_state = (bool) $cursor->getIsClosed();
         $branch_state = (bool) idx($fields, 'closed');
         if ($cursor_state != $branch_state) {
             $cursor->setIsClosed((int) $branch_state)->save();
         }
     }
 }
开发者ID:vinzent,项目名称:phabricator,代码行数:28,代码来源:PhabricatorRepositoryRefEngine.php

示例10: renderResultList

 protected function renderResultList(array $macros, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($macros, 'PhabricatorFileImageMacro');
     $viewer = $this->requireViewer();
     $handles = $viewer->loadHandles(mpull($macros, 'getAuthorPHID'));
     $xform = PhabricatorFileTransform::getTransformByKey(PhabricatorFileThumbnailTransform::TRANSFORM_PINBOARD);
     $pinboard = new PHUIPinboardView();
     foreach ($macros as $macro) {
         $file = $macro->getFile();
         $item = id(new PHUIPinboardItemView())->setUser($viewer)->setObject($macro);
         if ($file) {
             $item->setImageURI($file->getURIForTransform($xform));
             list($x, $y) = $xform->getTransformedDimensions($file);
             $item->setImageSize($x, $y);
         }
         if ($macro->getDateCreated()) {
             $datetime = phabricator_date($macro->getDateCreated(), $viewer);
             $item->appendChild(phutil_tag('div', array(), pht('Created on %s', $datetime)));
         } else {
             // Very old macros don't have a creation date. Rendering something
             // keeps all the pins at the same height and avoids flow issues.
             $item->appendChild(phutil_tag('div', array(), pht('Created in ages long past')));
         }
         if ($macro->getAuthorPHID()) {
             $author_handle = $handles[$macro->getAuthorPHID()];
             $item->appendChild(pht('Created by %s', $author_handle->renderLink()));
         }
         $item->setURI($this->getApplicationURI('/view/' . $macro->getID() . '/'));
         $item->setDisabled($macro->getisDisabled());
         $item->setHeader($macro->getName());
         $pinboard->addItem($item);
     }
     return $pinboard;
 }
开发者ID:hrb518,项目名称:phabricator,代码行数:34,代码来源:PhabricatorMacroSearchEngine.php

示例11: renderResultsList

 public function renderResultsList(array $requests, PhabricatorSavedQuery $query)
 {
     assert_instances_of($requests, 'ReleephRequest');
     $viewer = $this->getRequest()->getUser();
     // TODO: This is generally a bit sketchy, but we don't do this kind of
     // thing elsewhere at the moment. For the moment it shouldn't be hugely
     // costly, and we can batch things later. Generally, this commits fewer
     // sins than the old code did.
     $engine = id(new PhabricatorMarkupEngine())->setViewer($viewer);
     $list = array();
     foreach ($requests as $pull) {
         $field_list = PhabricatorCustomField::getObjectFields($pull, PhabricatorCustomField::ROLE_VIEW);
         $field_list->setViewer($viewer)->readFieldsFromStorage($pull);
         foreach ($field_list->getFields() as $field) {
             if ($field->shouldMarkup()) {
                 $field->setMarkupEngine($engine);
             }
         }
         $list[] = id(new ReleephRequestView())->setUser($viewer)->setCustomFields($field_list)->setPullRequest($pull)->setIsListView(true);
     }
     // This is quite sketchy, but the list has not actually rendered yet, so
     // this still allows us to batch the markup rendering.
     $engine->process();
     return $list;
 }
开发者ID:denghp,项目名称:phabricator,代码行数:25,代码来源:ReleephBranchViewController.php

示例12: sortAndGroupInlines

 public static function sortAndGroupInlines(array $inlines, array $changesets)
 {
     assert_instances_of($inlines, 'DifferentialTransaction');
     assert_instances_of($changesets, 'DifferentialChangeset');
     $changesets = mpull($changesets, null, 'getID');
     $changesets = msort($changesets, 'getFilename');
     // Group the changesets by file and reorder them by display order.
     $inline_groups = array();
     foreach ($inlines as $inline) {
         $changeset_id = $inline->getComment()->getChangesetID();
         $inline_groups[$changeset_id][] = $inline;
     }
     $inline_groups = array_select_keys($inline_groups, array_keys($changesets));
     foreach ($inline_groups as $changeset_id => $group) {
         // Sort the group of inlines by line number.
         $items = array();
         foreach ($group as $inline) {
             $comment = $inline->getComment();
             $num = $comment->getLineNumber();
             $len = $comment->getLineLength();
             $id = $comment->getID();
             $items[] = array('inline' => $inline, 'sort' => sprintf('~%010d%010d%010d', $num, $len, $id));
         }
         $items = isort($items, 'sort');
         $items = ipull($items, 'inline');
         $inline_groups[$changeset_id] = $items;
     }
     return $inline_groups;
 }
开发者ID:sethkontny,项目名称:phabricator,代码行数:29,代码来源:DifferentialTransactionComment.php

示例13: withUsers

 public function withUsers(array $users)
 {
     assert_instances_of($users, 'PhabricatorUser');
     $this->users = mpull($users, null, 'getPHID');
     $this->withUserPHIDs(array_keys($this->users));
     return $this;
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:7,代码来源:PhabricatorUserPreferencesQuery.php

示例14: __construct

 public function __construct(DifferentialRevision $revision, PhabricatorObjectHandle $actor, array $changesets)
 {
     assert_instances_of($changesets, 'DifferentialChangeset');
     $this->setRevision($revision);
     $this->setActorHandle($actor);
     $this->setChangesets($changesets);
 }
开发者ID:nexeck,项目名称:phabricator,代码行数:7,代码来源:DifferentialReviewRequestMail.php

示例15: renderResultList

 protected function renderResultList(array $logs, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($logs, 'PhabricatorCalendarImportLog');
     $viewer = $this->requireViewer();
     $view = id(new PhabricatorCalendarImportLogView())->setShowImportSources(true)->setViewer($viewer)->setLogs($logs);
     return id(new PhabricatorApplicationSearchResultView())->setTable($view->newTable());
 }
开发者ID:NeoArmageddon,项目名称:phabricator,代码行数:7,代码来源:PhabricatorCalendarImportLogSearchEngine.php


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