Re: Declare minimum PHP version required?

From: Date: Tue, 04 Feb 2014 22:37:31 +0000
Subject: Re: Declare minimum PHP version required?
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-72221@lists.php.net to get a copy of this message
Hi all, On Mon, Feb 3, 2014 at 3:58 PM, Yasuo Ohgaki <yohgaki@ohgaki.net> wrote: > I thought it might be good for us to have declaring minimum PHP version > required to execute script. > http://jp1.php.net/manual/en/control-structures.declare.php > I have concluded that these check should be done by new assert() https://wiki.php.net/rfc/expectations I think of another idea for declare(). Current declare() has 'tick'. How about have hooks 'pre_hook' and 'post_hook'? It works like tick. Tick executes registered function/code by execution cycle. 'pre_hook' and 'post_hook' executes registered function/code before function call and after function call. Something like declare(pre_hook=TYPE) { some_useful_code } declare(post_hook=TYPE) { some_useful_code } Where TYPE is 0=none, 1=user, 2=internal, 3=both. 'none' is for to use hook inside function body. These hooks are executed like function foo() { // pre_hook hook here some useful code // post_hook hook here (executed for all 'return') } This is useful for user land PHP debugger/profiler as well as pre/post condition checks. We have dbg, but it's nice to have hook in user land for simple debugging and profiling also. It may be convenient if hooked functions/methods can be specified, but it might be headache with namespace. Simply hooking all calls might be simpler as it does not have to be fast. Or declare() may be used inside functions. function foo() { declare(pre_hook=0) { some useful code } declare(post_hook=0) { some useful code } body } There are many way for hook design. Just an another idea for declare(). It would be useful, but it lacks elegance... Since declare() is compiler directive, INI is needed for enabling/disabling when user want hook for all files. Any comments for this feature? Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net

« previous php.internals (#72221) next »