[thelist] PHP object property getters/setters

Matt Warden mwarden at gmail.com
Wed Nov 30 14:41:57 CST 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Andrew Kamm wrote:
> Is there anything that would work similar to this non-functional, but
> oh-so-desireable syntax:
> 
> $cust->getState()->stateName; //won't call the state name :(

Ah, yes, the biggest pain of PHP. Really sucks when the language keeps
you from using good programming practices.

Have you tried, maybe:

{$cust->getState()}->stateName

Otherwise, I would probably just drop the use of accessors and mutators,
unless there is a case where it is necessary. And it really pains me to
say that, because if a case that didn't need an accessor/mutator
suddenly evolves into a case that does need one, then you're goign to be
changing a lot of code.

I was hoping that in PHP5 they would allow chaining like that.

- --
Matt Warden
Miami University
Oxford, OH, USA
http://mattwarden.com


This email proudly and graciously contributes to entropy.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDjg6VrI3LObhzHRMRAllSAJ9beTSL5LC3VWbK3vEpDHvx6vowrgCgt0Q9
j8TPQB7QmyhygqHS7t8olVE=
=zjxn
-----END PGP SIGNATURE-----



More information about the thelist mailing list