ID: 33397
User updated by: nikolaeff at gmail dot com
Reported By: nikolaeff at gmail dot com
Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Linux
PHP Version: 4.3.11
New Comment:
So tell me please, why i should write:
function Site() {
$config = new Config();
$this->db = new Database($config);
$this->config = $config;
}
instead of:
function Site() {
$this->config = new Config();
$this->db = new Database($this->config);
}
???
If it's a feature i'd like to see where it's documented.
Previous Comments:
------------------------------------------------------------------------
[2005-06-19 13:52:54] [EMAIL PROTECTED]
No, you're wrong.
------------------------------------------------------------------------
[2005-06-19 06:57:11] nikolaeff at gmail dot com
Description:
------------
Guess that $site->config shouldn't became reference after it passed to
method by reference. Am i right ?
Reproduce code:
---------------
class Config {}
class Database {
function Database(&$config) {} /* here */
}
class Site {
var $config;
var $db;
function Site() {
$this->config = new Config();
/* turns $this->config to a reference: */
$this->db = new Database($this->config);
}
}
$site = new Site();
var_dump($site);
Expected result:
----------------
object(site)(2) {
["config"]=>
object(config)(0) {
}
["db"]=>
object(database)(0) {
}
}
Actual result:
--------------
object(site)(2) {
["config"]=>
&object(config)(0) {
}
["db"]=>
object(database)(0) {
}
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=33397&edit=1