@@ -103,26 +103,22 @@ protected function validateParent(Nette\ComponentModel\IContainer $parent): void
103103 protected function tryCall (string $ method , array $ params ): bool
104104 {
105105 $ rc = $ this ->getReflection ();
106- if ($ rc ->hasMethod ($ method )) {
107- $ rm = $ rc ->getMethod ($ method );
108- if ($ rm ->isPrivate ()) {
109- throw new Nette \InvalidStateException ('Method ' . $ rm ->getName () . '() can not be called because it is private. ' );
110- }
111-
112- if (!$ rm ->isAbstract () && !$ rm ->isStatic ()) {
113- $ this ->checkRequirements ($ rm );
114- try {
115- $ args = $ rc ->combineArgs ($ rm , $ params );
116- } catch (Nette \InvalidArgumentException $ e ) {
117- throw new Nette \Application \BadRequestException ($ e ->getMessage ());
118- }
106+ if (!$ rc ->hasMethod ($ method )) {
107+ return false ;
108+ } elseif (!$ rc ->hasCallableMethod ($ method )) {
109+ throw new Nette \InvalidStateException ('Method ' . Nette \Utils \Reflection::toString ($ rc ->getMethod ($ method )) . ' is not callable. ' );
110+ }
119111
120- $ rm ->invokeArgs ($ this , $ args );
121- return true ;
122- }
112+ $ rm = $ rc ->getMethod ($ method );
113+ $ this ->checkRequirements ($ rm );
114+ try {
115+ $ args = $ rc ->combineArgs ($ rm , $ params );
116+ } catch (Nette \InvalidArgumentException $ e ) {
117+ throw new Nette \Application \BadRequestException ($ e ->getMessage ());
123118 }
124119
125- return false ;
120+ $ rm ->invokeArgs ($ this , $ args );
121+ return true ;
126122 }
127123
128124
0 commit comments