Skip to content

Give a computed field an argument for each parameter of its method - #313

Merged
TomHAnderson merged 1 commit into
API-Skeletons:14.0.xfrom
TomHAnderson:feature/computed-field-arguments
Oct 3, 2026
Merged

TomHAnderson merged 1 commit into
API-Skeletons:14.0.xfrom
TomHAnderson:feature/computed-field-arguments

Conversation

@TomHAnderson

Copy link
Copy Markdown
Member
#[ComputedField(type: 'int')]
public function getTotalRecordings(int|null $year = null): int

is queried as totalRecordings or totalRecordings(year: 2002).

An int, float, string or bool parameter is an Int, Float, String or Boolean argument; the attribute's new args give the registered type of any other parameter. A parameter which does not allow null is a non-null argument, and its default value is the argument's. A variadic or by-reference parameter, a parameter of another type without one in args, a default which is not scalar, and args naming no parameter are errors when the metadata is built; an argument whose type cannot be input is one when the type is built.

The method is called with the arguments by name. The values of a field with arguments are cached per set of them, so aliases with different arguments each have their own, and the hydrator's extract() leaves such a field out.

The metadata format version is 3, as computed fields have an args key.

    #[ComputedField(type: 'int')]
    public function getTotalRecordings(int|null $year = null): int

is queried as totalRecordings or totalRecordings(year: 2002).

An int, float, string or bool parameter is an Int, Float, String or
Boolean argument; the attribute's new args give the registered type of
any other parameter.  A parameter which does not allow null is a
non-null argument, and its default value is the argument's.  A variadic
or by-reference parameter, a parameter of another type without one in
args, a default which is not scalar, and args naming no parameter are
errors when the metadata is built; an argument whose type cannot be
input is one when the type is built.

The method is called with the arguments by name.  The values of a field
with arguments are cached per set of them, so aliases with different
arguments each have their own, and the hydrator's extract() leaves such
a field out.

The metadata format version is 3, as computed fields have an args key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (eef9bcf) to head (d0d61f0).
⚠️ Report is 1 commits behind head on 14.0.x.

Additional details and impacted files
@@             Coverage Diff              @@
##              14.0.x      #313    +/-   ##
============================================
  Coverage     100.00%   100.00%            
- Complexity      1147      1191    +44     
============================================
  Files             79        80     +1     
  Lines           3100      3213   +113     
============================================
+ Hits            3100      3213   +113     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TomHAnderson
TomHAnderson merged commit a182233 into API-Skeletons:14.0.x Oct 3, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant