Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:131028 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id DE4001A00BC for ; Wed, 27 May 2026 14:28:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1779892092; bh=NAmMAshtrbyWpGm1BgEtPyIHf2M5ldNYvXZjlasDGl4=; h=From:Subject:Date:References:To:In-Reply-To:From; b=Zs5d+spv5CN4+ILwY04ZHMUHA6L1ZwGHVBCb/niT0vtcYpxIqViizUA9X0CoYnR+x 4x65NhCK2LcmNftw/ifd23wGQ5qiemVdqQ46IGsTCxSekADjF7ihqxAWZ3O/9fqhTb VUI5hmhw+mJ5jZtd42RcqtzIqoRCCv/pK8cEKjBaP61CvW1AjqluJC7XjE6y80TPpb k8T1ELSq65dXEy5qPzv/GiILB5F3tuZPZnlTMpXFvw+WXWp4qL051/UDb4iJHvNzyQ 4HTZEV7u5wODTvIlD44dL+ptSkMxMAgBwKINgInReVyHYL/GqXMZXfHAuye4BltQv0 HEcMfu6xQ+JCw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 46B55180056 for ; Wed, 27 May 2026 14:28:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.9 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 27 May 2026 14:28:11 +0000 (UTC) Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-48d146705b4so125047675e9.3 for ; Wed, 27 May 2026 07:28:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779892085; x=1780496885; darn=lists.php.net; h=message-id:in-reply-to:to:references:date:subject:mime-version :content-transfer-encoding:from:from:to:cc:subject:date:message-id :reply-to; bh=9Q31YL1sFH28l/ORrtlYlGBBFYQFFE/XILOHNmHabj8=; b=XwyYBjn5gY/CQZZcDeSH/1kbk2lj5uS5DvPpmP9TB1O4cw7L7TsKSPyH/QeIgK4Xxn /W5dXlo+wtXjF6iB5Qk6uiIfxYhNE8FVLBGyZFoBGO3D2vFb7ranYSYTSaTu3Cr6RmBj lDEmbTI+adPCsOHwoBj59nGqjprrdaf8QvjHn38LsBYEMlpdqdh9gOJiH7YYT3A5kipV 2z6tToLR0XULgeBF372VSVsEr8fNU/c+ESpgyvfOzr5UQGtaf3cTSOFRSQW45uJuFuo/ ID04kLAfmVcJ9gqYHDos5cXtRNqNtO9HXfIo3naNu8tRp+O/4ircQpu8O9HQ+9E+WKje fOhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779892085; x=1780496885; h=message-id:in-reply-to:to:references:date:subject:mime-version :content-transfer-encoding:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=9Q31YL1sFH28l/ORrtlYlGBBFYQFFE/XILOHNmHabj8=; b=cZlHvKwz81ddi7Ij7SX9yNmGGkS/yxtCIni3C2uOpafndAK8NFbzI6ZMNdwnBsyCNZ 45uDdcx1/8qucCc778So2e3P5E3nZcKWA64BagwjKvVdnqdxr1mjp9f8HVcB1DvESPsd tWPpjfSXmIPbz0bgJpzY1F/8xI4t5v/G/guuSinuzYT6Vj1TP4gUTXRAb9C3UZt3eNbE qrzz/BRZMN6hPAfyZL5nQb2QvQS/eNt8hM07JTGYhRn30uK/W8335h4Vu2LXEUDIWuuh HYmoJcQmXFPEUYUpBgdzcUS/igYoYiSdSL76cnAzzzV5B+F3PCvkN32hQ2nVlovbqTDa kLyg== X-Gm-Message-State: AOJu0YyBe2DGSnrvNPNFfHH9CH4i/tHr+434SSfSCBRIohuZTLaYIkAv pgHmcv+QHu/kMuXoGilORHsSny5rpZcEi+ZDV0JjeT8iordy5qo29L2q3qGbinia X-Gm-Gg: Acq92OGsohP40/CNHJ9eDFYhUtqlomW5fcgFtJaXfEgnvDXZlsz0Xj1DYrPC3Zy2bkb ZHFhDoLrjz7JEusBZX4QBiYaKvAExkRLpDzvkmTgVtuyu5h04UImVLPh12nvHIgpvejQCiFucwp UD0kLHUwBoYVA2/X4/6rkoIYpo8RSdFK4/nsV/J5BW0xYKX0YxKuaF98NOkUBc6ZxKKCh/teKrT w4BkfBielqfwKnH401LAVEonICN8MEqTabtmiG5blZi+XKWOJSxVJtUIDNFN70UtIZOJbyKxUIj Raww6GmJVfD1x6+lKTcb/GgKB7aIAQDclDOhrQ/3Szqp5IVzuszVzUjCrWOQgvDGga6E/G6JZ+b U0fPuj9IGObef7RN8SJfWNlcFjL0XS0M0pRIz6GpQTE7v/KF7psWorR18aLI7ekA+ftlcIppDSY vd+qK0/AuZJ5IQMceb8+F+bZiMetQKDTNSRSKmAgK+H11INurznIhwJ5k2QHMfG/+gnnyvuvSDY 4K5bEJKrV+8CV8xKTy4TqDT X-Received: by 2002:a05:600c:818e:b0:490:58f4:ba23 with SMTP id 5b1f17b1804b1-4905c60ef29mr250989705e9.30.1779892084444; Wed, 27 May 2026 07:28:04 -0700 (PDT) Received: from smtpclient.apple (p508ccfb8.dip0.t-ipconnect.de. [80.140.207.184]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490809cf24csm25292175e9.6.2026.05.27.07.28.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 May 2026 07:28:03 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.600.51.1.1\)) Subject: Re: [PHP-DEV] [Pre-RFC] Pure-code source files via .phpc extension Date: Wed, 27 May 2026 16:27:52 +0200 References: <9E95EA03-B86A-D248-A980-B1E838F94C13@hxcore.ol> <20260527131921.086BB1A00BD@lists.php.net> To: internals@lists.php.net In-Reply-To: <20260527131921.086BB1A00BD@lists.php.net> Message-ID: <8AE9A269-2E40-42F0-A0F8-C6690B2935FE@gmail.com> X-Mailer: Apple Mail (2.3864.600.51.1.1) From: hmennen90@gmail.com (Hendrik Mennen) > Am 27.05.2026 um 15:19 schrieb Ben Ramsey : >=20 > On 5/27/26 07:12, hmennen90@gmail.com wrote: >> Hi internals, >> I intend to submit an RFC introducing a new file extension for = pure-code PHP >> source files (no leading > before drafting. >> Proposal in brief: >> Files ending in .phpc would be parsed starting in ST_IN_SCRIPTING = state. No > php or ?> tags permitted inside such files. Existing .php files and = their >> semantics are completely unchanged. This is purely additive and = BC-clean. >> Motivation: >> PHP's mixed-mode default reflects its 1995 templating origins. Since = PHP 7+, the >> language has evolved into a credible general-purpose tool: strict = types, enums, >> readonly classes, property hooks, JIT compilation. I personally = maintain >> PHPolygon, a CPU-bound 3D engine written in PHP =E2=80=93 a use case = where the >> templating heritage is pure ceremony. Other modern uses (CLI tooling, = queue >> workers, code generators) share this pattern. A dedicated pure-code = file format >> would be a small but meaningful acknowledgment that PHP-as-language = is now a >> first-class use case alongside PHP-as-template. >> Prior art and what's different: >> I have read both rfc/source_files_without_opening_tag (Boutell, 2012, = abandoned >> by author) and rfc/nophptags (Ohgaki, 2014, inactive). My proposal = deliberately >> avoids what I believe were the two design choices that killed them: >> - No new include syntax (Boutell's AS keyword). Extension-based = detection only. >> - No php.ini-based mode switch (Ohgaki's template_mode). No global = config side >> effects. >> - No security framing. The mode-switch overhead is parse-time only = and OPcache/ >> JIT eliminate it in practice; this proposal is about conceptual = clarity and >> tooling, not performance or LFI mitigation. >> Implementation: >> I will write and maintain the implementation patch. Initial scope: = extension >> registration in zend_compile_file, lexer state initialization, = OPcache >> awareness, CLI support, and rejection of tokens inside .phpc = files. I >> will also coordinate with Composer maintainers ahead of RFC = submission to >> confirm autoload support. >> Open questions for the list: >> 1. Is the .phpc extension acceptable as the disambiguator, or is = there appetite >> for something else (e.g. shebang line, declare directive =E2=80=93 = both of which I think >> are worse, but I'd hear the case)? >> 2. Should #! shebang lines and UTF-8 BOM be permitted before the = implicit >> scripting state begins? My intent is yes for both. >> 3. Should __halt_compiler() retain its current behavior in .phpc = files? My >> intent is yes. >> I welcome substantive critique. If the concept itself is unwanted, I = would >> rather know now than discover it during a vote. >> Thanks. >> Hendrik Mennen >> Maintainer, PHPolygon >=20 >=20 > The problem with assigning meaning to a file extension is that the = interpreter (currently) doesn't care what the file extension is. As long = as it's text, it'll process any file and execute what comes after any = =20 > What you want is something like this: >=20 > php -r "$(cat foo.phpc)" >=20 > Of course, this only works for a single file, and the engine won't = execute code in any included files unless they contain PHP open tags, so = the file needs a way to tell the engine to parse and execute it as PHP = source. >=20 > At the risk of bike-shedding, I think it could be easy for others to = confuse .phpc files as byte-code files, since it's common to see Python = byte-code files with the .pyc extension. Also, a lot of folks in the = community use "phpc" as a shorthand and tag to mean "PHP community," = though I'm not sure this is reason enough not to use the .phpc = extension. I don't have any better alternative recommendations at this = time, though. >=20 > Cheers, > Ben One more Try for readability: Hi Ben, Thanks for the quick response. > The problem with assigning meaning to a file extension is that the > interpreter (currently) doesn't care what the file extension is. As = long > as it's text, it'll process any file and execute what comes after any > At the risk of bike-shedding, I think it could be easy for others to > confuse .phpc files as byte-code files, since it's common to see = Python > byte-code files with the .pyc extension. Fair point, and one I had not weighed heavily enough. The Python .pyc = parallel is real and would cause exactly the kind of one-time confusion = that adds friction to adoption. Boutell's 2012 RFC used .phpp (Pure PHP) = for the same purpose, which avoids the bytecode association. I am open = to .phpp or other suggestions; the disambiguator matters less than the = mechanism. > Also, a lot of folks in the community use "phpc" as a shorthand and = tag > to mean "PHP community," though I'm not sure this is reason enough not > to use the .phpc extension. Noted. Less critical than the .pyc concern in my view, but it does = reinforce that .phpc is not the obviously-best choice. I will list = candidate extensions in the RFC and explicitly invite the list to pick = one rather than defending a specific letter. Thanks again for the substantive feedback. Hendrik Mennen Maintainer, PHPolygon=