File tree Expand file tree Collapse file tree 1 file changed +15
-6
lines changed Expand file tree Collapse file tree 1 file changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -39,13 +39,22 @@ public function __construct(Reader $reader)
3939 */
4040 protected function fetchMethodArguments (MethodInvocation $ invocation )
4141 {
42- $ parameters = $ invocation ->getMethod ()->getParameters ();
43- $ argumentNames = array_map (function (\ReflectionParameter $ parameter ) {
44- return $ parameter ->name ;
45- }, $ parameters );
46- $ parameters = array_combine ($ argumentNames , $ invocation ->getArguments ());
42+ $ result = [];
43+ $ parameters = $ invocation ->getMethod ()->getParameters ();
44+ $ argumentValues = $ invocation ->getArguments ();
4745
48- return $ parameters ;
46+ // Number of arguments can be less than number of parameters because of default values
47+ foreach ($ parameters as $ parameterIndex => $ reflectionParameter ) {
48+ $ hasArgumentValue = array_key_exists ($ parameterIndex , $ argumentValues );
49+ $ argumentValue = $ hasArgumentValue ? $ argumentValues [$ parameterIndex ] : null ;
50+ if (!$ hasArgumentValue && $ reflectionParameter ->isDefaultValueAvailable ()) {
51+ $ argumentValue = $ reflectionParameter ->getDefaultValue ();
52+ }
53+ $ result [$ reflectionParameter ->name ] = $ argumentValue ;
54+
55+ }
56+
57+ return $ result ;
4958 }
5059
5160 /**
You can’t perform that action at this time.
0 commit comments