|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-04-20 08:17 UTC] mogui83 at gmail dot com
Description:
------------
It seems that passing more than one argument to a constructor class cause an uncaught crash in the script, while call:
var c = new Cow('Molly');
works as expected, calling:
var c = new Cow('Molly','Bar');
cause a crash without any error
maybe it's my problem but I've tried anything reducing the problem to the default example.
thanks for the great work anyway
Reproduce code:
---------------
class Cow {
private $_name;
private $_milked;
public function __construct($name, $name2) {
$this->setName($name.' and '.$name2);
$this->_milked = 0;
}
// name setter/getter
public function setName($name) {
$this->_name = $name;
}
public function getName() {
return $this->_name;
}
// milking status setter/getter
public function milk() {
$this->_milked = 1;
}
public function getMilked() {
return $this->_milked;
}
public function output() {
if ($this->getMilked() == 1) {
return $this->getName() . ' has been milked today.';
} else {
return 'Time to milk ' . $this->getName();
}
}
}
$script = <<<END
var c = new Cow('Molly','Bar');
var d = new Date();
var ch = d.getHours();
if (ch > 8) {
c.milk();
}
c.output();
END;
echo $js->evaluateScript($script);
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 18:00:01 2025 UTC |
in function generic_constructor() ... /* ready parameters */ params = emalloc(argc * sizeof(zval**)); for (i = 0; i < argc; i++) { zval *val; MAKE_STD_ZVAL(val); jsval_to_zval(val, cx, &argv[i]); SEPARATE_ARG_IF_REF(val); params[i] = &val; // !!!!bug is here!!! all params references to the stack variable `val` } ...