warmwinter / hessianphp

Automatically exported from code.google.com/p/hessianphp
MIT License
0 stars 0 forks source link

Private or protected class attributes are not transmitted / Use of encapsulated classes (get and set function) #12

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a Service that uses a class XY with private and/or protected 
attributes.
2. Call a hessian method with this class XY as a parameter
3. Only the public attributes are transmitted.

What is the expected output? What do you see instead?

I'd expect the private and protected attributes to also be transfered, not only 
the public attributes.

What version of the product are you using? On what operating system?

Using Version 2.0.2

Please provide any additional information below.

We want to use encapsulated property access for our objects that we transmit 
with hessianphp. Therefore we extended the hessianphp classes to support a 
"useGetSetMethods" option. When this option is set, instead of accessing the 
attributes directly the writer/parser then invoke the coresponding 
getAttribute()/setAttribute() functions. 

I provide the changes to the sources below and it would be nice, if you would 
include this change in your release. Please feel free to adapt the changes in 
the way you like or contact me, if you have any questions about it. Please also 
note, that this option requires the classes to name the access functions 
'getXyz' and 'setXyz' where 'Xyz' is the accessed property and that there must 
be a set-function to every get-function.

As I am pretty new to hessianphp, it would be nice if you could check the 
changes if they conflict with anything in the classes.

THANKS FOR YOUR GREAT LIBRARY!

Original issue reported on code.google.com by ole...@gmx.net on 16 Feb 2011 at 3:51

Attachments:

GoogleCodeExporter commented 9 years ago
I extended the new option "useGetSetMethods with some following features and 
I also included the patch for the issue 13 (Date parsing writing):

- Set/Get methods now must have a capital letter after the 'set' (i.e. 
setVar1/getVar1 but not setvar1/getvar1), though it is now conform with camel 
case notation / Java Bean. This is done by using ucfirst and lcfirst functions. 
Since lcfirst is first available in PHP 5.3, so I added it to HessianUtils.
- stdClass does now have higher priority than using set/get-method, so 
attributes of stdClass are now always directly accessed. 

Hessian2Parser.php:
 - Set method is now only called, if there is a public set method available in the class, so it no longer crashes, when an object has only a get method for an attribute, but no set-method. So only attributes that have both public set and public get functions are transmitted.

I attach the patch as a file and would be pleased, if you would have a look on 
it and apply it to the current code. Thanks a lot.

Original comment by ole...@gmx.net on 23 Feb 2011 at 10:15

Attachments: