Danack / PHP-to-Javascript

A tool for converting simple PHP objects/code to Javascript, so that code for manipulating objects can be used both server-side and client-side.
Other
104 stars 32 forks source link

function using unset is broken. #12

Closed Danack closed 11 years ago

Danack commented 11 years ago

Just noticed that this:

static function fromJSON($jsonString){ $data = json_decode($jsonString);

    if(array_key_exists('ObjectType', $data) == TRUE){
        //Could do sanity check on type here.
        unset($data['ObjectType']);
    }

    return self::factory($data);
}

Is being converted to:

JSONFactory.fromJSON = function (jsonString){ var data = json_decode(jsonString);

    if(array_key_exists('ObjectType', data) == true){
        //Could do sanity check on type here.
        (data['ObjectType']);
    }

    return JSONFactory.factory(this.data);
}

i.e. the unset is disappearing - which is weird.

Danack commented 11 years ago

Fixed for small values of fixed. unset is a php language construct so added support for converting it to javascript delete.