1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 12:00:55 +01:00

Add some missing type hints

Summary: Add some typehints for Remarkup rules.

Test Plan: Browsed around some Remarkup text.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D12694
This commit is contained in:
Joshua Spence 2015-05-05 07:33:00 +10:00
parent 6bebb3c69a
commit 4ea9d76f66
16 changed files with 73 additions and 29 deletions

View file

@ -15,7 +15,11 @@ final class PhabricatorCountdownRemarkupRule
->execute(); ->execute();
} }
protected function renderObjectEmbed($object, $handle, $options) { protected function renderObjectEmbed(
$object,
PhabricatorObjectHandle $handle,
$options) {
$viewer = $this->getEngine()->getConfig('viewer'); $viewer = $this->getEngine()->getConfig('viewer');
return id(new PhabricatorCountdownView()) return id(new PhabricatorCountdownView())

View file

@ -14,10 +14,13 @@ final class PhabricatorDashboardRemarkupRule
->setViewer($viewer) ->setViewer($viewer)
->withIDs($ids) ->withIDs($ids)
->execute(); ->execute();
} }
protected function renderObjectEmbed($object, $handle, $options) { protected function renderObjectEmbed(
$object,
PhabricatorObjectHandle $handle,
$options) {
$viewer = $this->getEngine()->getConfig('viewer'); $viewer = $this->getEngine()->getConfig('viewer');
return id(new PhabricatorDashboardPanelRenderingEngine()) return id(new PhabricatorDashboardPanelRenderingEngine())

View file

@ -33,7 +33,7 @@ final class DivinerSymbolRemarkupRule extends PhutilRemarkupRule {
$text); $text);
} }
public function markupSymbol($matches) { public function markupSymbol(array $matches) {
if (!$this->isFlatText($matches[0])) { if (!$this->isFlatText($matches[0])) {
return $matches[0]; return $matches[0];
} }

View file

@ -28,7 +28,11 @@ final class PhabricatorEmbedFileRemarkupRule
return $objects; return $objects;
} }
protected function renderObjectEmbed($object, $handle, $options) { protected function renderObjectEmbed(
$object,
PhabricatorObjectHandle $handle,
$options) {
$options = $this->getFileOptions($options) + array( $options = $this->getFileOptions($options) + array(
'name' => $object->getName(), 'name' => $object->getName(),
); );

View file

@ -13,7 +13,7 @@ final class PhabricatorEmojiRemarkupRule extends PhutilRemarkupRule {
$text); $text);
} }
public function markupEmoji($matches) { public function markupEmoji(array $matches) {
if (!$this->isFlatText($matches[0])) { if (!$this->isFlatText($matches[0])) {
return $matches[0]; return $matches[0];
} }

View file

@ -13,7 +13,7 @@ final class PhabricatorIconRemarkupRule extends PhutilRemarkupRule {
$text); $text);
} }
public function markupIcon($matches) { public function markupIcon(array $matches) {
$engine = $this->getEngine(); $engine = $this->getEngine();
$text_mode = $engine->isTextMode(); $text_mode = $engine->isTextMode();
$mail_mode = $engine->isHTMLMailMode(); $mail_mode = $engine->isHTMLMailMode();
@ -73,7 +73,6 @@ final class PhabricatorIconRemarkupRule extends PhutilRemarkupRule {
$icon_view = id(new PHUIIconView()) $icon_view = id(new PHUIIconView())
->setIconFont('fa-'.$icon, $color); ->setIconFont('fa-'.$icon, $color);
return $this->getEngine()->storeText($icon_view); return $this->getEngine()->storeText($icon_view);
} }

View file

@ -13,7 +13,7 @@ final class PhabricatorImageMacroRemarkupRule extends PhutilRemarkupRule {
$text); $text);
} }
public function markupImageMacro($matches) { public function markupImageMacro(array $matches) {
if ($this->macros === null) { if ($this->macros === null) {
$this->macros = array(); $this->macros = array();

View file

@ -15,7 +15,7 @@ final class PhabricatorMemeRemarkupRule extends PhutilRemarkupRule {
$text); $text);
} }
public function markupMeme($matches) { public function markupMeme(array $matches) {
if (!$this->isFlatText($matches[0])) { if (!$this->isFlatText($matches[0])) {
return $matches[0]; return $matches[0];
} }

View file

@ -17,7 +17,11 @@ final class PhabricatorPasteRemarkupRule extends PhabricatorObjectRemarkupRule {
} }
protected function renderObjectEmbed($object, $handle, $options) { protected function renderObjectEmbed(
$object,
PhabricatorObjectHandle $handle,
$options) {
$embed_paste = id(new PasteEmbedView()) $embed_paste = id(new PasteEmbedView())
->setPaste($object) ->setPaste($object)
->setHandle($handle); ->setHandle($handle);

View file

@ -26,7 +26,7 @@ final class PhabricatorMentionRemarkupRule extends PhutilRemarkupRule {
$text); $text);
} }
protected function markupMention($matches) { protected function markupMention(array $matches) {
$engine = $this->getEngine(); $engine = $this->getEngine();
if ($engine->isTextMode()) { if ($engine->isTextMode()) {

View file

@ -12,7 +12,11 @@ final class PholioRemarkupRule extends PhabricatorObjectRemarkupRule {
return '[1-9]\d*(?:/[1-9]\d*/?)?'; return '[1-9]\d*(?:/[1-9]\d*/?)?';
} }
protected function getObjectHref($object, $handle, $id) { protected function getObjectHref(
$object,
PhabricatorObjectHandle $handle,
$id) {
$href = $handle->getURI(); $href = $handle->getURI();
// If the ID has a `M123/456` component, link to that specific image. // If the ID has a `M123/456` component, link to that specific image.
@ -51,7 +55,11 @@ final class PholioRemarkupRule extends PhabricatorObjectRemarkupRule {
return $results; return $results;
} }
protected function renderObjectEmbed($object, $handle, $options) { protected function renderObjectEmbed(
$object,
PhabricatorObjectHandle $handle,
$options) {
$embed_mock = id(new PholioMockEmbedView()) $embed_mock = id(new PholioMockEmbedView())
->setMock($object); ->setMock($object);

View file

@ -13,8 +13,7 @@ final class PhrictionRemarkupRule extends PhutilRemarkupRule {
$text); $text);
} }
public function markupDocumentLink($matches) { public function markupDocumentLink(array $matches) {
$link = trim($matches[1]); $link = trim($matches[1]);
$name = trim(idx($matches, 2, $link)); $name = trim(idx($matches, 2, $link));
if (empty($matches[2])) { if (empty($matches[2])) {

View file

@ -6,7 +6,12 @@ final class ProjectRemarkupRule extends PhabricatorObjectRemarkupRule {
return '#'; return '#';
} }
protected function renderObjectRef($object, $handle, $anchor, $id) { protected function renderObjectRef(
$object,
PhabricatorObjectHandle $handle,
$anchor,
$id) {
if ($this->getEngine()->isTextMode()) { if ($this->getEngine()->isTextMode()) {
return '#'.$id; return '#'.$id;
} }

View file

@ -18,7 +18,11 @@ final class SlowvoteRemarkupRule extends PhabricatorObjectRemarkupRule {
->execute(); ->execute();
} }
protected function renderObjectEmbed($object, $handle, $options) { protected function renderObjectEmbed(
$object,
PhabricatorObjectHandle $handle,
$options) {
$viewer = $this->getEngine()->getConfig('viewer'); $viewer = $this->getEngine()->getConfig('viewer');
$embed = id(new SlowvoteEmbedView()) $embed = id(new SlowvoteEmbedView())

View file

@ -13,7 +13,7 @@ final class PhabricatorNavigationRemarkupRule extends PhutilRemarkupRule {
$text); $text);
} }
public function markupNavigation($matches) { public function markupNavigation(array $matches) {
if (!$this->isFlatText($matches[0])) { if (!$this->isFlatText($matches[0])) {
return $matches[0]; return $matches[0];
} }

View file

@ -46,9 +46,10 @@ abstract class PhabricatorObjectRemarkupRule extends PhutilRemarkupRule {
protected function renderObjectRefForAnyMedia ( protected function renderObjectRefForAnyMedia (
$object, $object,
$handle, PhabricatorObjectHandle $handle,
$anchor, $anchor,
$id) { $id) {
$href = $this->getObjectHref($object, $handle, $id); $href = $this->getObjectHref($object, $handle, $id);
$text = $this->getObjectNamePrefix().$id; $text = $this->getObjectNamePrefix().$id;
@ -68,7 +69,12 @@ abstract class PhabricatorObjectRemarkupRule extends PhutilRemarkupRule {
} }
protected function renderObjectRef($object, $handle, $anchor, $id) { protected function renderObjectRef(
$object,
PhabricatorObjectHandle $handle,
$anchor,
$id) {
$href = $this->getObjectHref($object, $handle, $id); $href = $this->getObjectHref($object, $handle, $id);
$text = $this->getObjectNamePrefix().$id; $text = $this->getObjectNamePrefix().$id;
$status_closed = PhabricatorObjectHandleStatus::STATUS_CLOSED; $status_closed = PhabricatorObjectHandleStatus::STATUS_CLOSED;
@ -86,7 +92,11 @@ abstract class PhabricatorObjectRemarkupRule extends PhutilRemarkupRule {
return $this->renderHovertag($text, $href, $attr); return $this->renderHovertag($text, $href, $attr);
} }
protected function renderObjectEmbedForAnyMedia($object, $handle, $options) { protected function renderObjectEmbedForAnyMedia(
$object,
PhabricatorObjectHandle $handle,
$options) {
$name = $handle->getFullName(); $name = $handle->getFullName();
$href = $handle->getURI(); $href = $handle->getURI();
@ -100,7 +110,11 @@ abstract class PhabricatorObjectRemarkupRule extends PhutilRemarkupRule {
return $this->renderObjectEmbed($object, $handle, $options); return $this->renderObjectEmbed($object, $handle, $options);
} }
protected function renderObjectEmbed($object, $handle, $options) { protected function renderObjectEmbed(
$object,
PhabricatorObjectHandle $handle,
$options) {
$name = $handle->getFullName(); $name = $handle->getFullName();
$href = $handle->getURI(); $href = $handle->getURI();
$status_closed = PhabricatorObjectHandleStatus::STATUS_CLOSED; $status_closed = PhabricatorObjectHandleStatus::STATUS_CLOSED;
@ -115,7 +129,7 @@ abstract class PhabricatorObjectRemarkupRule extends PhutilRemarkupRule {
protected function renderObjectTagForMail( protected function renderObjectTagForMail(
$text, $text,
$href, $href,
$handle) { PhabricatorObjectHandle $handle) {
$status_closed = PhabricatorObjectHandleStatus::STATUS_CLOSED; $status_closed = PhabricatorObjectHandleStatus::STATUS_CLOSED;
$strikethrough = $handle->getStatus() == $status_closed ? $strikethrough = $handle->getStatus() == $status_closed ?
@ -243,7 +257,7 @@ abstract class PhabricatorObjectRemarkupRule extends PhutilRemarkupRule {
return $results; return $results;
} }
public function markupObjectEmbed($matches) { public function markupObjectEmbed(array $matches) {
if (!$this->isFlatText($matches[0])) { if (!$this->isFlatText($matches[0])) {
return $matches[0]; return $matches[0];
} }
@ -256,7 +270,7 @@ abstract class PhabricatorObjectRemarkupRule extends PhutilRemarkupRule {
)); ));
} }
public function markupObjectReference($matches) { public function markupObjectReference(array $matches) {
if (!$this->isFlatText($matches[0])) { if (!$this->isFlatText($matches[0])) {
return $matches[0]; return $matches[0];
} }