Re: String passed to object constructor turning into an instance of that object?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux