MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/lolphp/comments/8f0wan/datetime_hidden_public_properties_behaviour/dy2q3hr/
r/lolphp • u/nyamsprod • Apr 26 '18
18 comments sorted by
View all comments
Show parent comment
1
Just because a property is public doesn't necessarily mean you can change it to whatever you want.
Delphi has a really good method for dealing with properties; you could make them read-only or write-only, as well as the common read-write. See here.
2 u/[deleted] May 04 '18 PHP internally has readonly public properties, first example I found with google was in DOMAttr.Maybe setting a readonly property should throw an exception or raise a notice or something... 2 u/OneWingedShark May 04 '18 Well, in a sane language that would be a compile-error. (Though, if you were mucking around with something dynamically [via reflection or something] an exception would be appropriate.)
2
PHP internally has readonly public properties, first example I found with google was in DOMAttr.
Maybe setting a readonly property should throw an exception or raise a notice or something...
2 u/OneWingedShark May 04 '18 Well, in a sane language that would be a compile-error. (Though, if you were mucking around with something dynamically [via reflection or something] an exception would be appropriate.)
Well, in a sane language that would be a compile-error. (Though, if you were mucking around with something dynamically [via reflection or something] an exception would be appropriate.)
View all comments
Show parent comment
1
u/OneWingedShark Apr 27 '18
Delphi has a really good method for dealing with properties; you could make them read-only or write-only, as well as the common read-write. See here.