google-code-backups / sabreamf

Automatically exported from code.google.com/p/sabreamf
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

SABREAMF_OBJECT_AS_ARRAY creates object with AMF0 #16

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What is the expected behavior of this function? Right now it checks for
SABREAMF_OBJECT_AS_ARRAY but casts as (object). Seems like it should by
default cast to (object) and use array if SABREAMF_OBJECT_AS_ARRAY happens.
I'm writing unit tests for the AMF0 Serializer/Desrialize and rand across this.

        public function readObject() {

            $object = array();
            $this->refList[] =& $object;
            while (true) {
                $key = $this->readString();
                $vartype = $this->stream->readByte();
                if ($vartype==SabreAMF_AMF0_Const::DT_OBJECTTERM) break;
                $object[$key] = $this->readAmfData($vartype);
            }
            if (defined('SABREAMF_OBJECT_AS_ARRAY')) {
                $object = (object)$object;
            }
            return $object;    

        }

Original issue reported on code.google.com by msthorn...@gmail.com on 24 Sep 2009 at 7:09

GoogleCodeExporter commented 8 years ago
"Fixing" this obviously breaks compatibility since most installs are expecting 
to get
an array back.

Original comment by msthorn...@gmail.com on 24 Sep 2009 at 7:09

GoogleCodeExporter commented 8 years ago
So it looks like it actually does the exact opposite of what it's supposed to 
do? :( 

Original comment by evert...@gmail.com on 24 Sep 2009 at 8:23

GoogleCodeExporter commented 8 years ago
Yeah, seems so.

Original comment by msthorn...@gmail.com on 24 Sep 2009 at 8:40

GoogleCodeExporter commented 8 years ago
I'll write my unit test to test for the behavior that happens now. If the 
behavior is
wrong then the tests and the code can be fixed.

Original comment by msthorn...@gmail.com on 24 Sep 2009 at 9:14

GoogleCodeExporter commented 8 years ago
The behaviour is wrong for what the original goal of that setting was; 
however.. this
might be yet another case where a BC break is not an option. 

Original comment by evert...@gmail.com on 24 Sep 2009 at 9:31