コード例 #1
0
 /**
  * @param MemberMetadata $propertyMetadata
  * @param mixed $dataSource
  * @param string $dataSourceClass
  * @return null|array
  */
 protected function findPropertyDataTypeInfo(MemberMetadata $propertyMetadata, $dataSource, $dataSourceClass)
 {
     if ($dataSource !== null) {
         $dataSource = $propertyMetadata->getReflectionMember($dataSourceClass)->getValue($dataSource);
         if (is_array($dataSource) || $dataSource instanceof \ArrayAccess) {
             return array(null, $dataSource);
         }
         if (is_object($dataSource)) {
             return array(get_class($dataSource), $dataSource);
         }
         return null;
     }
     // Since there is no datasource we need another way to determin the properties class
     foreach ($propertyMetadata->getConstraints() as $constraint) {
         if (!$constraint instanceof Type) {
             continue;
         }
         $type = strtolower($constraint->type);
         $type = $type == 'boolean' ? 'bool' : $constraint->type;
         $isFunction = 'is_' . $type;
         $ctypeFunction = 'ctype_' . $type;
         if (function_exists($isFunction) || function_exists($ctypeFunction)) {
             return null;
         }
         return array($constraint->type, null);
     }
     return null;
 }