本文整理汇总了PHP中Classes::classOf方法的典型用法代码示例。如果您正苦于以下问题:PHP Classes::classOf方法的具体用法?PHP Classes::classOf怎么用?PHP Classes::classOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Classes
的用法示例。
在下文中一共展示了Classes::classOf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processCall
public function processCall($payload)
{
$this->checkPermutationStrongName();
try {
$rpcRequest = RPC::decodeRequest($payload, Classes::classOf($this->delegate), $this);
$this->onAfterRequestDeserialized($rpcRequest);
return RPC::invokeAndEncodeResponse($this->delegate, $rpcRequest->getMethod(), $rpcRequest->getParameters(), $rpcRequest->getSerializationPolicy(), $rpcRequest->getFlags());
} catch (IncompatibleRemoteServiceException $ex) {
echo $ex;
/*log(
"An IncompatibleRemoteServiceException was thrown while processing this call.",
ex);
*/
return RPC::encodeResponseForFailure(null, $ex);
} catch (RpcTokenException $ex) {
//log("An RpcTokenException was thrown while processing this call.",
//tokenException);
return RPC::encodeResponseForFailure(null, $ex);
}
}
示例2: objectCall
/** @return boolean */
public function objectCall(CustomObject $param)
{
if (Classes::classOf($param) != Classes::classOf('CustomObject')) {
return false;
}
return $param->number == 5;
}
示例3: maybeDeobfuscate
private static function maybeDeobfuscate(ServerSerializationStreamReader $streamReader, $name)
{
if ($streamReader->hasFlags(AbstractSerializationStream::FLAG_ELIDE_TYPE_NAMES)) {
$serializationPolicy = $streamReader->getSerializationPolicy();
if (!serializationPolicy instanceof TypeNameObfuscator) {
throw new IncompatibleRemoteServiceException('RPC request was encoded with obfuscated type names, ' . 'but the SerializationPolicy in use does not implement ' . Classes::classOf(TypeNameObfuscator)->getName());
}
$maybe = $serializationPolicy->getClassNameForTypeId($name);
if (!is_null($maybe)) {
return $maybe;
}
} else {
if (($index = mb_strpos($name, '/')) !== false) {
return mb_substr($name, 0, $index);
}
}
return $name;
}
示例4: 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;
}
示例5: deserialize
protected function deserialize($typeSignature)
{
$instance = null;
try {
$instanceClass = null;
if ($this->hasFlags(self::FLAG_ELIDE_TYPE_NAMES)) {
if ($this->getSerializationPolicy() instanceof TypeNameObfuscator) {
$obfuscator = $this->getSerializationPolicy();
$instanceClassName = $obfuscator->getClassNameForTypeId($typeSignature);
$instanceClass = Classes::classOf($instanceClassName);
} else {
throw new SerializationException('The GWT module was compiled with RPC type name elision enabled, but ' . Classes::classOf($this->getSerializationPolicy())->getFullName() . ' does not implement ' + Classes::classOf('TypeNameObfuscator')->getFullName());
}
} else {
$serializedInstRef = SerializabilityUtilEx::decodeSerializedInstanceReference($typeSignature);
$instanceClass = Classes::classOf($serializedInstRef->getName());
$this->validateTypeVersions($instanceClass, $serializedInstRef);
}
assert(!is_null($this->serializationPolicy));
$this->serializationPolicy->validateDeserialize($instanceClass);
$customSerializer = SerializabilityUtilEx::hasCustomFieldSerializer($instanceClass);
$index = $this->reserveDecodedObjectIndex();
//TODO to test
$transform = $this->getCustomSerializerTransform($customSerializer);
if (!is_null($transform)) {
$instance = $transform->invoke($this);
$this->rememberDecodedObject($index, $instance);
} else {
$instance = $this->instantiate($customSerializer, $instanceClass);
$this->rememberDecodedObject($index, $instance);
$replacement = $this->deserializeImpl($customSerializer, $instanceClass, $instance);
// It's possible that deserializing an object requires the original proxy
// object to be replaced.
if (instance !== $replacement) {
$this->rememberDecodedObject($index, $replacement);
$instance = $replacement;
}
}
return $instance;
} catch (Exception $e) {
throw new SerializationException($e);
}
}
示例6: findClass
private function findClass($token)
{
if (isset($this->classCache[$token])) {
return $this->classCache[$token];
}
$className = $this->clientOracle->getTypeName($token);
if ($className == null) {
$className = $token;
}
if (strstr($className, '[]') !== false) {
$firstIndex = -1;
$j = -1;
$dims = 0;
while (($j = strpos($className, '[')) !== false) {
if ($dims++ == 0) {
$firstIndex = $j;
}
}
$componentType = $this->findClass(substr($className, 0, $firstIndex));
assert($componentType != null);
$clazz = ArrayType::clazz($componentType, $dims);
} else {
$clazz = Classes::classOf($className);
}
$this->classCache[$token] = $clazz;
return $clazz;
}
示例7: __construct
public function __construct($exceptionClassName, $msg)
{
$this->exceptionClass = Classes::classOf($exceptionClassName);
$this->detailMessage = $msg;
}
示例8: loadFromStream
public static function loadFromStream($filename, GenericList $classNotFoundExceptions)
{
if (is_null($filename)) {
throw new NullPointerException('InputStream');
}
$whitelistSer = new HashMap();
$whitelistDeser = new HashMap();
$typeIds = new HashMap();
$clientFields = new HashMap();
$br = new BufferedReader($filename);
$line = $br->readLine();
$lineNum = 1;
while (!is_null($line)) {
$line = trim($line);
if (mb_strlen($line) > 0) {
$components = explode(',', $line);
if ($components[0] === self::CLIENT_FIELDS_KEYWORD) {
/*
* Lines starting with '@ClientFields' list potentially serializable fields known to
* client code for classes that may be enhanced with additional fields on the server.
* If additional server fields are found, they will be serizalized separately from the
* normal RPC process and transmitted to the client as an opaque blob of data stored
* in a WeakMapping associated with the object instance.
*/
$binaryTypeName = trim($components[1]);
try {
$clazz = Classes::classOf($binaryTypeName);
$fieldNames = new HashSet();
for ($i = 2; $i < count($components); $i++) {
$fieldNames->add($components[$i]);
}
$clientFields->put($clazz, $fieldNames);
} catch (ClassNotFoundException $e) {
// Ignore the error, but add it to the list of errors if one was
// provided.
if (!is_null($classNotFoundExceptions)) {
$classNotFoundExceptions->add($e);
}
}
} else {
if (count($components) != 2 && count($components) != 7) {
throw new ParseException(self::FORMAT_ERROR_MESSAGE, $lineNum);
}
for ($i = 0; $i < count($components); $i++) {
$components[$i] = trim($components[$i]);
if (mb_strlen($components[$i]) == 0) {
throw new ParseException(self::FORMAT_ERROR_MESSAGE, $lineNum);
}
}
$binaryTypeName = trim($components[0]);
if (count($components) == 2) {
$fieldSer = $fieldDeser = true;
$instantSer = $instantDeser = Boolean::valueOf($components[1]);
$typeId = $binaryTypeName;
} else {
$idx = 1;
// TODO: Validate the instantiable string better
$fieldSer = Boolean::valueOf($components[$idx++]);
$instantSer = Boolean::valueOf($components[$idx++]);
$fieldDeser = Boolean::valueOf($components[$idx++]);
$instantDeser = Boolean::valueOf($components[$idx++]);
$typeId = $components[$idx++];
if (!$fieldSer && !$fieldDeser && TypeNameObfuscator::SERVICE_INTERFACE_ID != $typeId) {
throw new ParseException('Type ' . $binaryTypeName . ' is neither field serializable, field deserializable ' . 'nor the service interface : ', $lineNum);
}
}
try {
$clazz = Classes::classOf($binaryTypeName);
if ($fieldSer) {
$whitelistSer->put($clazz, $instantSer);
}
if ($fieldDeser) {
$whitelistDeser->put($clazz, $instantDeser);
}
$typeIds->put($clazz, $typeId);
} catch (ClassNotFoundException $e) {
// Ignore the error, but add it to the list of errors if one was
// provided.
if (!is_null($classNotFoundExceptions)) {
$classNotFoundExceptions->add($e);
}
}
}
}
$line = $br->readLine();
$lineNum++;
}
return new StandardSerializationPolicy($whitelistSer, $whitelistDeser, $typeIds, $clientFields);
}
示例9: classOfArray
private static function classOfArray($className)
{
// Java array style
if ($className[0] == ArrayType::SIGNATURE) {
if (self::exists($className)) {
return self::getClass($className);
} else {
$count = substr_count($className, '[');
$type = mb_substr($className, $count);
if ($type[0] == Object::SIGNATURE) {
$clazz = Classes::classOf(mb_substr($type, 1, mb_strlen($type) - 2));
} else {
$clazz = self::$SIGNATURES[$type[0]];
}
$reformed = $clazz->getName() . str_repeat('[]', $count);
$wanted = self::classOfArray($reformed);
self::registerClass($className, $wanted);
return $wanted;
}
} else {
$count = substr_count($className, '[');
$pos = strpos($className, '[');
$type = substr($className, 0, $pos);
$className = $type . str_repeat('[]', $count);
if (self::exists($className)) {
return self::getClass($className);
} else {
$compType = $type . str_repeat('[]', $count - 1);
$class = new ArrayClazz(Object::clazz(), Classes::classOf($compType), $count);
self::registerClass($class->getName(), $class);
return $class;
}
}
}
示例10: isInstantiable
private function isInstantiable(Clazz $clazz)
{
if ($clazz->isPrimitive()) {
return true;
}
if ($clazz->isArray()) {
return $this->isInstantiable($clazz->getComponentType());
}
if (Classes::classOf('IsSerializable')->isAssignableFrom($clazz)) {
return true;
}
return Serializability::hasCustomFieldSerializer($clazz) != null;
}
示例11: getObjectTypeSignature
protected function getObjectTypeSignature($instance, Clazz $instanceClass = null)
{
assert(!is_null($instance));
$clazz = self::getClassForSerialization($instance, $instanceClass);
if ($this->hasFlags(self::FLAG_ELIDE_TYPE_NAMES)) {
if ($this->serializationPolicy instanceof TypeNameObfuscator) {
return $this->serializationPolicy->getTypeIdForClass($clazz);
}
throw new SerializationException('The GWT module was compiled with RPC ' . 'type name elision enabled, but ' . Classes::classOf($this->serializationPolicy)->getFullName() . ' does not implement ' . Classes::classOf('TypeNameObfuscator')->getFullName());
} else {
return SerializabilityUtilEx::encodeSerializedInstanceReference($clazz, $this->serializationPolicy);
}
}
示例12: loadCustomFieldSerializer
public static function loadCustomFieldSerializer(Clazz $customSerializerClass)
{
$customFieldSerializer = self::$CLASS_TO_SERIALIZER_INSTANCE->get($customSerializerClass);
if (is_null($customFieldSerializer)) {
if (Classes::classOf('CustomFieldSerializer')->isAssignableFrom($customSerializerClass)) {
$customFieldSerializer = $customSerializerClass->newInstance();
} else {
$customFieldSerializer = self::$NO_SUCH_SERIALIZER;
}
self::$CLASS_TO_SERIALIZER_INSTANCE->put($customSerializerClass, $customFieldSerializer);
}
if ($customFieldSerializer == self::$NO_SUCH_SERIALIZER) {
return null;
} else {
return $customFieldSerializer;
}
}
示例13: accept
public function accept(RpcCommand $command)
{
if (!$command instanceof ValueCommand) {
throw new SerializationException(Classes::classOf($command)->getName());
}
$this->container->addValue($command);
}
示例14: instantiateInstance
public function instantiateInstance(SerializationStreamReader $streamReader)
{
throw new SerializationException('instantiateInstance is not supported by ' . Classes::classOf($this)->getFullName);
}
示例15: constructorFunctionArray
private function constructorFunctionArray(ArrayValueCommand $x)
{
$targetClass = ArrayType::clazz($x->getComponentType());
$functionName = $this->constructorFunctions->get($targetClass);
if (!is_null($functionName)) {
return $functionName;
}
$initValuesId = $this->clientOracle->getMethodIdByClassName('com.google.gwt.lang.Array', 'initValues', array('Ljava/lang/Class;', 'Lcom/google/gwt/core/client/JavaScriptObject;', 'I', 'Lcom/google/gwt/lang/Array;'));
assert(!is_null($initValuesId));
$classLitId = $this->clientOracle->getFieldIdByClassName('com.google.gwt.lang.ClassLiteralHolder', $this->getJavahSignatureName($x->getComponentType()) . '_classLit');
assert(!is_null($classLitId));
$functionName = $this->clientOracle->createUnusedIdent($classLitId);
$this->constructorFunctions->put($targetClass, $functionName);
$castableTypeData = $this->clientOracle->getCastableTypeData($targetClass);
if (is_null($castableTypeData)) {
$castableTypeData = $this->clientOracle->getCastableTypeData(Classes::classOf('Object[]'));
}
$queryId = $this->clientOracle->getQueryId($x->getComponentType());
if ($queryId == 0) {
$queryId = $this->clientOracle->getQueryId(Classes::classOf('Object'));
}
$ident = '_0';
// function foo(_0) {return initValues(classLid, castableTypeData, queryId, _0)}
$this->_function();
$this->push($functionName);
$this->lparen();
$this->push($ident);
$this->rparen();
$this->lbrace();
$this->_return();
$this->push($initValuesId);
$this->lparen();
$this->push($classLitId);
$this->comma();
$this->push($castableTypeData->toJs());
$this->comma();
$this->push(String::valueOf($queryId));
$this->comma();
$this->push($ident);
$this->rparen();
$this->rbrace();
$this->flush($x);
return $functionName;
}