Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:72221 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 67052 invoked from network); 4 Feb 2014 22:38:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Feb 2014 22:38:17 -0000 Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.170 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.217.170 mail-lb0-f170.google.com Received: from [209.85.217.170] ([209.85.217.170:59840] helo=mail-lb0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 62/E6-13782-6DB61F25 for ; Tue, 04 Feb 2014 17:38:15 -0500 Received: by mail-lb0-f170.google.com with SMTP id u14so6989235lbd.15 for ; Tue, 04 Feb 2014 14:38:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=swq/9sRYggpvQugtYsGM/TIbXkrQVPerNnVRc5Jt7PM=; b=JkTDpsqvu/l1iGwmi7xZ/Ic2HWGfF3tJiZoadN0eeUilhvXp8a0hM08TzZ7BtIMJup d/9rkKn7hTw7LFxz43OxZEgJnLk66SinZbXxZyCIcJt6Dlk06Eipa4NOTDPim46KO7RT 4Ed0x0B4TOFyNcm2TG7R9tixEA0S1douNUkX69YhKS4G1j1kqtL0KjQwmAfDR7TyuBHp d2flL2ZjexZSuhJLtZKR9nDmqGy2IOB+J6lFERM2QNwYZmD2kPiMsgWg27GPa6SWgIBL lnVGSd8+7AJlBKC3vZKOzZI39B6B0TCNUgkmrWN3IzXKvwB3zVOvojC8SxKVG/NWh4c1 Lfkw== X-Received: by 10.152.42.196 with SMTP id q4mr3109037lal.52.1391553491773; Tue, 04 Feb 2014 14:38:11 -0800 (PST) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.112.199.37 with HTTP; Tue, 4 Feb 2014 14:37:31 -0800 (PST) In-Reply-To: References: Date: Wed, 5 Feb 2014 07:37:31 +0900 X-Google-Sender-Auth: -mXgZnEYfVTPK8fqeGo2AKcQPx0 Message-ID: To: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a11c34e8e902e4404f19c4be1 Subject: Re: Declare minimum PHP version required? From: yohgaki@ohgaki.net (Yasuo Ohgaki) --001a11c34e8e902e4404f19c4be1 Content-Type: text/plain; charset=UTF-8 Hi all, On Mon, Feb 3, 2014 at 3:58 PM, Yasuo Ohgaki 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 --001a11c34e8e902e4404f19c4be1--