assign to $this
| From: | Lorenzo Alberton | Date: | Thu, 15 Apr 2004 12:11:19 +0000 |
| Subject: | assign to $this | ||
| Groups: | php.pear.qa | ||
| Request: | Send a blank email to pear-qa+get-1116@lists.php.net to get a copy of this message | ||
Hi guys,
this will probably start another long thread
(I hope not, though, since I'm still catching
up with the long Easter ones...).
I think it's time to face the "assign to $this" problem.
I'm focusing on PEAR::Pager now, but the same
applies to these packages, maybe others as well:
http://pear.php.net/bugs/search.php?search_for=assign&cmd=display&status=Open
The solution proposed by Toby in the QA reports
won't work, as php5 will die as soon as it *sees*
an assignment to $this, even if it never encounters
it in its workflow, so "if()" checks are out of the game.
Hence, for most packages, it's simply impossible
to fix the issue without breaking BC.
Now, I'll talk about Pager v2.x, since it's the one I'm involved in...
Back in September, when the assignment to $this was still
allowed in php5, I used that workaround for one and only one
reason: mantaining BC with Pager v.1.x. It was the *only*
way I found to do that. I've asked many times for alternate
solutions (please check the archives), but nobody could
show one.
Now, I can add a factory() method in no time, that
will solve the problem in an elegant way, but will
break BC. Not a big deal, but still a BC break:
$pager =& Pager::factory($options);
instead of
$pager =& new Pager($options);
Currently, there's an easy workaround for php5,
as I described in the manual at the bottom of this page:
http://pear.php.net/manual/en/package.html.pager.intro.php
but it's still a workaround and not a final solution.
For the records, I'm *strongly* against releasing a
Pager v.3.x just because of that.
Can I add the factory method, and release a new
*minor* version of Pager v.2.x?
I will clearly document the change in the manual
and add a big warning in the changelog, of course.
Thanks for your attention,
Lorenzo