|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-04-06 07:33 UTC] colder@php.net
[2008-04-06 08:01 UTC] j dot amel83 at gmail dot com
[2008-04-06 08:11 UTC] colder@php.net
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Dec 06 14:00:01 2025 UTC |
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