Re: String passed to object constructor turning into an instance of that object?
| From: | Kris Deugau | Date: | Thu, 16 Dec 2010 23:04:47 +0000 |
| Subject: | Re: String passed to object constructor turning into an instance of that object? | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-310091@lists.php.net to get a copy of this message | ||
Nathan Nobbe wrote:
probly something screwy going on w/ the old style of naming constructors. 2 things, 1. can you post the Tag constructor as it reads now?function Tag($tag='', $tagContent='') { $this->tagContent = $tagContent; $this->tag = $tag; $this->showEndTag = false; $this->attributes = array(); $this->children = array(); }
2. try modifying Tag & SelectBoxOption to have __construct() instead of Tag() & SelectBoxOption(), then call parent::__construct() from inside of SelectBoxOption::__construct(); see if that clears up your problem under 5.2 (read: this will only be a partial solution as it only addresses one child of Tag).Mmm. I hoped this would help, but all it seems to have done was cascade errors across the rest of Tag's object children. :( Copying the old constructor back in resolved that, but I'm not sure whether that reintroduces the root problem. Other objects derived from Tag seem to work just fine; I came into this chunk of the code trying to find out why a SelectBoxOption didn't seem to have a toString function - and then why trying to access what should be the value and name the same way as with other objects derived at some level from Tag blew up instead of working happily. I'll try converting all of the constructors to your recommendation as above, but given that the problem is only happening with this one class, I'm not sure that will do much. (A "don't-break-crusty-old-code" option for php.ini would be handy...) The class hierarchy I've dug up so far looks like this (and appears to have been entirely defined by the original developer): Object Fieldset RadioButtonGroup Tag
Column
FormObject
FormInput
CheckBox
DateSelector
Editor
FileField
FormButton
HiddenField
PasswordField
RadioButton
SelectBox
PopulatedSelectBox
RecursiveSelectBox
TextArea
TextField
Form
Row
Table
SelectBoxOption
-kgd