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

Đang mở
#798 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
8/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
php
Lĩnh vực
backend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
PHP
Star
1.7k
Fork
166
Merge trung bình
1 ngày 1 giờ
Pull request đã merge (30 ngày)
38

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của goaop/framework

Tất cả issue của goaop/framework

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.