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


PHP Assert::isUnreachable方法代码示例

本文整理汇总了PHP中Hesper\Core\Base\Assert::isUnreachable方法的典型用法代码示例。如果您正苦于以下问题:PHP Assert::isUnreachable方法的具体用法?PHP Assert::isUnreachable怎么用?PHP Assert::isUnreachable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Hesper\Core\Base\Assert的用法示例。


在下文中一共展示了Assert::isUnreachable方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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:justthefish,项目名称:hesper,代码行数:39,代码来源:IntervalUnit.php

示例2: toSetter

    public function toSetter(MetaClass $class, MetaClassProperty $property, MetaClassProperty $holder = null)
    {
        $name = $property->getName();
        $methodName = 'set' . ucfirst($name);
        $default = $property->isRequired() ? '' : ' = null';
        if ($holder) {
            Assert::isUnreachable();
        } else {
            return <<<EOT

/**
 * @return {$class->getName()}
**/
public function {$methodName}(array \${$name}{$default})
{
\t\$this->{$name} = \${$name};

\treturn \$this;
}

EOT;
        }
        Assert::isUnreachable();
    }
开发者ID:justthefish,项目名称:hesper,代码行数:24,代码来源:ArrayType.php

示例3: importValue

 public function importValue($value)
 {
     Assert::isUnreachable('No import value!');
     return $this;
 }
开发者ID:justthefish,项目名称:hesper,代码行数:5,代码来源:PrimitiveNoValue.php

示例4: run

 /**
  * @return CustomizableDaoSynchronizer
  **/
 public function run()
 {
     $masterIterator = new DaoIterator();
     $slaveIterator = new DaoIterator();
     $masterIterator->setDao($this->master);
     $slaveIterator->setDao($this->slave);
     if ($this->masterKeyProperty) {
         $masterIterator->setKeyProperty($this->masterKeyProperty);
     }
     if ($this->slaveKeyProperty) {
         $slaveIterator->setKeyProperty($this->slaveKeyProperty);
     }
     if ($this->masterProjection) {
         $masterIterator->setProjection($this->masterProjection);
     }
     if ($this->slaveProjection) {
         $slaveIterator->setProjection($this->slaveProjection);
     }
     $this->totalDeleted = 0;
     $this->totalInserted = 0;
     $this->totalUpdated = 0;
     while ($masterIterator->valid() || $slaveIterator->valid()) {
         $masterObject = $masterIterator->current();
         $slaveObject = $slaveIterator->current();
         $masterObject = $this->convertMasterObjectToSlave($masterObject);
         $masterGetter = 'get' . ucfirst($this->masterKeyProperty);
         $slaveGetter = 'get' . ucfirst($this->slaveKeyProperty);
         if ($masterObject && $slaveObject && $masterObject->{$masterGetter}() == $slaveObject->{$slaveGetter}()) {
             if ($this->sync($slaveObject, $masterObject)) {
                 $this->totalUpdated++;
             }
             $masterIterator->next();
             $slaveIterator->next();
         } elseif (!$masterObject || $slaveObject && $this->compareKeys($masterObject->{$masterGetter}(), $slaveObject->{$slaveGetter}()) > 0) {
             if ($this->delete($slaveObject)) {
                 $this->totalDeleted++;
             }
             $slaveIterator->next();
         } elseif (!$slaveObject || $masterObject && $this->compareKeys($masterObject->{$masterGetter}(), $slaveObject->{$slaveGetter}()) < 0) {
             if ($this->insert($masterObject)) {
                 $this->totalInserted++;
             }
             $masterIterator->next();
         } else {
             Assert::isUnreachable('how did you get here?');
         }
     }
     return $this;
 }
开发者ID:justthefish,项目名称:hesper,代码行数:52,代码来源:CustomizableDaoSynchronizer.php

示例5: getCurrentItem

 /**
  * @thows WrongArgumentException
  * @return AMQPInterface
  */
 protected function getCurrentItem()
 {
     if ($this->current && $this->pool[$this->current]->isAlive()) {
         return $this->pool[$this->current];
     }
     Assert::isUnreachable("no current connection");
 }
开发者ID:justthefish,项目名称:hesper,代码行数:11,代码来源:AMQPSelective.php

示例6: checkClassSanity

 /**
  * @return MetaConfiguration
  **/
 private function checkClassSanity(MetaClass $class, \ReflectionClass $info)
 {
     switch ($class->getTypeId()) {
         case null:
             break;
         case MetaClassType::CLASS_ABSTRACT:
             Assert::isTrue($info->isAbstract(), 'class ' . $info->getName() . ' expected to be abstract');
             Assert::isTrue($class->getPattern() instanceof AbstractClassPattern, 'class ' . $info->getName() . ' must use AbstractClassPattern');
             break;
         case MetaClassType::CLASS_FINAL:
             Assert::isTrue($info->isFinal(), 'class ' . $info->getName() . ' expected to be final');
             break;
         case MetaClassType::CLASS_SPOOKED:
         default:
             Assert::isUnreachable();
             break;
     }
     if ($public = $info->getProperties(\ReflectionProperty::IS_PUBLIC)) {
         Assert::isUnreachable($class->getName() . ' contains properties with evil visibility:' . "\n" . print_r($public, true));
     }
     return $this;
 }
开发者ID:justthefish,项目名称:hesper,代码行数:25,代码来源:MetaConfiguration.php


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