@@ -869,7 +869,7 @@ protected function createRequest($component, $destination, array $args, $mode)
869869 throw new InvalidLinkException ("Unknown signal ' $ signal', missing handler {$ reflection ->getName ()}:: $ method() " );
870870 }
871871 // convert indexed parameters to named
872- self ::argsToParams (get_class ($ component ), $ method , $ args , [], $ mode === ' test ' );
872+ self ::argsToParams (get_class ($ component ), $ method , $ args , [], $ missing );
873873 }
874874
875875 // counterpart of IStatePersistent
@@ -911,7 +911,7 @@ protected function createRequest($component, $destination, array $args, $mode)
911911 throw new InvalidLinkException ("Unable to pass parameters to action ' $ presenter: $ action', missing corresponding method. " );
912912 }
913913 } else {
914- self ::argsToParams ($ presenterClass , $ method , $ args , $ destination === 'this ' ? $ this ->params : [], $ mode === ' test ' );
914+ self ::argsToParams ($ presenterClass , $ method , $ args , $ destination === 'this ' ? $ this ->params : [], $ missing );
915915 }
916916
917917 // counterpart of IStatePersistent
@@ -936,6 +936,14 @@ protected function createRequest($component, $destination, array $args, $mode)
936936 $ args += $ globalState ;
937937 }
938938
939+ if ($ mode !== 'test ' && !empty ($ missing )) {
940+ foreach ($ missing as $ rp ) {
941+ if (!array_key_exists ($ rp ->getName (), $ args )) {
942+ throw new InvalidLinkException ("Missing parameter \${$ rp ->getName ()} required by {$ rp ->getDeclaringClass ()->getName ()}:: {$ rp ->getDeclaringFunction ()->getName ()}() " );
943+ }
944+ }
945+ }
946+
939947 // ADD ACTION & SIGNAL & FLASH
940948 if ($ action ) {
941949 $ args [self ::ACTION_KEY ] = $ action ;
@@ -995,12 +1003,12 @@ protected function createRequest($component, $destination, array $args, $mode)
9951003 * @param string method name
9961004 * @param array arguments
9971005 * @param array supplemental arguments
998- * @param bool prevents 'Missing parameter' exception
1006+ * @param ReflectionParameter[] missing arguments
9991007 * @return void
10001008 * @throws InvalidLinkException
10011009 * @internal
10021010 */
1003- public static function argsToParams ($ class , $ method , & $ args , $ supplemental = [], $ ignoreMissing = FALSE )
1011+ public static function argsToParams ($ class , $ method , & $ args , $ supplemental = [], & $ missing = [] )
10041012 {
10051013 $ i = 0 ;
10061014 $ rm = new \ReflectionMethod ($ class , $ method );
@@ -1021,10 +1029,11 @@ public static function argsToParams($class, $method, & $args, $supplemental = []
10211029 }
10221030
10231031 if (!isset ($ args [$ name ])) {
1024- if ($ param ->isDefaultValueAvailable () || $ type === 'NULL ' || $ type === 'array ' || $ ignoreMissing ) {
1025- continue ;
1032+ if (!$ param ->isDefaultValueAvailable () && $ type !== 'NULL ' && $ type !== 'array ' ) {
1033+ $ missing [] = $ param ;
1034+ unset($ args [$ name ]);
10261035 }
1027- throw new InvalidLinkException ( " Missing parameter \$ $ name required by $ class :: { $ rm -> getName ()} () " ) ;
1036+ continue ;
10281037 }
10291038
10301039 if (!ComponentReflection::convertType ($ args [$ name ], $ type , $ isClass )) {
0 commit comments