@@ -873,9 +873,8 @@ protected function createRequest($component, $destination, array $args, $mode)
873873 if (!$ reflection ->hasCallableMethod ($ method )) {
874874 throw new InvalidLinkException ("Unknown signal ' $ signal', missing handler {$ reflection ->getName ()}:: $ method() " );
875875 }
876- if ($ args ) { // convert indexed parameters to named
877- self ::argsToParams (get_class ($ component ), $ method , $ args );
878- }
876+ // convert indexed parameters to named
877+ self ::argsToParams (get_class ($ component ), $ method , $ args );
879878 }
880879
881880 // counterpart of IStatePersistent
@@ -901,28 +900,27 @@ protected function createRequest($component, $destination, array $args, $mode)
901900 $ current = ($ action === '* ' || strcasecmp ($ action , $ this ->action ) === 0 ) && $ presenterClass === get_class ($ this );
902901
903902 $ reflection = new PresenterComponentReflection ($ presenterClass );
904- if ($ args || $ destination === 'this ' ) {
905- // counterpart of run() & tryCall()
906- $ method = $ presenterClass ::formatActionMethod ($ action );
903+
904+ // counterpart of run() & tryCall()
905+ $ method = $ presenterClass ::formatActionMethod ($ action );
906+ if (!$ reflection ->hasCallableMethod ($ method )) {
907+ $ method = $ presenterClass ::formatRenderMethod ($ action );
907908 if (!$ reflection ->hasCallableMethod ($ method )) {
908- $ method = $ presenterClass ::formatRenderMethod ($ action );
909- if (!$ reflection ->hasCallableMethod ($ method )) {
910- $ method = NULL ;
911- }
909+ $ method = NULL ;
912910 }
911+ }
913912
914- // convert indexed parameters to named
915- if ($ method === NULL ) {
916- if (array_key_exists (0 , $ args )) {
917- throw new InvalidLinkException ("Unable to pass parameters to action ' $ presenter: $ action', missing corresponding method. " );
918- }
913+ // convert indexed parameters to named
914+ if ($ method === NULL ) {
915+ if (array_key_exists (0 , $ args )) {
916+ throw new InvalidLinkException ("Unable to pass parameters to action ' $ presenter: $ action', missing corresponding method. " );
917+ }
919918
920- } elseif ($ destination === 'this ' ) {
921- self ::argsToParams ($ presenterClass , $ method , $ args , $ this ->params );
919+ } elseif ($ destination === 'this ' ) {
920+ self ::argsToParams ($ presenterClass , $ method , $ args , $ this ->params );
922921
923- } else {
924- self ::argsToParams ($ presenterClass , $ method , $ args );
925- }
922+ } else {
923+ self ::argsToParams ($ presenterClass , $ method , $ args );
926924 }
927925
928926 // counterpart of IStatePersistent
@@ -1015,7 +1013,9 @@ public static function argsToParams($class, $method, & $args, $supplemental = []
10151013 $ i = 0 ;
10161014 $ rm = new \ReflectionMethod ($ class , $ method );
10171015 foreach ($ rm ->getParameters () as $ param ) {
1016+ list ($ type , $ isClass ) = PresenterComponentReflection::getParameterType ($ param );
10181017 $ name = $ param ->getName ();
1018+
10191019 if (array_key_exists ($ i , $ args )) {
10201020 $ args [$ name ] = $ args [$ i ];
10211021 unset($ args [$ i ]);
@@ -1026,16 +1026,15 @@ public static function argsToParams($class, $method, & $args, $supplemental = []
10261026
10271027 } elseif (array_key_exists ($ name , $ supplemental )) {
10281028 $ args [$ name ] = $ supplemental [$ name ];
1029-
1030- } else {
1031- continue ;
10321029 }
10331030
1034- if ($ args [$ name ] === NULL ) {
1035- continue ;
1031+ if (!isset ($ args [$ name ])) {
1032+ if ($ param ->isDefaultValueAvailable () || $ type === 'NULL ' || $ type === 'array ' || $ isClass ) {
1033+ continue ;
1034+ }
1035+ throw new InvalidLinkException ("Missing parameter \$$ name required by $ class:: {$ rm ->getName ()}() " );
10361036 }
10371037
1038- list ($ type , $ isClass ) = PresenterComponentReflection::getParameterType ($ param );
10391038 if (!PresenterComponentReflection::convertType ($ args [$ name ], $ type , $ isClass )) {
10401039 throw new InvalidLinkException (sprintf (
10411040 'Argument $%s passed to %s() must be %s, %s given. ' ,
@@ -1046,22 +1045,14 @@ public static function argsToParams($class, $method, & $args, $supplemental = []
10461045 ));
10471046 }
10481047
1049- if ($ param ->isDefaultValueAvailable ()) {
1050- $ def = $ param ->getDefaultValue ();
1051- } else {
1052- $ def = NULL ;
1053- if (!$ isClass ) {
1054- settype ($ def , $ type );
1055- }
1056- }
1048+ $ def = $ param ->isDefaultValueAvailable () ? $ param ->getDefaultValue () : NULL ;
10571049 if ($ args [$ name ] === $ def || ($ def === NULL && $ args [$ name ] === '' )) {
10581050 $ args [$ name ] = NULL ; // value transmit is unnecessary
10591051 }
10601052 }
10611053
10621054 if (array_key_exists ($ i , $ args )) {
1063- $ method = $ rm ->getName ();
1064- throw new InvalidLinkException ("Passed more parameters than method $ class:: $ method() expects. " );
1055+ throw new InvalidLinkException ("Passed more parameters than method $ class:: {$ rm ->getName ()}() expects. " );
10651056 }
10661057 }
10671058
0 commit comments