當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Type::check方法代碼示例

本文整理匯總了PHP中Type::check方法的典型用法代碼示例。如果您正苦於以下問題:PHP Type::check方法的具體用法?PHP Type::check怎麽用?PHP Type::check使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Type的用法示例。


在下文中一共展示了Type::check方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: check

 /**
  * This method checks if $value confirms to Type, if $value does not confirm to type, throws an exception or returns null if $soft is true
  *
  * @param            $value
  * @param string     $variableName Used in the message of the Exception, to ease debugging
  * @param bool       $soft
  *
  * @return mixed
  */
 public function check($value, $variableName = "unknown", $soft = false)
 {
     if ($value === null) {
         return null;
     }
     return $this->type->check($value, $variableName, $soft);
 }
開發者ID:mmagyar,項目名稱:typage-php,代碼行數:16,代碼來源:Nullable.php

示例2: check

 /**
  * This method checks if $value confirms to Type, if $value does not confirm to type, throws an exception or returns null if $soft is true
  *
  * @param            $value
  * @param string     $variableName Used in the message of the Exception, to ease debugging
  * @param bool       $soft
  *
  * @return mixed
  */
 public function check($value, $variableName = "unknown", $soft = false)
 {
     if ($value === null && $this->defaultOnNull) {
         return $this->defaultValue;
     }
     $result = $this->type->check($value, $variableName, $this->defaultOnWrongType);
     if ($result instanceof None) {
         return $this->defaultValue;
     }
     return $result;
 }
開發者ID:mmagyar,項目名稱:typage-php,代碼行數:20,代碼來源:Either.php

示例3: check

 function check($value = null, $schema = null, $path = null, $i = null)
 {
     $type = isset($schema->type) ? $schema->type : null;
     $isValid = true;
     if (is_array($type)) {
         $validatedOneType = false;
         $errors = array();
         foreach ($type as $tp) {
             $validator = new Type($this->checkMode);
             $subSchema = new \stdClass();
             $subSchema->type = $tp;
             $validator->check($value, $subSchema, $path, null);
             $error = $validator->getErrors();
             if (!count($error)) {
                 $validatedOneType = true;
                 break;
             } else {
                 $errors = $error;
             }
         }
         if (!$validatedOneType) {
             return $this->addErrors($errors);
         }
     } elseif (is_object($type)) {
         $this->checkUndefined($value, $type, $path);
     } else {
         $isValid = $this->validateType($value, $type);
     }
     if ($isValid === false) {
         $this->addError($path, gettype($value) . " value found, but a " . $type . " is required");
     }
 }
開發者ID:itillawarra,項目名稱:cmfive,代碼行數:32,代碼來源:Type.php

示例4: checkType

 /**
  * validates the type of a property
  *
  * @param mixed $value
  * @param mixed $schema
  * @param mixed $path
  * @param mixed $i
  */
 protected function checkType($value, $schema = null, $path = null, $i = null)
 {
     $validator = new Type($this->checkMode);
     $validator->check($value, $schema, $path, $i);
     $this->addErrors($validator->getErrors());
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:14,代碼來源:Constraint.php

示例5: type

 public static function type($Types, &$Variable, $sVarName = null)
 {
     if (!self::$bEnableAssert) {
         return;
     }
     Type::toArray($Types, Type::toArray_ignoreNull);
     if (!Type::check($Types, $Variable)) {
         throw new TypeException($Variable, $Types, $sVarName);
     }
 }
開發者ID:JeCat,項目名稱:framework,代碼行數:10,代碼來源:Assert.php

示例6: compile

 /**
  * @param $context
  * @param $output
  * @return bool|void
  */
 public static function compile($context, $output)
 {
     if (Type::check(Type::STRING, $context) && Type::check(Type::STRING, $output)) {
         $Cparts = explode('.', $context);
         $Cextension = $Cparts[count($Cparts) - 1];
         $Oparts = explode('.', $output);
         $Oextension = $Oparts[count($Oparts) - 1];
         $Cfile = new File($context);
         if ($Cfile->exists()) {
             switch ($Cextension) {
                 case 'po':
                     $translations = Translations::fromPoFile($context);
                     break;
                 case 'mo':
                     $translations = Translations::fromMoFile($context);
                     break;
                 case 'php':
                     $translations = Translations::fromPhpArrayFile($context);
                     break;
             }
             switch ($Oextension) {
                 case 'po':
                     $translations->toPoFile($output);
                     break;
                 case 'mo':
                     $translations->toMoFile($output);
                     break;
                 case 'php':
                     $translations->toPhpArrayFile($output);
                     break;
             }
         }
     } else {
         return false;
     }
 }
開發者ID:jankal,項目名稱:mvc,代碼行數:41,代碼來源:Gettext.php


注:本文中的Type::check方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。