Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phid/handle/pool/PhabricatorHandleList.php
Show First 20 Lines • Show All 120 Lines • ▼ Show 20 Lines | public function renderHandle($phid) { | ||||
return id(new PHUIHandleView()) | return id(new PHUIHandleView()) | ||||
->setHandleList($this) | ->setHandleList($this) | ||||
->setHandlePHID($phid); | ->setHandlePHID($phid); | ||||
} | } | ||||
/* -( Iterator )----------------------------------------------------------- */ | /* -( Iterator )----------------------------------------------------------- */ | ||||
#[\ReturnTypeWillChange] | |||||
public function rewind() { | public function rewind() { | ||||
$this->cursor = 0; | $this->cursor = 0; | ||||
} | } | ||||
#[\ReturnTypeWillChange] | |||||
public function current() { | public function current() { | ||||
return $this->getHandle($this->phids[$this->cursor]); | return $this->getHandle($this->phids[$this->cursor]); | ||||
} | } | ||||
#[\ReturnTypeWillChange] | |||||
public function key() { | public function key() { | ||||
return $this->phids[$this->cursor]; | return $this->phids[$this->cursor]; | ||||
} | } | ||||
#[\ReturnTypeWillChange] | |||||
public function next() { | public function next() { | ||||
++$this->cursor; | ++$this->cursor; | ||||
} | } | ||||
#[\ReturnTypeWillChange] | |||||
public function valid() { | public function valid() { | ||||
return ($this->cursor < $this->count); | return ($this->cursor < $this->count); | ||||
} | } | ||||
/* -( ArrayAccess )-------------------------------------------------------- */ | /* -( ArrayAccess )-------------------------------------------------------- */ | ||||
#[\ReturnTypeWillChange] | |||||
public function offsetExists($offset) { | public function offsetExists($offset) { | ||||
// NOTE: We're intentionally not loading handles here so that isset() | // NOTE: We're intentionally not loading handles here so that isset() | ||||
// checks do not trigger fetches. This gives us better bulk loading | // checks do not trigger fetches. This gives us better bulk loading | ||||
// behavior, particularly when invoked through methods like renderHandle(). | // behavior, particularly when invoked through methods like renderHandle(). | ||||
if ($this->map === null) { | if ($this->map === null) { | ||||
$this->map = array_fill_keys($this->phids, true); | $this->map = array_fill_keys($this->phids, true); | ||||
} | } | ||||
return isset($this->map[$offset]); | return isset($this->map[$offset]); | ||||
} | } | ||||
#[\ReturnTypeWillChange] | |||||
public function offsetGet($offset) { | public function offsetGet($offset) { | ||||
if ($this->handles === null) { | if ($this->handles === null) { | ||||
$this->loadHandles(); | $this->loadHandles(); | ||||
} | } | ||||
return $this->handles[$offset]; | return $this->handles[$offset]; | ||||
} | } | ||||
#[\ReturnTypeWillChange] | |||||
public function offsetSet($offset, $value) { | public function offsetSet($offset, $value) { | ||||
$this->raiseImmutableException(); | $this->raiseImmutableException(); | ||||
} | } | ||||
#[\ReturnTypeWillChange] | |||||
public function offsetUnset($offset) { | public function offsetUnset($offset) { | ||||
$this->raiseImmutableException(); | $this->raiseImmutableException(); | ||||
} | } | ||||
private function raiseImmutableException() { | private function raiseImmutableException() { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'Trying to mutate a %s, but this is not permitted; '. | 'Trying to mutate a %s, but this is not permitted; '. | ||||
'handle lists are immutable.', | 'handle lists are immutable.', | ||||
__CLASS__)); | __CLASS__)); | ||||
} | } | ||||
/* -( Countable )---------------------------------------------------------- */ | /* -( Countable )---------------------------------------------------------- */ | ||||
#[\ReturnTypeWillChange] | |||||
public function count() { | public function count() { | ||||
return $this->count; | return $this->count; | ||||
} | } | ||||
} | } |