Skip to content

Conversation

@stloyd
Copy link
Member

@stloyd stloyd commented Nov 16, 2025

Resolves: #2014

Change Log


Added

Fixed

Changed

  • Enforcing string types for argument names `call()` scalar method

Removed

Deprecated

Security

@codecov
Copy link

codecov bot commented Nov 16, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.39%. Comparing base (1459485) to head (67fd55c).
⚠️ Report is 1 commits behind head on 1.x.

Additional details and impacted files
@@            Coverage Diff             @@
##              1.x    #2015      +/-   ##
==========================================
+ Coverage   78.94%   79.39%   +0.44%     
==========================================
  Files         846      846              
  Lines       25235    25244       +9     
==========================================
+ Hits        19923    20043     +120     
+ Misses       5312     5201     -111     
Components Coverage Δ
etl 88.53% <100.00%> (+1.11%) ⬆️
cli 85.96% <ø> (ø)
lib-array-dot 95.00% <ø> (ø)
lib-azure-sdk 60.39% <ø> (ø)
lib-doctrine-dbal-bulk 95.14% <ø> (ø)
lib-filesystem 80.68% <ø> (ø)
lib-types 89.49% <ø> (+1.75%) ⬆️
lib-parquet 68.35% <ø> (ø)
lib-parquet-viewer 83.04% <ø> (ø)
lib-snappy 90.18% <ø> (+0.46%) ⬆️
bridge-filesystem-async-aws 91.00% <ø> (ø)
bridge-filesystem-azure 89.47% <ø> (ø)
bridge-monolog-http 96.91% <ø> (ø)
bridge-openapi-specification 94.55% <ø> (ø)
symfony-http-foundation 73.17% <ø> (ø)
adapter-chartjs 86.36% <ø> (ø)
adapter-csv 89.08% <ø> (ø)
adapter-doctrine 90.97% <ø> (ø)
adapter-elasticsearch 97.17% <ø> (ø)
adapter-google-sheet 91.40% <ø> (ø)
adapter-http 67.36% <ø> (ø)
adapter-json 89.80% <ø> (ø)
adapter-logger 83.33% <ø> (ø)
adapter-meilisearch 97.87% <ø> (ø)
adapter-parquet 78.30% <ø> (ø)
adapter-text 88.09% <ø> (ø)
adapter-xml 83.07% <ø> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

* @param null|Type<mixed> $returnType
*/
public function call(ScalarFunction|callable $callable, array $arguments = [], string|int $refAlias = 0, ?Type $returnType = null) : CallUserFunc
public function call(ScalarFunction|callable $callable, string $refAlias, array $arguments = [], ?Type $returnType = null) : CallUserFunc
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how much I like that change.
When refAlias is required string you need to always provide argument name to call even if function has just one parameter.

For example ref('array')->call('count') needs to now become ref('array')->call('count', refAlias: 'value')

I just checked and in one project I have around 150 calls like this that I will need to manually one by one adjust (and sine those are different functions I would need to learn their argument names as well).
I need a really strong argument too approve that.

Instead I would rather prefer to check if refAlias was passed as string|integer, then check if how arguments are passed and throw an exception if one us using integer indexes and other is string, or other way around.

Copy link
Member Author

@stloyd stloyd Nov 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After writing more tests, I had a similar feeling that enforcing will always be problematic, and I did the change on it, I think the same way as you pointed out in the comment ;)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, which calls do you have more of? So we can extend the tests to see what I missed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original intention of allowing for int was to be able to pass arguments by name or position.

So for example:

  • ['param_name_1' => 'param_value_1', 'param_name_2' => 'param_value_2']
  • ['param_value_1', 'param_value_2']

And ideally I would like to keep it this way.

However to be able to use it with positional parameter you need to do something lke this:

call(ref('column'), ['param_1, null, 'param_2'], refALias: 1]) 

So array merge would replace [1 => null] with [1 => ref('column')->eval()]

(this wasn't properly documented)

@stloyd stloyd changed the title Change of argument order in call() scalar method Enforcing string types for argument names call() scalar method Nov 16, 2025
@stloyd stloyd closed this Nov 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: call() can lead to PHP fatal error when arguments are mixed

2 participants