ID:               44649
 Updated by:       [EMAIL PROTECTED]
 Reported By:      j dot amel83 at gmail dot com
 Status:           Bogus
 Bug Type:         Class/Object related
 Operating System: Windows MCE (Zend Core)
 PHP Version:      5.2.5
 New Comment:

No, I mean that your code uses $this->$object = $object; which will try
to get the property name from $object, which will try to get its string
representation, hence the error.

You obviously want $this->object = $object; instead of $this->$object =
$object;. Same for the other assignations.


Previous Comments:
------------------------------------------------------------------------

[2008-04-06 08:01:44] j dot amel83 at gmail dot com

I try to pass an object to __constrcut method. PHP try to convert my
object to string before assignment.

$this->object = $object;

I think the code was clear.
do you mean that I can't pass an object reference to constructor of a
Class in PHP.

Thanks for your consideration.

------------------------------------------------------------------------

[2008-04-06 07:33:23] [EMAIL PROTECTED]

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

$this->object = ...

------------------------------------------------------------------------

[2008-04-06 07:14:13] j dot amel83 at gmail dot com

Description:
------------
I got Catchable fatal error when I want to pass an object as a
__construct method args and assign it to a class property. PHP try to
convert my object to string before assignment.  

Reproduce code:
---------------
<?php
require_once '../../RAPI/autoload.php';

class ActionController {
        
        /**
         * TransactionScript Reference
         *
         * @var TransactionScript
         */
        public $object;
        
        /**
         * Method name
         *
         * @var String
         */
        public $method;
        
        /**
         * Method parameters
         *
         * @var Array
         */
        public $params = array();
        
        /**
         * Response Name
         *
         * @var String
         */
        public $responseName;
        
        /**
         * @param TransactionScript $object
         * @param String $method
         * @param Array $params
         * @param String $responseName
         */
        public function __construct(TransactionScript $object, $method, Array
$params, $responseName) {
                
                $this->$object  = $object;
                $this->$method  = $method;
                $this->$params  = $params;
                $this->$responseName = $responseName;
                
        }
}

$a = new ActionController(new LongtermAlon(), 'sayHello', array(),
'sname');
echo $a->responseName;
?>

Expected result:
----------------
sname

Actual result:
--------------
Catchable fatal error: Object of class LongtermAlon could not be
converted to string in C:\Inetpub\Refah\testArea\ActionController.php on
line 42


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=44649&edit=1

Reply via email to