• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Assert类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Assert的典型用法代码示例。如果您正苦于以下问题:PHP Assert类的具体用法?PHP Assert怎么用?PHP Assert使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Assert类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: testAsserts

 public function testAsserts()
 {
     $wrapper = new Assert();
     $this->assertEquals(
         file_get_contents(__DIR__ . '/_files/Asserts-origin.php'),
         $wrapper->process(file_get_contents(__DIR__ . '/_files/Asserts.php')));
 }
开发者ID:necromant2005,项目名称:AOP,代码行数:7,代码来源:AssertTest.php


示例2: __construct

 function __construct($name, $address)
 {
     Assert::isScalar($name);
     Assert::isScalar($address);
     $this->name = $name;
     $this->address = $address;
 }
开发者ID:phoebius,项目名称:phoebius.com,代码行数:7,代码来源:ViewLink.php


示例3: __construct

 /**
  * @param string $func name of the aggregate
  * @param string $expression property to be used for aggregation
  * @param string $alias optional label for the result of the aggregator
  */
 function __construct($func, $expression = null, $alias = null)
 {
     Assert::isScalar($func);
     $this->func = $func;
     $this->expression = $expression;
     $this->alias = $alias;
 }
开发者ID:phoebius,项目名称:phoebius,代码行数:12,代码来源:AggrProjection.class.php


示例4: castNumber

 protected function castNumber($number)
 {
     if (!$this->scalar && Assert::checkInteger($number)) {
         return (int) $number;
     }
     return $number;
 }
开发者ID:rero26,项目名称:onphp-framework,代码行数:7,代码来源:IdentifiablePrimitive.class.php


示例5: __construct

 /**
  * @param string $name name of the column
  * @param ISqlType $type SQL type of the column
  */
 function __construct($name, DBTable $table, ISqlType $type)
 {
     Assert::isScalar($name);
     $this->name = $name;
     $this->table = $table;
     $this->type = $type;
 }
开发者ID:phoebius,项目名称:phoebius,代码行数:11,代码来源:DBColumn.class.php


