ID: 22833
User updated by: rainmaker at omenmedia dot com
Reported By: rainmaker at omenmedia dot com
Status: Closed
Bug Type: Feature/Change Request
Operating System: Windows 2000
-PHP Version: 5.0.0-dev
+PHP Version: 4.3.1
New Comment:
Just for clarification there (for anyone else reading this report), I
believe sniper is saying it's fixed in 5.0.0-dev aka PHP5 aka Zend
Engine 2. So we still have no idea when ZE2 will be ready... and no
chance of having this fixed in ZE1?
Previous Comments:
------------------------------------------------------------------------
[2003-03-24 03:45:10] [EMAIL PROTECTED]
It already is fixed, AFAIK.
------------------------------------------------------------------------
[2003-03-23 20:55:32] rainmaker at omenmedia dot com
Ok, after doing some research it appears that this is a fixed
limitation of Zend Engine 1, correct? I've seen info saying that this
will be fixed in Zend Engine 2... any ideas when that will be ready?
------------------------------------------------------------------------
[2003-03-23 19:57:32] rainmaker at omenmedia dot com
Actually, what I neglected to mention before was that whereas there are
possible ways around this problem when using functions or methods, it
is the *constructor* function of a class where the most potential
problems are encountered.
------------------------------------------------------------------------
[2003-03-23 18:24:22] rainmaker at omenmedia dot com
Firstly, I'll apologise in advance if this issue has been raised
before, but I think I have a valid point here, please hear me out...
When testing some code on another server the other day, I was presented
with quite a few errors relating to call time pass by reference. I
have never seen these errors when developing locally as the server I
use has allow_call_time_pass_reference set to on (as part of the dist
PHP ini).
Going through my code I found the problems it was referring to: a
couple of occasions where I was passing in a value by reference into a
function, where the function definition did not explicitly specify the
argument to be passed by reference. I went about correcting this,
however discovered some limitations with function definition references
and the current PHP engine.
These limitations relate primarily to the fact that you cannot specify
a default value for a reference argument in a function definition,
thereby making the argument *required* and non-optional. This is a
huge issue.
For example, I have a class called StringWriter which takes one
argument (a string) through the constructor. Now, this argument is
*supposed* to be optional, however it also could be (and indeed often
is) a reference to a string somewhere else. If I recode this class to
satisfy the deprecated call time reference passing requirements, more
problems are created:
With call time references, this is all fine:
$writer = new StringWriter();
$writer = new StringWriter("string");
$writer = new StringWriter($aString);
$writer = new StringWriter(&$anotherString);
However without them:
$writer = new StringWriter(); // ERROR, argument required
$writer = new StringWriter("string"); // Fine
$writer = new StringWriter($aString); // Fine
$writer = new StringWriter(&$anotherString); // ERROR (obviously)
In this case, where the argument could equally be a reference or a
non-reference, the user is forced to create the object like this:
$writer = new StringWriter("");
...to avoid an error, which is a PITA if you ask me. Surely the fact
that we are now 'forced' to code without using call time references,
and yet cannot under any circumstances specify that a reference
argument is optional (with a default value) is a huge limitation?
And also, doesn't it make *more* sense to allow the developer to decide
whether they want to pass a value or a reference? I'm not sure of the
technical issues (i.e. zend engine) surrounding call time passed
references, but to me, unless function definition reference arguments
can be made optional, call time passed references just seem to make a
whole lot more sense.
Because some of my code under the current circumstances *requires* call
time passed references, I'm pretty much forced to inform anybody who
uses my code that they must modify their ini to allow them... not good.
Please don't "bogus" this report because I feel this is a huge issue
that need to be addressed.
Thanks.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=22833&edit=1