Use partial function application in the engine source once PHP 8.6 is the minimum

未关闭
#798 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
一周以上
新手友好度
8/100
Issue 类型
重构
描述清晰度
基本清楚
活跃度
活跃
技术栈
php
领域
backend

调研方向

This is a blocked tracking issue, not a task to start: partial function application needs PHP 8.6 as the minimum version, and PHPStan and php-cs-fixer do not yet support it. The candidate sites are in src/Instrument/PathResolver.php, src/Aop/Pointcut/PointcutGrammar.php, src/Core/Container.php, src/Console/CommandLoader.php and src/Aop/Pointcut/ReturnTypePointcut.php. Done would mean the tooling supports 8.6 and the minimum version is raised, which is outside a first contribution.

由索引模型根据 Issue 内容生成。

描述

Enhancement PHP-8.6 To Be Discussed

A tracking issue for using PFA in src/. It is blocked until the minimum PHP version is ^8.6 and the tooling supports the syntax.

Blockers (checked on 8.6.0RC2)

  • PHPStan 2.3.4 crashes on any ? placeholder: "Internal error: ArgumentsHandler::matchArgParameter(): Argument #2 ($arg) must be of type PhpParser\Node\Arg, PhpParser\Node\ArgPlaceholder given".
  • php-cs-fixer 3.95 supports syntax only up to PHP 8.5.
  • composer.json requires php: ^8.4.

Candidates (cosmetic only: no runtime gain, a PFA costs the same as a closure)

Place Today With PFA
src/Instrument/PathResolver.php:47 static fn(string $path) => self::realpath($path, $shouldCheckExistence) self::realpath(?, $shouldCheckExistence)
src/Aop/Pointcut/PointcutGrammar.php:328 fn(int $group, ModifierPointcut $matcher) => self::addModifierGroup($matcher, $group) self::addModifierGroup(group: ?, matcher: ?) (named placeholders keep the written order)
src/Core/Container.php:278 fn(): object => $factory($this) $factory($this, ...) (thunk)
src/Console/CommandLoader.php:57 static fn(): Command => $instantiate($commandClass) $instantiate($commandClass, ...)
src/Aop/Pointcut/ReturnTypePointcut.php:145 fn($a, $b) => $this->atomMatches($a, $b) $this->atomMatches(...): FCC, already possible today

Must stay closures

  • src/Aop/Pointcut/PointcutGrammar.php:330: fn(int $group) => self::addModifierGroup(new ModifierPointcut(), $group). PFA evaluates its arguments when the closure is created, so every match would share one ModifierPointcut instance.
  • src/Aop/Framework/StaticTraitAliasMethodInvocation.php:75, the forward_static_call_array() shim. It is rebound with bindTo(null, $scope) to carry late static binding. A PFA closure can't be rebound to another scope ("Cannot rebind scope of closure created from function", returns null).
  • Closures that compose calls (Enumerator.php:85, :150, :200) or call a method on a varying receiver (AndPointcut/OrPointcut). 8.6 has no placeholder for the object a method is called on.

Generated code

No change proposed. Proxies already use first-class callables ($this->mOriginalAlias(...), The::aspect(X::class)->m(...)), and PFA can't express an unbound method reference (see #796).

Part of #789.

主要语言
PHP
星标
1.7k
派生
166
平均合并
1 天 1 小时
30 天内合并 PR
38

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

goaop/framework 的其他 Issue

查看 goaop/framework 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。