[PHP]
<?
class EditResultGener ator extends MethodGenerator ForActionPerfor mer {
/**
* Create an instance of itself if $this does not yet exist as an
EditResultGener ator class object
*
* @access private
* @see is_class
*/
function &generateSel f() { // STATIC VOID METHOD
if (!is_object($th is) || @!is_class($thi s, 'EditResultGene rator')) {
$this->self =& new EditResultGener ator();
} else {
$this->self =& $this;
}
}
}
?>
[/PHP]
This self-generating function serves a purpose to ensure that if part
of the application does this:
[PHP]
<?
EditResultGener ator::getResult ();
?>
[/PHP]
That it will work *exactly* the same as if I did this:
[PHP]
<?
$edit =& new EditResultGener ator();
$result = $edit->getResult();
?>
[/PHP]
However, I cannot change hundreds of lines of code from the former to
the latter just to ensure instantiation is uniform, so I'm stuck with
the fact that I have to generate a $this->self EditResultGener ator
class object if $this does not exist, otherwise, $this->self must be
*absolutely identical* to $this, in fact, be a reference!
This works beautifully in PHP 4.3+, but bombs in PHP 5.2.
How can I get it to work in PHP 5.2+?
Phil
<?
class EditResultGener ator extends MethodGenerator ForActionPerfor mer {
/**
* Create an instance of itself if $this does not yet exist as an
EditResultGener ator class object
*
* @access private
* @see is_class
*/
function &generateSel f() { // STATIC VOID METHOD
if (!is_object($th is) || @!is_class($thi s, 'EditResultGene rator')) {
$this->self =& new EditResultGener ator();
} else {
$this->self =& $this;
}
}
}
?>
[/PHP]
This self-generating function serves a purpose to ensure that if part
of the application does this:
[PHP]
<?
EditResultGener ator::getResult ();
?>
[/PHP]
That it will work *exactly* the same as if I did this:
[PHP]
<?
$edit =& new EditResultGener ator();
$result = $edit->getResult();
?>
[/PHP]
However, I cannot change hundreds of lines of code from the former to
the latter just to ensure instantiation is uniform, so I'm stuck with
the fact that I have to generate a $this->self EditResultGener ator
class object if $this does not exist, otherwise, $this->self must be
*absolutely identical* to $this, in fact, be a reference!
This works beautifully in PHP 4.3+, but bombs in PHP 5.2.
How can I get it to work in PHP 5.2+?
Phil