本文整理汇总了PHP中Checker类的典型用法代码示例。如果您正苦于以下问题:PHP Checker类的具体用法?PHP Checker怎么用?PHP Checker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Checker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
public static function show()
{
$messages = new Messages();
$reporter = new \Jelix\Installer\Reporter\Html($messages);
$check = new Checker($reporter, $messages);
$check->addDatabaseCheck(array('mysql', 'sqlite', 'pgsql'), false);
header("Content-type:text/html;charset=UTF-8");
?>
<!DOCTYPE html>
<html lang="<?php
echo $check->messages->getLang();
?>
">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type"/>
<title><?php
echo htmlspecialchars($check->messages->get('checker.title'));
?>
</title>
<link type="text/css" href="jelix/design/jelix.css" rel="stylesheet" />
</head><body >
<h1 class="apptitle"><?php
echo htmlspecialchars($check->messages->get('checker.title'));
?>
</h1>
<?php
$check->run();
?>
</body>
</html>
<?php
}
示例2: checkFile
/**
* @param string $filename
* @param Settings $settings
* @return Result[]
*/
public function checkFile($filename, Settings $settings = null)
{
if ($settings === null) {
$settings = new Settings();
}
$content = $this->loadFile($filename);
$checker = new Checker($settings);
$results = $checker->check($content);
$this->setFilePathToResults($results, $filename);
return $results;
}
示例3: testCheckingForCacheReturnsWritableState
public function testCheckingForCacheReturnsWritableState()
{
mkdir($root = '/tmp/' . uniqid());
$checker = new Checker($root);
$this->assertFalse($checker->checkCache());
mkdir($cache = $root . '/cache');
chmod($cache, 00);
$this->assertFalse($checker->checkCache());
chmod($cache, 0700);
$this->assertTrue($checker->checkCache());
rmdir($cache);
rmdir($root);
}
示例4: __construct
/**
* Constructor.
*
* @param AppInfo $appInfo
* See {@link getAppInfo()}
* @param string $clientIdentifier
* See {@link getClientIdentifier()}
* @param null|string $userLocale
* See {@link getUserLocale()}
*/
function __construct($appInfo, $clientIdentifier, $userLocale = null)
{
AppInfo::checkArg("appInfo", $appInfo);
Checker::argStringNonEmpty("clientIdentifier", $clientIdentifier);
Checker::argStringNonEmptyOrNull("userLocale", $userLocale);
$this->appInfo = $appInfo;
$this->clientIdentifier = $clientIdentifier;
$this->userLocale = $userLocale;
}
示例5: getRandomBytes
/**
* Returns cryptographically strong secure random bytes (as a PHP string).
*
* @param int $numBytes
* The number of bytes of random data to return.
*
* @return string
*/
static function getRandomBytes($numBytes)
{
Checker::argIntPositive("numBytes", $numBytes);
// openssl_random_pseudo_bytes had some issues prior to PHP 5.3.4
if (function_exists('openssl_random_pseudo_bytes') && version_compare(PHP_VERSION, '5.3.4') >= 0) {
$s = openssl_random_pseudo_bytes($numBytes, $isCryptoStrong);
if ($isCryptoStrong) {
return $s;
}
}
if (function_exists('mcrypt_create_iv')) {
return mcrypt_create_iv($numBytes);
}
// Hopefully the above two options cover all our users. But if not, there are
// other platform-specific options we could add.
assert(False, "no suitable random number source available");
}
示例6: addTransaction
private function addTransaction($hash_out, $hash_in, $type, $choice1 = null, $choice2 = null)
{
if ($this->closed) {
throw new \RuntimeException("Could not add the transaction. This batchRequest is closed.");
}
if ($this->isFull()) {
throw new \RuntimeException('The transaction could not be added to the batch. It is full.');
}
if ($type == 'accountUpdate' && $this->counts_and_amounts['accountUpdate']['count'] != $this->total_txns) {
throw new \RuntimeException("The transaction could not be added to the batch. The transaction type {$type} cannot be mixed with non-Account Updates.");
} elseif ($type != 'accountUpdate' && $this->counts_and_amounts['accountUpdate']['count'] == $this->total_txns && $this->total_txns > 0) {
throw new \RuntimeException("The transaction could not be added to the batch. The transaction type {$type} cannot be mixed with AccountUpdates.");
}
if (isset($hash_in['reportGroup'])) {
$report_group = $hash_in['reportGroup'];
} else {
$conf = Obj2xml::getConfig(array());
$report_group = $conf['reportGroup'];
}
Checker::choice($choice1);
Checker::choice($choice2);
$request = Obj2xml::transactionToXml($hash_out, $type, $report_group);
if (file_put_contents($this->transaction_file, $request, FILE_APPEND) === FALSE) {
throw new \RuntimeException("A transaction could not be written to the batch file at {$this->transaction_file}. Please check your privilege.");
}
$this->total_txns += 1;
}
示例7: define
<?php
require_once 'Checker.php';
define('APP_DIR', __DIR__);
echo 'Checking filesystem permissions:' . PHP_EOL;
$checker = new Checker(APP_DIR);
$checker->result($checker->checkCache(), 'Cache: ');
$checker->result($checker->checkLib(), 'Lib: ');
$checker->result($checker->checkLog(), 'Log: ');
$checker->result($checker->checkInstaller(), 'Installer removed: ');
示例8: testAllLevels
/**
* Test for check.
*
* @dataProvider checkerProvider
*/
public function testAllLevels($subject, $codiceFiscaleToCheck, $omocodiaLevel, $expected)
{
$checker = new Checker($subject, array('codiceFiscaleToCheck' => $codiceFiscaleToCheck, 'omocodiaLevel' => $omocodiaLevel));
$actual = $checker->check();
$this->assertEquals($expected, $actual);
}
示例9: processRequest
private function processRequest($hash_out, $hash_in, $type, $choice1 = null, $choice2 = null)
{
$hash_config = LitleOnlineRequest::overideconfig($hash_in);
$hash = LitleOnlineRequest::getOptionalAttributes($hash_in, $hash_out);
Checker::choice($choice1);
Checker::choice($choice2);
$request = Obj2xml::toXml($hash, $hash_config, $type);
$litleOnlineResponse = $this->newXML->request($request, $hash_config, $this->useSimpleXml);
return $litleOnlineResponse;
}
示例10: checkArgNonRoot
/**
* @internal
*
* @param string $argName
* @param mixed $value
* @throws \InvalidArgumentException
*/
static function checkArgNonRoot($argName, $value)
{
Checker::argStringNonEmpty($argName, $value);
$error = self::findErrorNonRoot($value);
if ($error !== null) {
throw new \InvalidArgumentException("'{$argName}': bad path: {$error}: " . Util::q($value));
}
}
示例11: runWithRetry
/**
* @param int $maxRetries
* The number of times to retry it the action if it fails with one of the transient
* API errors. A value of 1 means we'll try the action once and if it fails, we
* will retry once.
*
* @param callable $action
* The the action you want to retry.
*
* @return mixed
* Whatever is returned by the $action callable.
*/
static function runWithRetry($maxRetries, $action)
{
Checker::argNat("maxRetries", $maxRetries);
$retryDelay = 1;
$numRetries = 0;
while (true) {
try {
return $action();
} catch (Exception_NetworkIO $ex) {
$savedEx = $ex;
} catch (Exception_ServerError $ex) {
$savedEx = $ex;
} catch (Exception_RetryLater $ex) {
$savedEx = $ex;
}
// We maxed out our retries. Propagate the last exception we got.
if ($numRetries >= $maxRetries) {
throw $savedEx;
}
$numRetries++;
sleep($retryDelay);
$retryDelay *= 2;
// Exponential back-off.
}
throw new \RuntimeException("unreachable");
}
示例12: checkArg
/**
* Use this to check that a function argument is of type <code>AppInfo</code>
*
* @internal
*/
static function checkArg($argName, $argValue)
{
if (!$argValue instanceof self) {
Checker::throwError($argName, $argValue, __CLASS__);
}
}
示例13: litleInternalRecurringRequestType
public static function litleInternalRecurringRequestType($hash_in)
{
if (isset($hash_in)) {
$hash_out = array("subscriptionId" => Checker::requiredField(XmlFields::returnArrayValue($hash_in, "subscriptionId")), "recurringTxnId" => Checker::requiredField(XmlFields::returnArrayValue($hash_in, "recurringTxnId")));
return $hash_out;
}
}
示例14: recyclingRequestType
public static function recyclingRequestType($hash_in)
{
if (isset($hash_in)) {
$hash_out = array("recycleBy" => Checker::requiredField(XmlFields::returnArrayValue($hash_in, "recycleBy")));
return $hash_out;
}
}
示例15: showCheckRes
function showCheckRes()
{
/* update last page */
$_SESSION['LASTPAGE'] = substr($_SESSION['LASTPAGE'], 0, strripos($_SESSION['LASTPAGE'], "res"));
$displaySysAdmin = new DisplaySysAdmin();
$comp = loadvar("survey");
$components = loadvar("components");
if ($components == "") {
return $displaySysAdmin->showCheck($displaySysAdmin->displayWarning(Language::messageToolsCompileSelectComponent()));
}
set_time_limit(0);
$messages = array();
$survey = new Survey($comp);
$checker = new Checker($comp);
$compiler = new Compiler($comp, getSurveyVersion($survey));
$sectionmessages = array();
$routingmessages = array();
$variablemessages = array();
$typemessages = array();
$groupmessages = array();
$surveymessages = array();
if (inArray(SURVEY_COMPONENT_ROUTING, $components)) {
$sections = $survey->getSections();
foreach ($sections as $section) {
$mess = $compiler->generateEngine($section->getSeid(), false);
if (sizeof($mess) > 0) {
$routingmessages[$section->getName()] = $mess;
$errors = true;
}
}
}
if (inArray(SURVEY_COMPONENT_SECTION, $components)) {
$sections = $survey->getSections();
foreach ($sections as $section) {
$mess = $checker->checkSection($section, true);
if (sizeof($mess) > 0) {
$sectionmessages[$section->getName()] = $mess;
$errors = true;
}
}
}
if (inArray(SURVEY_COMPONENT_VARIABLE, $components)) {
$vars = $survey->getVariableDescriptives();
foreach ($vars as $var) {
$mess = $checker->checkVariable($var, true);
if (sizeof($mess) > 0) {
$variablemessages[$var->getName()] = $mess;
$errors = true;
}
$mess = $compiler->generateSetFills(array($var), false, false);
if (sizeof($mess) > 0) {
//print_r($mess);
if (isset($variablemessages[$var->getName()])) {
$variablemessages[$var->getName()] = array_merge($variablemessages[$var->getName()], $mess);
} else {
$variablemessages[$var->getName()] = $mess;
}
$errors = true;
}
}
}
if (inArray(SURVEY_COMPONENT_TYPE, $components)) {
$types = $survey->getTypes();
foreach ($types as $type) {
$mess = $checker->checkType($type, true);
if (sizeof($mess) > 0) {
$typemessages[$type->getName()] = $mess;
$errors = true;
}
}
}
if (inArray(SURVEY_COMPONENT_SETTING, $components)) {
$mess = $checker->checkSurvey();
if (sizeof($mess) > 0) {
$surveymessages = $mess;
$errors = true;
}
}
if (inArray(SURVEY_COMPONENT_GROUP, $components)) {
$groups = $survey->getGroups();
foreach ($groups as $group) {
$mess = $checker->checkGroup($group, true);
if (sizeof($mess) > 0) {
$groupmessages[$group->getName()] = $mess;
$errors = true;
}
}
}
$messages = array(Language::labelSections() => $sectionmessages, Language::labelVariables() => $variablemessages, Language::labelTypes() => $typemessages, Language::labelGroups() => $groupmessages, Language::labelSettings() => $surveymessages, Language::LabelRouting() => $routingmessages);
if ($errors) {
$m = '<a data-keyboard="false" data-toggle="modal" data-target="#errorsModal">Show error(s)</a>';
$content .= $displaySysAdmin->displayError(Language::messageToolsCheckNotOk() . " " . $m);
} else {
$content .= $displaySysAdmin->displaySuccess(Language::messageToolsCheckOk());
}
$text = "";
//print_r($messages);
foreach ($messages as $k => $v) {
if (sizeof($v) == 0) {
//$text .= $displaySysAdmin->displaySuccess(Language::messageToolsCheckOk());
//.........这里部分代码省略.........