Question about mixed read-write property

From: Date: Sat, 20 Jul 2013 16:50:07 +0000
Subject: Question about mixed read-write property
Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-10889@lists.php.net to get a copy of this message
Hi, I have a mixed read-write property here: http://docs.php.net/manual/en/class.evwatcher.php#evwatcher.props.data The property write handler https://bitbucket.org/osmanov/pecl-ev/src/589ccf73896ea0c2763e8923ea054ccc825a732c/pe.c?at=master#cl-240 calls php_ev_prop_write_zval. static inline void php_ev_prop_write_zval(zval **ppz, zval *value) { if (!*ppz) { MAKE_STD_ZVAL(*ppz); } REPLACE_ZVAL_VALUE(ppz, value, 1); } Should I call REPLACE_ZVAL_VALUE with or without "copy"(1)? I suspect it should be 0. Let's look at some PHP code. The following script outputs "123".
<?php
class indicator {
	public function __destruct() {
		echo "2";
	}
}

class A {
	public $data;
}

function test() {
	$a = new A();

	$indicator = new indicator();
	$a->data = $indicator;

	debug_zval_dump($indicator);
	debug_zval_dump($a);
	$indicator = null;

	echo "1";
	$a = null;
	echo "3";
}

test();
echo "\n";
But the code below outputs: 13 2 However, when I change the last argument of REPLACE_ZVAL_VALUE to zero, both scripts output the same "123" string. So should I call REPLACE_ZVAL_VALUE(ppz, value, 0); instead? -- Regards, Ruslan Osmanov

« previous php.pecl.dev (#10889) next »