示例6: __construct

 public function __construct()
 {
     require ONPHP_META_AUTO_DIR . 'schema.php';
     Assert::isTrue(isset($schema));
     $this->schema = $schema;
     // in case of unclean shutdown of previous tests
     foreach (DBTestPool::me()->getPool() as $name => $db) {
         foreach ($this->schema->getTableNames() as $name) {
             try {
                 $db->queryRaw(OSQL::dropTable($name, true)->toDialectString($db->getDialect()));
             } catch (DatabaseException $e) {
                 // ok
             }
             if ($db->hasSequences()) {
                 foreach ($this->schema->getTableByName($name)->getColumns() as $columnName => $column) {
                     try {
                         if ($column->isAutoincrement()) {
                             $db->queryRaw("DROP SEQUENCE {$name}_id;");
                         }
                     } catch (DatabaseException $e) {
                         // ok
                     }
                 }
             }
         }
     }
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:27,代码来源:TestTables.class.php


示例7: __construct

 /**
  * @param boolean whether to use include path or not
  * @param boolean whether to allow pre-scanning technique or not. PreScan is important for 
  * huge and distributed class locations
  */
 function __construct($useIncludePath = true, $allowPreScan = false)
 {
     Assert::isBoolean($allowPreScan);
     $this->allowPreScan = $allowPreScan;
     parent::__construct($useIncludePath);
     $this->setExtension(PHOEBIUS_TYPE_EXTENSION);
 }
开发者ID:phoebius,项目名称:phoebius,代码行数:12,代码来源:CSharpStyleClassResolver.class.php


示例8: set

 public function set($name, $value)
 {
     if (!isset($this->mapping[$name])) {
         throw new WrongArgumentException("knows nothing about property '{$name}'");
     }
     $primitive = $this->mapping[$name];
     $setter = 'set' . ucfirst($primitive->getName());
     if (!method_exists($this->object, $setter)) {
         throw new WrongArgumentException("cannot find mutator for '{$name}' in class " . get_class($this->object));
     }
     if (is_object($value)) {
         if ($primitive instanceof PrimitiveAnyType && $value instanceof PrototypedEntity) {
             $value = ObjectToDTOConverter::create($value->entityProto())->make($value);
         } else {
             $value = $this->dtoValue($value, $primitive);
         }
     } elseif (is_array($value) && is_object(current($value))) {
         $dtoValue = array();
         foreach ($value as $oneValue) {
             Assert::isTrue(is_object($oneValue), 'array must contain only objects');
             $dtoValue[] = $this->dtoValue($oneValue, $primitive);
         }
         $value = $dtoValue;
     }
     return $this->object->{$setter}($value);
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:26,代码来源:DTOSetter.class.php


示例9: import

 public function import($scope)
 {
     if (!$this->className) {
         throw new WrongStateException("no class defined for PrimitiveIdentifierList '{$this->name}'");
     }
     if (!BasePrimitive::import($scope)) {
         return null;
     }
     if (!is_array($scope[$this->name])) {
         return false;
     }
     $list = array_unique($scope[$this->name]);
     $values = array();
     foreach ($list as $id) {
         if (!Assert::checkInteger($id)) {
             return false;
         }
         $values[] = $id;
     }
     $objectList = array();
     foreach ($values as $value) {
         $className = $this->className;
         $objectList[] = new $className($value);
     }
     if (count($objectList) == count($values)) {
         $this->value = $objectList;
         return true;
     }
     return false;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:30,代码来源:PrimitiveEnumList.class.php


示例10: __construct

 /**
  * @param string $field name of the column
  * @param string $table optional name of the table that owns the column
  */
 function __construct($field, $table = null)
 {
     Assert::isScalar($field);
     Assert::isScalarOrNull($table);
     $this->field = $field;
     $this->table = $table;
 }
开发者ID:phoebius,项目名称:phoebius,代码行数:11,代码来源:SqlColumn.class.php


示例11: setAllowedMethodsHeaders

 public static function setAllowedMethodsHeaders($allowed_methods_arr)
 {
     Assert::assert(is_array($allowed_methods_arr));
     self::setAccessControlAllowOriginHeader();
     header('Access-Control-Allow-Methods: ' . implode(', ', $allowed_methods_arr));
     header('Allow: ' . implode(', ', $allowed_methods_arr));
 }
开发者ID:o-log,项目名称:php-lib,代码行数:7,代码来源:Exits.php


示例12: setup

 /**
  * Configures PHP environment.
  * @return void
  */
 public static function setup()
 {
     self::$useColors = getenv('NETTE_TESTER_COLORS') !== FALSE ? (bool) getenv('NETTE_TESTER_COLORS') : PHP_SAPI === 'cli' && (function_exists('posix_isatty') && posix_isatty(STDOUT) || getenv('ConEmuANSI') === 'ON' || getenv('ANSICON') !== FALSE);
     class_exists('Tester\\Runner\\Job');
     class_exists('Tester\\Dumper');
     class_exists('Tester\\Assert');
     error_reporting(E_ALL | E_STRICT);
     ini_set('display_errors', TRUE);
     ini_set('html_errors', FALSE);
     ini_set('log_errors', FALSE);
     set_exception_handler(array(__CLASS__, 'handleException'));
     set_error_handler(function ($severity, $message, $file, $line) {
         if (in_array($severity, array(E_RECOVERABLE_ERROR, E_USER_ERROR)) || ($severity & error_reporting()) === $severity) {
             Environment::handleException(new \ErrorException($message, 0, $severity, $file, $line));
         }
         return FALSE;
     });
     register_shutdown_function(function () {
         Assert::$onFailure = array(__CLASS__, 'handleException');
         // note that Runner is unable to catch this errors in CLI & PHP 5.4.0 - 5.4.6 due PHP bug #62725
         $error = error_get_last();
         if (in_array($error['type'], array(E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_PARSE)) && ($error['type'] & error_reporting()) !== $error['type']) {
             register_shutdown_function(function () use($error) {
                 echo "\nFatal error: {$error['message']} in {$error['file']} on line {$error['line']}\n";
             });
         }
     });
 }
开发者ID:jakuborava,项目名称:walletapp,代码行数:32,代码来源:Environment.php


示例13: run_is_true_with_four_chains

/**
 * @param int $iterations
 * @return array
 */
function run_is_true_with_four_chains($iterations)
{
    $start = microtime(true);
    for ($i = 0; $i < $iterations; $i++) {
        Assert::argument()->is_true(true)->is_true(true)->is_true(true)->is_true(true);
    }
    $end = microtime(true);
    $assert_time = $end - $start;
    $start = microtime(true);
    for ($i = 0; $i < $iterations; $i++) {
        Assert::argument()->is_true(true)->is_true(true)->is_true(true)->is_true(true);
    }
    $end = microtime(true);
    $assert_time = $end - $start;
    $start = microtime(true);
    for ($i = 0; $i < $iterations; $i++) {
        if (!(true === true)) {
            throw new InvalidArgumentException("unacceptable!");
        }
        if (!(true === true)) {
            throw new InvalidArgumentException("unacceptable!");
        }
        if (!(true === true)) {
            throw new InvalidArgumentException("unacceptable!");
        }
        if (!(true === true)) {
            throw new InvalidArgumentException("unacceptable!");
        }
    }
    $end = microtime(true);
    $base_time = $end - $start;
    return [$base_time, $assert_time, $assert_time];
}
开发者ID:tempbottle,项目名称:augmented_types,代码行数:37,代码来源:bench.php


示例14: admin_index

 /**
  * undocumented function
  *
  * @return void
  * @access public
  */
 function admin_index()
 {
     Assert::true(User::allowed($this->name, $this->action), '403');
     $defaults = array('model' => null, 'user_id' => null, 'my_limit' => 20, 'custom_limit' => false, 'start_date_day' => '01', 'start_date_year' => date('Y'), 'start_date_month' => '01', 'end_date_day' => '31', 'end_date_year' => date('Y'), 'end_date_month' => '12');
     $params = am($defaults, $this->params['url'], $this->params['named']);
     unset($params['ext']);
     unset($params['url']);
     if (is_numeric($params['custom_limit'])) {
         if ($params['custom_limit'] > 75) {
             $params['custom_limit'] = 75;
         }
         if ($params['custom_limit'] == 0) {
             $params['custom_limit'] = 50;
         }
         $params['my_limit'] = $params['custom_limit'];
     }
     $conditions = array();
     if (!empty($params['model'])) {
         $conditions['Log.model'] = $params['model'];
     }
     if (!empty($params['user_id'])) {
         $conditions['Log.user_id'] = $params['user_id'];
     }
     $conditions = $this->Log->dateRange($conditions, $params, 'created');
     $this->Session->write('logs_filter_conditions', $conditions);
     $userOptions = ClassRegistry::init('User')->find('list', array('conditions' => array('User.office_id' => $this->Session->read('Office.id'))));
     $this->paginate['Log'] = array('conditions' => $conditions, 'contain' => array('User', 'Gift', 'Transaction'), 'limit' => $params['my_limit'], 'order' => array('Log.continuous_id' => 'desc'));
     $logs = $this->paginate($this->Log);
     $this->set(compact('logs', 'params', 'userOptions'));
 }
开发者ID:stripthis,项目名称:donate,代码行数:36,代码来源:logs_controller.php


示例15: __construct

 function __construct($title = null, $block = false)
 {
     Assert::isScalarOrNull($title);
     Assert::isBoolean($block);
     $this->title = $title;
     $this->block = $block;
 }
开发者ID:phoebius,项目名称:phoebius.com,代码行数:7,代码来源:SiteDocChapter.class.php


示例16: test_extract_jpeg_images_with_redirection

 function test_extract_jpeg_images_with_redirection()
 {
     $html = '<html><body><img src="http://ocafe.appspot.com/?redirect=true"/></body></html>';
     $images = p2mixi_extract_jpeg_images($html, 1);
     //		Assert::equals( count ($images['images']), 1, '');
     Assert::equals(strlen($images['images'][0]), 5221, '');
 }
开发者ID:ento,项目名称:publishToMixi,代码行数:7,代码来源:test_jpeg_extraction.php


示例17: __construct

 protected function __construct(array $dbs = array())
 {
     Assert::isArray($dbs);
     foreach ($dbs as $connector => $credentials) {
         $this->pool[$connector] = DB::spawn($connector, $credentials['user'], $credentials['pass'], $credentials['host'], $credentials['base']);
     }
 }
开发者ID:rero26,项目名称:onphp-framework,代码行数:7,代码来源:DBTestPool.class.php


示例18: unite

 public function unite(Identifiable $object, Identifiable $old)
 {
     Assert::isNotNull($object->getId());
     Assert::isTypelessEqual($object->getId(), $old->getId(), 'cannot merge different objects');
     $query = OSQL::update($this->getTable());
     foreach ($this->getProtoClass()->getPropertyList() as $property) {
         $getter = $property->getGetter();
         if ($property->getClassName() === null) {
             $changed = $old->{$getter}() !== $object->{$getter}();
         } else {
             /**
              * way to skip pointless update and hack for recursive
              * comparsion.
              **/
             $changed = $old->{$getter}() !== $object->{$getter}() || $old->{$getter}() != $object->{$getter}();
         }
         if ($changed) {
             $property->fillQuery($query, $object);
         }
     }
     if (!$query->getFieldsCount()) {
         return $object;
     }
     $this->targetizeUpdateQuery($query, $object);
     return $this->doInject($query, $object);
 }
开发者ID:rero26,项目名称:onphp-framework,代码行数:26,代码来源:StorableDAO.class.php


示例19: makeSelectQuery

 private function makeSelectQuery(SqlSelectiveFieldSet $fields, $source, IDalExpression $condition = null, SqlOrderChain $orderBy = null, $limit = 0, $offset = 0)
 {
     Assert::isInteger($limit);
     Assert::isInteger($offset);
     $dialect = $this->getDB()->getDialect();
     $query = array();
     $query[] = 'SELECT ' . $fields->toDialectString($dialect);
     if (is_scalar($source)) {
         $source = $dialect->quoteIdentifier($source);
     } else {
         Assert::isTrue(is_array($source));
         $tables = array();
         foreach ($source as $table) {
             $tables[] = $dialect->quoteIdentifier($table);
         }
         $source = join(", ", $tables);
     }
     $query[] = 'FROM ' . $source;
     if ($condition) {
         $query[] = 'WHERE ' . $condition->toDialectString($dialect);
     }
     if ($orderBy) {
         $query[] = $orderBy->toDialectString($dialect);
     }
     if ($limit) {
         $query[] = 'LIMIT ' . (int) $limit;
     }
     if ($offset) {
         $query[] = 'OFFSET ' . (int) $offset;
     }
     $query = join("\r\n", $query);
     return $query;
 }
开发者ID:phoebius,项目名称:proof-of-concept,代码行数:33,代码来源:QueryWorkbench.class.php


示例20: make

 /**
  * @return GmpBigInteger
  **/
 public static function make($number, $base = 10)
 {
     Assert::isTrue(is_numeric($number));
     $result = new self();
     $result->resource = gmp_init($number, $base);
     return $result;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:10,代码来源:GmpBigInteger.class.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Asset类代码示例发布时间:2022-05-23
下一篇:
PHP Artists类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap