-
-
Notifications
You must be signed in to change notification settings - Fork 48
Milestone
Description
Describe the Proposal
Currently there is no easy way to apply simple php functions or static methods on a cell.
This means that every time we want to add a transformation that would require a custom logic, new scalar functions is required.
For simple scenarios where we just want to use a native php function or even a static method a ScalarFunction that would use call_user_func under the hood should be enough.
API Adjustments
This is the tricky part, I don't yet know what would be the best API for CallUserFunction scalar function.
We need to support at least this:
ref('array')->call('count')
ref('array')->call('\My\Namespace\Functions\count')
ref('array')->call('\My\Namespace\Class::count')But we should also allow for:
- passing additional arguments
- passing a value from a row under different name. For example when columns is called
arraybut the function expects$collectionthere should be a way to tell CallScalarFunction to pass value ofarrayentry as acollectionlike for example `...[$refAlias => (new Parameter($this->ref))->eval()
So probably something like:
ref('collection')->call(
callable: 'implode', // accepts a callable
arguments: ['separator' => ','], // default []
refAlias: 'array', // default null
returnType => type_string() // default null
)Are you intenting to also work on proposed change?
Yes
Are you interested in sponsoring this change?
None
Integration & Dependencies
No response
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Done