本文整理汇总了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();
}
示例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();
}
示例3: importValue
public function importValue($value)
{
Assert::isUnreachable('No import value!');
return $this;
}
示例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;
}
示例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");
}
示例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;
}