Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » PHP
  • » [PHP-DEV] Overriding Default Functions [RSS Feed]

#1 Nov. 15, 2005 23:54:36

Alan C.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] Overriding Default Functions


Hello -
Is there a way to build an extension that overrides the default
behavior of a built-in PHP function? Would it be possible to add an
extension that removes a PHP function, so that I could redefine it in my
PHP code?

What I want to do is override the time calculations. We are running
unit tests on a testing server that are dependent on time. For
instance, there is one behavior before the 15th of the month and another
one on or after the 15th. I'm not able to change the system time, since
this testing server is used by a lot of people. What I'd like to be
able to do is load a module in the unit test that makes it so that a
custom time() function is used. This time() function wouldn't look at
the system clock for the time.

Thanks for your help.
Alan

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#2 Nov. 16, 2005 00:08:18

Wez F.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] Overriding Default Functions


I think runkit is what you're looking for.http://pecl.php.net/packages/runkit--Wez.

On 11/15/05, Alan Cox <> wrote:
> Hello -
> Is there a way to build an extension that overrides the default
> behavior of a built-in PHP function? Would it be possible to add an
> extension that removes a PHP function, so that I could redefine it in my
> PHP code?
>
> What I want to do is override the time calculations. We are running
> unit tests on a testing server that are dependent on time. For
> instance, there is one behavior before the 15th of the month and another
> one on or after the 15th. I'm not able to change the system time, since
> this testing server is used by a lot of people. What I'd like to be
> able to do is load a module in the unit test that makes it so that a
> custom time() function is used. This time() function wouldn't look at
> the system clock for the time.
>
> Thanks for your help.
> Alan
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit:http://www.php.net/unsub.php>
>

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#3 Nov. 16, 2005 01:38:39

Sara G.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] Overriding Default Functions


Specifically, you want to enable the (under-documented)
runkit.internal_override INI option. It's mentioned on the reference page,
but with no explanation of what it does. I need to make a language-snippet
for that at some point....

This was added in version 0.6 (prior versions could only override
user-defined functions/methods). If you enable this option (PHP_INI_SYSTEM
only) you can use runkit_function_redefine() to replace the builtin time()
with something else.

-Sara

----- Original Message -----
From: "Wez Furlong" <>
Newsgroups: php.internals
To: <>
Cc: <intern***@*ists.php.net>
Sent: Tuesday, November 15, 2005 4:07 PM
Subject: Re: Overriding Default Functions


I think runkit is what you're looking for.http://pecl.php.net/packages/runkit--Wez.

On 11/15/05, Alan Cox <> wrote:
> Hello -
> Is there a way to build an extension that overrides the default
> behavior of a built-in PHP function? Would it be possible to add an
> extension that removes a PHP function, so that I could redefine it in my
> PHP code?
>
> What I want to do is override the time calculations. We are running
> unit tests on a testing server that are dependent on time. For
> instance, there is one behavior before the 15th of the month and another
> one on or after the 15th. I'm not able to change the system time, since
> this testing server is used by a lot of people. What I'd like to be
> able to do is load a module in the unit test that makes it so that a
> custom time() function is used. This time() function wouldn't look at
> the system clock for the time.
>
> Thanks for your help.
> Alan
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit:http://www.php.net/unsub.php>
>

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

  • Root
  • » PHP
  • » [PHP-DEV] Overriding Default Functions [RSS Feed]

Board footer

Moderator control

Enjoy the 18th of November
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support