本文整理汇总了PHP中Assert::isUnreachable方法的典型用法代码示例。如果您正苦于以下问题:PHP Assert::isUnreachable方法的具体用法?PHP Assert::isUnreachable怎么用?PHP Assert::isUnreachable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assert
的用法示例。
在下文中一共展示了Assert::isUnreachable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: truncate
/**
* @return Timestamp
*
* Emulates PostgreSQL's date_trunc() function
*
**/
public function truncate(Date $time, $ceil = false)
{
$time = $time->toTimestamp();
$function = $ceil ? 'ceil' : 'floor';
if ($this->seconds) {
if ($this->seconds < 1) {
return $time->spawn();
}
$truncated = (int) ($function($time->toStamp() / $this->seconds) * $this->seconds);
return Timestamp::create($truncated);
} elseif ($this->days) {
$epochStartTruncated = Date::create('1970-01-05');
$truncatedDate = Date::create($time->toDate());
if ($ceil && $truncatedDate->toStamp() < $time->toStamp()) {
$truncatedDate->modify('+1 day');
}
$difference = Date::dayDifference($epochStartTruncated, $truncatedDate);
$truncated = (int) ($function($difference / $this->days) * $this->days);
return Timestamp::create($epochStartTruncated->spawn($truncated . ' days')->toStamp());
} elseif ($this->months) {
$monthsCount = $time->getYear() * 12 + ($time->getMonth() - 1);
if ($ceil && $time->getDay() - 1 + $time->getHour() + $time->getMinute() + $time->getSecond() > 0) {
$monthsCount += 0.1;
}
// delta
$truncated = (int) ($function($monthsCount / $this->months) * $this->months);
$months = $truncated % 12;
$years = ($truncated - $months) / 12;
Assert::isEqual($years, (int) $years);
$years = (int) $years;
$months = $months + 1;
return Timestamp::create("{$years}-{$months}-01 00:00:00");
}
Assert::isUnreachable();
}
示例2: unlink
public function unlink($key)
{
try {
return unlink($this->path . $key);
} catch (BaseException $e) {
return false;
}
Assert::isUnreachable();
}
示例3: getList
public function getList()
{
if ($this->value) {
return ClassUtils::callStaticMethod(get_class($this->value) . '::getList');
} elseif ($this->default) {
return ClassUtils::callStaticMethod(get_class($this->default) . '::getList');
} else {
$object = new $this->className(ClassUtils::callStaticMethod($this->className . '::getAnyId'));
return $object->getObjectList();
}
Assert::isUnreachable();
}
示例4: get
public function get($key)
{
try {
if (!isset($this->pool[$key])) {
$this->pool[$key] = sem_get($key, 1, ONPHP_IPC_PERMS, false);
}
return sem_acquire($this->pool[$key]);
} catch (BaseException $e) {
return null;
}
Assert::isUnreachable();
}
示例5: import
public function import($scope)
{
if (!($result = parent::import($scope))) {
return $result;
}
if ($this->value = $this->isSplitByRegexp() ? preg_split($this->separator, $this->value, -1, PREG_SPLIT_NO_EMPTY) : explode($this->separator, $this->value)) {
return true;
} else {
return false;
}
Assert::isUnreachable();
}
示例6: calculateBoolean
private static function calculateBoolean($logic, $left, $right)
{
switch ($logic) {
case BinaryExpression::EXPRESSION_AND:
return $left && $right;
case BinaryExpression::EXPRESSION_OR:
return $left || $right;
default:
throw new WrongArgumentException("unknown logic - '{$logic}'");
}
Assert::isUnreachable();
}
示例7: getList
public function getList()
{
if ($this->value) {
return $this->value->getObjectList();
} elseif ($this->default) {
return $this->default->getObjectList();
} else {
$object = new $this->className(call_user_func(array($this->className, 'getAnyId')));
return $object->getObjectList();
}
Assert::isUnreachable();
}
示例8: renderNode
/**
* @return string
*/
private function renderNode(DOMNode $node)
{
switch ($node->nodeType) {
case XML_CDATA_SECTION_NODE:
return $node->nodeValue;
case XML_TEXT_NODE:
return htmlspecialchars($node->nodeValue);
case XML_ELEMENT_NODE:
return $this->renderElementNode($node);
default:
Assert::isUnreachable('not-renderable node type: %s (name: %s)', $node->nodeType, $node->nodeName);
}
}
示例9: __get
/**
* A shorthand getter of the view data.
*
* If the variable is missing, and error_reporting is turned off (by prepending the call
* with the "@" operator) then the variable is treated as NULL. Otherwise a compilation
* error is raised
*
* @return mixed
*/
function __get($name)
{
Assert::isScalar($name);
if (array_key_exists($name, $this->data)) {
return $this->data[$name];
} else {
if (!error_reporting()) {
$this->data[$name] = null;
return null;
} else {
Assert::isUnreachable('unknown view data `%s` expected within %s view', $name, $this->name);
}
}
}
示例10: assemble
function assemble(array $tuple, FetchStrategy $fetchStrategy)
{
Assert::isTrue(sizeof($tuple) == 1);
$value = reset($tuple);
if (is_null($value)) {
return null;
} else {
try {
return call_user_func_array(array($this->boxableType, 'cast'), array($value));
} catch (TypeCastException $e) {
Assert::isUnreachable('wrong `%s` cast to %s', $value, $this->boxableType);
}
}
}
示例11: run
/**
* @throws BaseException
* @return ModelAndView
**/
public function run(Prototyped $subject, Form $form, HttpRequest $request)
{
Assert::isFalse($this->running, 'command already running');
Assert::isTrue($subject instanceof DAOConnected);
$this->transaction = InnerTransaction::begin($subject->dao());
try {
$mav = $this->command->run($subject, $form, $request);
$this->running = true;
return $mav;
} catch (BaseException $e) {
$this->transaction->rollback();
throw $e;
}
Assert::isUnreachable();
}
示例12: __construct
/**
* @param array $fields fields of referencing table that reference primary another table
* @param DBTable $referencedTable object that represents referenced table
* @param AssociationBreakAction $associationBreakAction action which is performed on reference break
*/
function __construct(array $fields, DBTable $referencedTable, AssociationBreakAction $associationBreakAction)
{
foreach ($referencedTable->getConstraints() as $constraint) {
if ($constraint instanceof DBPrimaryKeyConstraint) {
$pkFields = $constraint->getFields();
Assert::isTrue(sizeof($pkFields) == sizeof($fields), 'foreign key (%s) should have the same number of columns as %s`s table primary key (%s)', join(', ', $fields), $referencedTable->getName(), join(', ', $pkFields));
$this->fields = new SqlFieldArray($fields);
$this->pkFields = new SqlFieldArray($pkFields);
$this->referencedTable = $referencedTable;
$this->associationBreakAction = $associationBreakAction;
return;
}
}
Assert::isUnreachable('referenced table `%s` MUST contain DBPrimaryKeyConstraint', $referencedTable->getName());
}
示例13: handleRequest
/**
* @return ModelAndView
**/
public function handleRequest(HttpRequest $request)
{
if ($action = $this->chooseAction($request)) {
$method = $this->methodMap[$action];
$mav = $this->{$method}($request);
if ($mav->viewIsRedirect()) {
return $mav;
}
$mav->getModel()->set('action', $action);
return $mav;
} else {
return ModelAndView::create();
}
Assert::isUnreachable();
}
示例14: touch
public function touch($key)
{
try {
$q = msg_get_queue($this->id, ONPHP_IPC_PERMS);
} catch (BaseException $e) {
// race
return false;
}
try {
return msg_send($q, $key, 1, false, false);
} catch (BaseException $e) {
// queue is full, rotate it.
return msg_remove_queue($q);
}
Assert::isUnreachable();
}
示例15: import
public function import($scope)
{
if (!BasePrimitive::import($scope)) {
return null;
}
if ($scope[$this->getName()] instanceof $this->className) {
$this->value = $scope[$this->getName()];
return true;
}
try {
$this->value = new $this->className($scope[$this->getName()]);
return true;
} catch (WrongArgumentException $e) {
return false;
}
Assert::isUnreachable();
}