joomla-framework / github-api

Joomla Framework GitHub Package
GNU General Public License v2.0
26 stars 29 forks source link

Autocompletion for returned json data #2

Open dongilbert opened 10 years ago

dongilbert commented 10 years ago

See conversation here:

http://www.reddit.com/r/PHP/comments/1zix9k/github_api_client_feedback_welcome/cfuym7r

elkuku commented 10 years ago

Damn, I forgot to watch this repo, sorry for the late response.... Some time ago I was experimenting with creating some abstract classes that contain the properties for the returned json data. Those classes can be generated using this file that contains all the return objects and their properties: https://github.com/github/developer.github.com/blob/master/lib/resources.rb

I think that's doable :wink:

dongilbert commented 10 years ago

I helped flesh out a Stripe PHP API where we had value objects for the returned json data. It uses JMSerializer and Doctrine Annotations to fill the value object, and it gives you nice camelCased method names instead. :P

I think we can do something like this - https://github.com/jlinn/stripe-api-php/tree/master/src/Response

elkuku commented 10 years ago

Looks like a nice concept. As far as I can see, it would require passing the class name to our processResponse() method so the JSON data can be properly deserialized. (I didn't knew about the serializer script - I think it is the JM_S_Serializer? - nice)

CamelCase properties also look better then under_scored ones in the PHP world. The only concern I have here is that we would move away from the GitHub API and it's wonderful documentation and, of course, there will be a huge b/c break..

What about a "simple" auto complete using dumb classes with public properties which are used only as the return type in the method doc blocks?