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


PHP assert_options函数代码示例

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


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

示例1: register

 /**
  * Register assertion handler in php
  *
  * @returns void
  */
 public static function register()
 {
     assert_options(ASSERT_ACTIVE, 1);
     assert_options(ASSERT_WARNING, 0);
     assert_options(ASSERT_QUIET_EVAL, 1);
     assert_options(ASSERT_CALLBACK, array('libfajr\\Assert', 'myAssertHandler'));
 }
开发者ID:BGCX067,项目名称:fajr-git,代码行数:12,代码来源:Assert.php

示例2: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!Session::has('role')) {
         return redirect('/login');
     }
     if (!isset($_COOKIE['login'])) {
         $visitorCount = 1;
     }
     $setTime = time() + 3600;
     if (isset($_COOKIE['login'])) {
         $visitorCount = $_COOKIE['login'] + 1;
         setCookie('login', $visitorCount, $setTime);
     } else {
         setCookie('login', $visitorCount, $setTime);
     }
     if (!Session::has('anchor')) {
         session(['anchor' => '2']);
     }
     assert_options(ASSERT_ACTIVE, 1);
     assert_options(ASSERT_WARNING, 0);
     assert_options(ASSERT_QUIET_EVAL, 1);
     assert_options(ASSERT_CALLBACK, 'my_assert_handler');
     $old_error_handler = set_error_handler("myErrorHandler");
     return $next($request);
 }
开发者ID:Soul0806,项目名称:MyWeb,代码行数:32,代码来源:AuthMiddleware.php

示例3: ERAssertInRange

function ERAssertInRange($expr, $min, $max, $description)
{
    $expression = eval("return {$expr};");
    assert_options(ASSERT_CALLBACK, create_function('$file, $line, $code', "echo \"{$description}; expected in range ({$min}),({$max}) but found ({$expression})\n" . '";'));
    $success = assert("(({$expr}) >= ({$min})) && (({$expr}) <= ({$max}))");
    assertion_increase($success);
}
开发者ID:emeraldion,项目名称:zelda,代码行数:7,代码来源:test.php

示例4: assert_in_function

function assert_in_function()
{
    assert_options(ASSERT_ACTIVE, true);
    $value = '2';
    var_dump(assert(is_string($value)));
    var_dump(assert('is_string($value)'));
}
开发者ID:badlamer,项目名称:hhvm,代码行数:7,代码来源:assert_eval.php

示例5: isModuleEnabled

 /**
  * Determine whether a module is enabled.
  *
  * Will return false if the given module doesn't exists.
  *
  * @param string $module Name of the module
  *
  * @return bool True if the given module is enabled, false otherwise.
  *
  * @throws Exception If module.enable is set and is not boolean.
  */
 public static function isModuleEnabled($module)
 {
     $moduleDir = self::getModuleDir($module);
     if (!is_dir($moduleDir)) {
         return false;
     }
     $globalConfig = SimpleSAML_Configuration::getOptionalConfig();
     $moduleEnable = $globalConfig->getArray('module.enable', array());
     if (isset($moduleEnable[$module])) {
         if (is_bool($moduleEnable[$module]) === true) {
             return $moduleEnable[$module];
         }
         throw new Exception("Invalid module.enable value for for the module {$module}");
     }
     if (assert_options(ASSERT_ACTIVE) && !file_exists($moduleDir . '/default-enable') && !file_exists($moduleDir . '/default-disable')) {
         SimpleSAML_Logger::error("Missing default-enable or default-disable file for the module {$module}");
     }
     if (file_exists($moduleDir . '/enable')) {
         return true;
     }
     if (!file_exists($moduleDir . '/disable') && file_exists($moduleDir . '/default-enable')) {
         return true;
     }
     return false;
 }
开发者ID:palantirnet,项目名称:simplesamlphp,代码行数:36,代码来源:Module.php

示例6: installHandler

 /**
  * Install this assertion handler.
  *
  * This function will register this assertion handler. If will not enable assertions if they are
  * disabled.
  */
 public static function installHandler()
 {
     assert_options(ASSERT_WARNING, 0);
     assert_options(ASSERT_BAIL, 0);
     assert_options(ASSERT_QUIET_EVAL, 0);
     assert_options(ASSERT_CALLBACK, array('SimpleSAML_Error_Assertion', 'onAssertion'));
 }
开发者ID:hukumonline,项目名称:yii,代码行数:13,代码来源:Assertion.php

