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


PHP Assert::isUnreachable方法代码示例

本文整理汇总了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();
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:41,代码来源:IntervalUnit.class.php

示例2: unlink

 public function unlink($key)
 {
     try {
         return unlink($this->path . $key);
     } catch (BaseException $e) {
         return false;
     }
     Assert::isUnreachable();
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:9,代码来源:FileSystemSegmentHandler.class.php

示例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();
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:12,代码来源:PrimitiveEnum.class.php

示例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();
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:12,代码来源:SystemFiveLocker.class.php

示例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();
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:12,代码来源:ExplodedPrimitive.class.php

示例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();
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:12,代码来源:LogicalChain.class.php

示例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();
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:12,代码来源:PrimitiveEnumeration.class.php

示例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);
     }
 }
开发者ID:phoebius,项目名称:phoebius.com,代码行数:16,代码来源:SiteDocContentBlockRenderer.class.php

示例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);
         }
     }
 }
开发者ID:phoebius,项目名称:phoebius,代码行数:23,代码来源:View.class.php

示例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);
         }
     }
 }
开发者ID:phoebius,项目名称:phoebius,代码行数:14,代码来源:BoxablePropertyType.class.php

示例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();
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:19,代码来源:CarefulDatabaseRunner.class.php

示例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());
 }
开发者ID:phoebius,项目名称:ajax-example,代码行数:20,代码来源:DBOneToOneConstraint.class.php

示例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();
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:18,代码来源:MethodMappedController.class.php

示例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();
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:16,代码来源:MessageSegmentHandler.class.php

示例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();
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:17,代码来源:BaseObjectPrimitive.class.php


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