当前位置: 首页>>代码示例>>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;未经允许,请勿转载。