Re: Adding a few debug helpers to php4.x
| From: | Todd Ruth | Date: | Wed, 03 Mar 2004 20:21:07 +0000 |
| Subject: | Re: Adding a few debug helpers to php4.x | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-8353@lists.php.net to get a copy of this message | ||
Thanks for the replies.
First, in response to Stefan...
> et@edea:~$ php -r '$a = 2; $b = $a; debug_zval_dump($a);'
> long(2) refcount(3)
> et@edea:~$
I missed that one. Thanks! With that I'd at least be
able to implement ref_count in php.
And then in response to Adam...
> > ============ (dis)allow_copies(mixed var) ============
>
> What about implementing this directly in php? You could use
> trigger_error in the constructor to stop the script from executing if
> the object is instantiated more than once.
I'll end up doing both. I'll do what you've mentioned to
get an error from the following code:
$s1 = new Singleton(); // Constructor sets non-member var to true
$s2 = new Singleton(); // The constructor will fail
I need disallow_copies() also though in order to get an error
from the following code:
$s1 = new Singleton(); // constructor calls disallow_copies($this)
$s2 = $s1; // With php4 I get a copy without any function call
or the following code:
function f($server) { // Bug! Should have been &$server
...
}
$s1 = new Singleton(); // constructor calls disallow_copies($this)
f($s1); // With php4 I get a copy without any function call
Finding those bugs when you have tens of thousands of lines of
php can be a real headache. That's why I'd very much like
a disallow_copies function.
Is anyone familiar with the extent of the uninitialized
struct issue I faced with the implemention I posted
yesterday?
Thanks again,
Todd