Re: [apd][patch] Two new functions: override_constant() and rename_constant()
| From: | DvDmanDT | Date: | Mon, 13 Sep 2004 21:58:57 +0000 |
| Subject: | Re: [apd][patch] Two new functions: override_constant() and rename_constant() | ||
| References: | 1 | Groups: | php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-1332@lists.php.net to get a copy of this message | ||
I like the idea of being able to do these things _while debugging_.. I love
constants due to the fact that they exist in all scopes, and I use them
pretty much in my scripts.. For example I use them for storing the user id
of the logged in user at one place, and it's 0 if noone is logged in.. I
display different things depending on wether that constant is 0 or not..
While debugging sometimes I might need to show one thing and not the other
one.. At the moment I do this: if(1||CONSTANT) or id(0&&CONSTANT) to
override these if's, and replace all occurences inside that block.. Would've
been much easier to debug these problems I have by just changing the value
over 30 lines..
--
// DvDmanDT
MSN: dvdmandt¤hotmail.com
Mail: dvdmandt¤telia.com
"Johannes Schlueter" <johannes@php.net> skrev i meddelandet
news:200409120137.28637@schlueters.de...
> Hi George,
>
> while trying to understand an application I got a bit frustrated that I
can
> rename functions using apd and change classes using classkit but that I
can't
> change constants. So I wrote a small patch for apd adding two small
functions
> which can change constants.
>
> The protos are quite similar to override_function and rename_function:
>
> /* {{{ proto bool override_consant(string name, mixed value)
> overrides the content of the constant name with value */
>
> /* {{{ proto bool rename_constant(string oldname, string newname)
> renames the constant oldname to newname */
>
> A small example looks like
>
> <?php
> define('FOO', 'asdf');
>
> rename_constant('FOO', 'BAR');
> override_constant('BAR', 'qwerty');
>
> echo BAR;
> ?>
>
> This echos "qwerty".
>
> Maybe you like the idea and maybe even (parts of) the implementation it.
;-)
>
> johannes
>