示例7: run

 /**
  * Runs tests and outputs report. This function will run all functions
  * beginning with test_ found in all files provided as arguments. Invalid
  * files are skipped.
  *
  * @param string|array $files Either a string or an array of test files
  *
  * @return bool True if all tests passes, false otherwise
  */
 public static function run($files)
 {
     static $tokens = array();
     $failures = array();
     assert_options(ASSERT_ACTIVE, true);
     assert_options(ASSERT_BAIL, false);
     assert_options(ASSERT_WARNING, false);
     assert_options(ASSERT_QUIET_EVAL, false);
     assert_options(ASSERT_CALLBACK, function ($file, $line, $assert, $description = null) use(&$failures, &$tokens) {
         $failures[] = array('file' => $file, 'line' => $line, 'assert' => $assert, 'description' => $description);
     });
     if (is_string($files)) {
         $files = (array) $files;
     }
     $asserts = 0;
     $tests = 0;
     $t0 = microtime(true);
     foreach ($files as $file) {
         if (!(is_string($file) && is_readable($file))) {
             continue;
         }
         $source = file_get_contents($file);
         $asserts = preg_match_all('/assert\\(/im', $source, $_);
         if (preg_match_all('/function (test_(?:[a-z_][a-z0-9_]*))\\(/im', $source, $matches)) {
             $functions = $matches[1];
             require_once $file;
             foreach ($functions as $f) {
                 if (is_callable($f)) {
                     $tests += 1;
                     call_user_func($f);
                 }
             }
         }
     }
     $t = round(microtime(true) - $t0, 3);
     ob_start();
     if ($failures) {
         print 'Failed ' . count($failures) . " of {$asserts} assert(s) in {$tests} test(s) - completed in {$t} seconds." . PHP_EOL;
         print str_repeat('-', 79) . PHP_EOL;
         foreach ($failures as $i => $failure) {
             print $i + 1 . ". {$failure['file']}:{$failure['line']}" . PHP_EOL;
             if (strlen($failure['assert'])) {
                 print "\t{$failure['assert']}" . PHP_EOL;
             }
             print str_repeat('-', 79) . PHP_EOL;
         }
     } else {
         print "Passed {$asserts} assert(s) in {$tests} test(s) - completed in {$t} seconds." . PHP_EOL;
     }
     $report = ob_get_clean();
     if (php_sapi_name() == 'cli') {
         echo $report;
     } else {
         echo '<pre>' . PHP_EOL;
         echo $report;
         echo '</pre>' . PHP_EOL;
     }
     return empty($failures);
 }
开发者ID:nramenta,项目名称:rein,代码行数:68,代码来源:Rein.php

示例8: setup

 static function setup()
 {
     set_error_handler(array("\\libraries\\ExceptionHandler", "error_handler"));
     set_exception_handler(array("\\libraries\\ExceptionHandler", 'exception_handler'));
     register_shutdown_function(array("\\libraries\\ExceptionHandler", "check_for_fatal"));
     assert_options(ASSERT_ACTIVE, true);
     assert_options(ASSERT_CALLBACK, array("\\libraries\\ExceptionHandler", '_assert_failure'));
 }
开发者ID:Anon215,项目名称:filebin,代码行数:8,代码来源:ExceptionHandler.php

示例9: main

function main($argv)
{
    ini_set('error_reporting', E_ALL | E_STRICT);
    ini_set('display_errors', 'on');
    assert_options(ASSERT_CALLBACK, 'assert_cb');
    $proc = new phpjs();
    $proc->translate_file($argv[1]);
}
开发者ID:rex786,项目名称:php2js,代码行数:8,代码来源:phpxml.php

示例10: setAssertionsLevel1

 public static function setAssertionsLevel1($enable)
 {
     assert('is_bool($enable)', vs(isset($this), get_defined_vars()));
     assert_options(ASSERT_ACTIVE, $enable);
     if (self::$ms_anyFailedAssertionIsFatal && $enable) {
         assert_options(ASSERT_BAIL, true);
     }
 }
开发者ID:nunodotferreira,项目名称:Phred,代码行数:8,代码来源:CDebug.php

示例11: assertsInitialize

 protected function assertsInitialize()
 {
     assert_options(ASSERT_ACTIVE, static::$ASSERT_ACTIVE);
     assert_options(ASSERT_WARNING, static::$ASSERT_WARNING);
     assert_options(ASSERT_BAIL, static::$ASSERT_BAIL);
     assert_options(ASSERT_QUIET_EVAL, static::$ASSERT_QUIET_EVAL);
     assert_options(ASSERT_CALLBACK, [$this, static::ASSERT_FAILED_METHOD]);
 }
开发者ID:shgysk8zer0,项目名称:core,代码行数:8,代码来源:asserts.php

示例12: resetAssertOptions

 /**
  * Reset assert() options
  *
  * @return void
  */
 public static function resetAssertOptions()
 {
     assert_options(ASSERT_ACTIVE, 1);
     assert_options(ASSERT_WARNING, 1);
     assert_options(ASSERT_BAIL, 0);
     assert_options(ASSERT_QUIET_EVAL, 0);
     assert_options(ASSERT_CALLBACK, null);
 }
开发者ID:apeschar,项目名称:php-fw,代码行数:13,代码来源:FWErrorHandler.class.php

示例13: refreshAssertBindings

 /** @return void */
 public function refreshAssertBindings()
 {
     assert_options(ASSERT_CALLBACK, array($this, 'assertCallback'));
     assert_options(ASSERT_ACTIVE, 1);
     assert_options(ASSERT_WARNING, 0);
     assert_options(ASSERT_QUIET_EVAL, 1);
     assert_options(ASSERT_BAIL, 0);
 }
开发者ID:rsms,项目名称:phpab,代码行数:9,代码来源:UnitTest.php

示例14: setAssertHandling

 /**
  *
  */
 protected function setAssertHandling()
 {
     // Active assert and make it quiet
     assert_options(ASSERT_ACTIVE, 1);
     assert_options(ASSERT_WARNING, 0);
     assert_options(ASSERT_QUIET_EVAL, 1);
     // Set up the callback
     assert_options(ASSERT_CALLBACK, array($this, 'assertHandler'));
 }
开发者ID:thomblin,项目名称:slimline,代码行数:12,代码来源:handler.php

示例15: register

 public static function register()
 {
     self::$oldhandler = set_error_handler(array(__CLASS__, '__php_handleError'), E_ALL);
     \set_exception_handler(array(__CLASS__, '__php_handleException'));
     // Active assert and make it quiet
     assert_options(ASSERT_ACTIVE, 1);
     assert_options(ASSERT_WARNING, 0);
     assert_options(ASSERT_QUIET_EVAL, 1);
     assert_options(ASSERT_CALLBACK, array(__CLASS__, '__php_handleAssert'));
 }
开发者ID:noccy80,项目名称:cherryphp,代码行数:10,代码来源:errorhandler.php


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