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


PHP Classes::classOfValue方法代码示例

本文整理汇总了PHP中Classes::classOfValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Classes::classOfValue方法的具体用法?PHP Classes::classOfValue怎么用?PHP Classes::classOfValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Classes的用法示例。


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

示例1: encodeResponseForSuccess

 public static function encodeResponseForSuccess(Method $serviceMethod, $object, SerializationPolicy $serializationPolicy = null, $flags = AbstractSerializationStream::DEFAULT_FLAGS)
 {
     if (is_null($serviceMethod)) {
         throw new NullPointerException('serviceMethod cannot be null');
     }
     if (is_null($serializationPolicy)) {
         $serializationPolicy = self::getDefaultSerializationPolicy();
         throw new NullPointerException('serializationPolicy cannot be null');
     }
     $methodReturnTypeName = $serviceMethod->getReturnType();
     //TODO see if must be an object
     if (empty($methodReturnTypeName)) {
         $methodReturnType = Void::typeClass();
     } else {
         $methodReturnType = Classes::classOf($methodReturnTypeName);
     }
     if ($methodReturnType !== Void::typeClass() && !is_null($object)) {
         // TODO : Verify
         /*if ($methodReturnType->isPrimitive()) {
         			$actualReturnType = self::getPrimitiveClassFromWrapper(Classes::classOf($object));
         		}
         		else {
         			$actualReturnType = Classes::classOf($object);
         		}*/
         $actualReturnType = Classes::classOfValue($object);
         //var_dump($methodReturnType);
         // TODO : Enum manage
         if ($methodReturnType->isEnum() && $actualReturnType === Integer::typeClass()) {
             return self::encodeResponse($methodReturnType, $object, false, $flags, $serializationPolicy);
         }
         if (is_null($actualReturnType) || !$methodReturnType->isAssignableFrom($actualReturnType)) {
             $printedType = self::printTypeName(Classes::classOfValue($object));
             $source = self::getSourceRepresentation($serviceMethod);
             throw new IllegalArgumentException("Type '{$printedType}' does not match the return type in the method's signature : '{$source}'");
         }
     }
     return self::encodeResponse($methodReturnType, $object, false, $flags, $serializationPolicy);
 }
开发者ID:google-code-backups,项目名称:gwtphp-derpc,代码行数:38,代码来源:RPC.php

示例2: autoClass

 public static function autoClass(array &$value)
 {
     $type = null;
     for ($i = 0; $i < count($value); $i++) {
         $itype = Classes::classOfValue($value[$i]);
         if (is_null($type)) {
             $type = $itype;
         } else {
             if ($type != $itype) {
                 return self::clazz(Object::clazz(), 1);
             }
         }
     }
     return self::clazz($type, 1);
 }
开发者ID:google-code-backups,项目名称:gwtphp-derpc,代码行数:15,代码来源:classes.php

示例3: makeObject

 private function makeObject(Clazz $type, $value)
 {
     // no anonymous class, and no local class in php
     $manualType = $type;
     $customSerializer = null;
     do {
         $customSerializer = SerializabilityUtil::hasCustomFieldSerializer($manualType);
         if ($customSerializer != null) {
             break;
         }
         $manualType = $manualType->getSuperClass();
     } while ($manualType != null);
     $ins = null;
     if ($customSerializer != null) {
         $ins = $this->serializeWithCustomSerializer($customSerializer, $value, $type, $manualType);
     } else {
         $ins = new InstantiateCommand($type);
         $this->identityMap->put($value, $ins);
     }
     if ($type != $manualType) {
         if (!Classes::classOf('GWTSerializable')->isAssignableFrom($type) && !Classes::classOf('IsSerializable')->isAssignableFrom($type)) {
             throw new SerializationException($type->getName() . ' is not a serializable type');
         }
     }
     while ($type != $manualType) {
         $serializableFields = $this->clientOracle->getOperableFields($type);
         foreach ($serializableFields as $declField) {
             assert($declField != null);
             //echo '[' . $declField->getName() . ' = ' . $declField->getType() . ']<br />';
             $accessor = Accessors::get($declField->getType());
             $valueCommand = null;
             $fieldValue = $accessor->get($value, $declField);
             if (is_null($fieldValue)) {
                 $valueCommand = NullValueCommand::INSTANCE();
             } else {
                 $fieldType = $declField->getType()->isPrimitive() ? $declField->getType() : ($declField->hasType() ? $declField->getType() : Classes::classOfValue($fieldValue));
                 $valueCommand = $this->makeValue($fieldType, $fieldValue);
             }
             //echo '{set ' . $declField->getDeclaringClass()->getName() . ' / ' . $declField->getName() . ' / ' . $valueCommand . '}';
             $ins->set($declField->getDeclaringClass(), $declField->getName(), $valueCommand);
         }
         $type = $type->getSuperClass();
     }
     return $ins;
 }
开发者ID:google-code-backups,项目名称:gwtphp-derpc,代码行数:45,代码来源:SerializationStreamWriter.php

示例4: getClassForSerialization

 private static function getClassForSerialization($instance, Clazz $instanceClass = null)
 {
     assert(!is_null($instance));
     /*if ($instance instanceof SerializedEnum) {
     			return $instance->getEnumClass();
     		}*/
     // TODO if enum
     /*if (instance instanceof Enum<?>) {
         Enum<?> e = (Enum<?>) instance;
         return e.getDeclaringClass();
       } else {
         return instance.getClass();
       }*/
     if (is_null($instanceClass)) {
         return Classes::classOfValue($instance);
     } else {
         return $instanceClass;
     }
 }
开发者ID:google-code-backups,项目名称:gwtphp-derpc,代码行数:19,代码来源:ServerSerializationStreamWriter.php


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