Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82958 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 9298 invoked from network); 17 Feb 2015 13:35:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Feb 2015 13:35:38 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.51 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.51 mail-wg0-f51.google.com Received: from [74.125.82.51] ([74.125.82.51:58117] helo=mail-wg0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 94/44-19463-9A343E45 for ; Tue, 17 Feb 2015 08:35:38 -0500 Received: by mail-wg0-f51.google.com with SMTP id y19so35473514wgg.10 for ; Tue, 17 Feb 2015 05:35:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=BPIWsrZlg2imjACdUl+t56Y13ACST17dDyqm7LHnWPQ=; b=an8bq3naxHmVVNsPdrbdgXotQu6scnlKOGGq4vImJ+f0Kiu4gfCPLCVNzNJv/Pafc9 9w1SEsEh2omassJT88FCBDwuWPGVv2mtDX9pMd9fWULnHty423C6qblnuaDmcB5SWe+M R/5JqyNu+tljMeodSI9k1l0GTKQFBb85fhLOokSdeOq3WdejmaTVC3AiaW9ZM7q2g7Br MtPFvSZQNLmAD4ObjXGFQkKgNC2yWj4sc0m3rRcHHVYFf9jTRjnG4zLHIfPh3V1tNgbK 0gldIPYqjXuyJ7fBF4/PNyTKmMoM872JBlLE9Ls/td2JluhEkBuyxRDChAtYqcFe4IQN 011g== X-Received: by 10.180.19.9 with SMTP id a9mr25536051wie.85.1424180135163; Tue, 17 Feb 2015 05:35:35 -0800 (PST) Received: from [192.168.0.172] ([62.189.198.114]) by mx.google.com with ESMTPSA id ga8sm11196503wib.6.2015.02.17.05.35.33 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Feb 2015 05:35:33 -0800 (PST) Message-ID: <54E3439D.30407@gmail.com> Date: Tue, 17 Feb 2015 13:35:25 +0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: internals@lists.php.net References: In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC][Discussion] Parser extension API From: rowan.collins@gmail.com (Rowan Collins) Alexander Lisachenko wrote on 17/02/2015 12:41: > 2015-02-17 15:29 GMT+03:00 Benjamin Eberlei : > >> Well not really, depending on the path towards a require a parser >> extension is already registered or not. Or you have conditional >> registration of extensions. So you could load a file with an extension >> registered, but it still serves the old opcodes for that file. > > > Technically, this will be possible, however, Parser Extensions should be > registered ASAP during bootstrap process, near spl_autoload_register(), > stream_wrapper_register(), stream_filter_register(), etc.. I think "should" is OK for extensions, but not for userland hooks. There needs to be a very firm definition of the right and wrong way to implement these hooks, which can at the very least warn the user when they are slipping into undefined behaviour. Note that spl_autoload_register doesn't affect OpCache because it only changes the mapping of a class to a parsed file (keyed on the file system path to the source), not the compiled contents of that file. If AST hooks can be registered on a global scope at any time, then compiling the same file can lead to different op codes at different times (e.g. page loads which take a different path through the code), which would mean the OpCache would need extra information in its keys to cache each possible version. > One more possible way for this RFC is to remove these register/unregister > methods from the `Php\Parser\Engine` class and add an option to the php.ini > with list of classes to load. This option can be adjusted then per > project/directory. Is this more suitable? The other alternative is to go to the other extreme, and have the extensions scoped to a particular file, more like Perl pragmas. Dare I say we could use the declare() syntax that everyone seems to have an irrational hatred of? declare(pragma=Example\DbcParserExtension); Regards, -- Rowan Collins [IMSoP]