Skip to content

Make args array contain an argument for every parameter of the method. #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 9, 2018

Conversation

JJK96
Copy link
Contributor

@JJK96 JJK96 commented Sep 9, 2018

Currently if the received params object does not contain a certain parameter of the function
this parameter is simply omitted in the array, resulting in a displacement of the following
arguments.

This commit fills a missing parameter in the array by the value null so that at least all
parameters are represented in the args array.

Currently if the received params object does not contain a certain parameter of the function
this parameter is simply omitted in the array, resulting in a displacement of the following
arguments.

This commit fills a missing parameter in the array by the value `null` so that at least all
parameters are represented in the args array.
@felixfbecker
Copy link
Owner

Could you add a test for this?

@codecov
Copy link

codecov bot commented Sep 9, 2018

Codecov Report

Merging #27 into master will increase coverage by 0.05%.
The diff coverage is 100%.

@@             Coverage Diff              @@
##             master      #27      +/-   ##
============================================
+ Coverage      89.6%   89.65%   +0.05%     
+ Complexity       58       57       -1     
============================================
  Files             8        8              
  Lines           125      116       -9     
============================================
- Hits            112      104       -8     
+ Misses           13       12       -1
Impacted Files Coverage Δ Complexity Δ
lib/Dispatcher.php 89.85% <100%> (+0.96%) 27 <0> (-1) ⬇️
lib/Response.php 50% <0%> (-10%) 5% <0%> (ø)
lib/ErrorResponse.php 100% <0%> (ø) 4% <0%> (ø) ⬇️
lib/Request.php 100% <0%> (ø) 4% <0%> (ø) ⬇️
lib/SuccessResponse.php 100% <0%> (ø) 4% <0%> (ø) ⬇️
lib/Notification.php 100% <0%> (ø) 4% <0%> (ø) ⬇️
lib/Error.php 100% <0%> (ø) 1% <0%> (ø) ⬇️

@JJK96
Copy link
Contributor Author

JJK96 commented Sep 9, 2018

You mean a test that shows that the current situation has problems?

This change should be covered by the current tests, specifically the DispatcherTest.php

@felixfbecker
Copy link
Owner

Yes, a test that fails on master, while it passes on this branch. This helps prevent regressions.

@JJK96
Copy link
Contributor Author

JJK96 commented Sep 9, 2018

I added a test, note that it does cheat a little bit. I originally had the assert line as follows

$this->assertEquals($this->calls, [new MethodCall('someMethodWithDifferentlyTypedArgs', ['arg2' => 0])]);

Which fails on master, but also on my fix because it passes the arguments in a different way.

I do not know how to fix this issue without changing the way that arguments are passed to the method.

Maybe you have a better idea.

@@ -50,6 +50,13 @@ public function testCallMethodWithArrayParamTag()
$this->assertEquals($this->calls, [new MethodCall('someMethodWithArrayParamTag', [[new Argument('whatever')]])]);
}

public function testCallMethodWithDifferentlyTypedArgs()
Copy link
Owner

Choose a reason for hiding this comment

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

I think a more descriptive name of this test would be testCallMethodWithMissingArgument

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adapted

@felixfbecker
Copy link
Owner

I think it is totally fine to pass null if no value was given.

@felixfbecker
Copy link
Owner

Released in 3.0.2

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.

2 participants