ZF-8005: Actionscript function arguments not passed as correct type to Zend_Amf

Description

The Zend_Amf specification states that a Number type returned from flash will map to a float in PHP. That's fine but why does the number 16 get parsed as 6.1026988574311E_320 ? I actually want to pass an integer but even if I do an explicit cast in Actionscript to type:int, Charles Proxy still reports that the value being passed is of type:Number so Zend/Amf sees it as a float. The number 16 is actually a parameter in a netconnection call from Actionscript so I don't believe it relates to object mapping between Actionscript and Zend_AMF.

As a workaround, I can pass the parameter as a string and this works but I think I should be able to pass it as a true integer.

connection.call("myservice.doSomething()", responder, id); //id is the value in question

I have tried setting the id to int elsewhere in the code and also passing int(16) but the value always arrives as a float in PHP and cannot be cast to an integer (PHP rounds it to zero).

Does anyone know why this is happening? Is it possible there is a bug in Zend_Amf causing it?

Comments

There is a similar problem with the results sent from PHP to Flex. If an array or object value is a float in PHP, a wrong value arrives in flex. e.g. a price from db of 59.56 arrives in Flex as 1.2179606413329341e+43. If it's a string on PHP side, it arrives correct.

The same with too big integer values, they are converted to wrong float value.

See this thread re this being an 'endian' problem.

http://stackoverflow.com/questions/1503746/…

The problem is in the class Zend_Amf_Util_BinaryStream: in the constructor the class variable _bigEndian is fix set to 1. If change this to 0, it's working for me.

My server is an i5 (AS/400) which has PPC architecture. I thought PPC is big endian and x86 is little endian? But it works if _bigEndian is set to false!

Bulk change of all issues last updated before 1st January 2010 as "Won't Fix".

Feel free to re-open and provide a patch if you want to fix this issue.