Registers a new static method for the given method name and closure on this MetaClass

@param name     The method name
@param callable The callable Closure
188011
protected void registerStaticMethod(final String name, final Closure callable, final Class[] paramTypes) {
        performOperationOnMetaClass(new Callable() {
            public void call() {
                String methodName;
                if (name.equals(METHOD_MISSING))
                    methodName = STATIC_METHOD_MISSING;
                else if (name.equals(PROPERTY_MISSING))
                    methodName = STATIC_PROPERTY_MISSING;
                else
                    methodName = name;

                ClosureStaticMetaMethod metaMethod = null;

                if (paramTypes != null) {
                    metaMethod = new ClosureStaticMetaMethod(methodName, theClass, callable, paramTypes);
                } else {
                    metaMethod = new ClosureStaticMetaMethod(methodName, theClass, callable);
                }

                if (methodName.equals(INVOKE_METHOD_METHOD) && callable.getParameterTypes().length == 2) {
                    invokeStaticMethodMethod = metaMethod;
                } else {
                    if (methodName.equals(METHOD_MISSING)) {
                        methodName = STATIC_METHOD_MISSING;
                    }
                    MethodKey key = new DefaultCachedMethodKey(theClass, methodName, metaMethod.getParameterTypes(), false);

                    addMetaMethod(metaMethod);
                    dropStaticMethodCache(methodName);
//                    cacheStaticMethod(key,metaMethod);

                    if (isGetter(methodName, metaMethod.getParameterTypes())) {
                        String propertyName = getPropertyForGetter(methodName);
                        registerBeanPropertyForMethod(metaMethod, propertyName, true, true);

                    } else if (isSetter(methodName, metaMethod.getParameterTypes())) {
                        String propertyName = getPropertyForSetter(methodName);
                        registerBeanPropertyForMethod(metaMethod, propertyName, false, true);
                    }
                    performRegistryCallbacks();
                    expandoMethods.put(key, metaMethod);
                }
            }

        });
    }
395051
@Nonnull
    public BugInstance addCalledMethod(ConstantPoolGen cpg, InvokeInstruction inv) {
        String className = inv.getClassName(cpg);
        String methodName = inv.getMethodName(cpg);
        String methodSig = inv.getSignature(cpg);
        addMethod(className, methodName, methodSig, inv.getOpcode() == Const.INVOKESTATIC);
        describe(MethodAnnotation.METHOD_CALLED);
        return this;
    }
88258
protected function registerExtraMethodCallback($name, $callback)
    {
        if (!isset($this->extra_method_registers[$name])) {
            $this->extra_method_registers[$name] = $callback;
        }
    }
1158432
public void pushEnclosingMethodCall(Expression call) {
        if (call instanceof MethodCallExpression || call instanceof StaticMethodCallExpression) {
            enclosingMethodCalls.addFirst(call);
        } else {
            throw new IllegalArgumentException("Expression must be a method call or a static method call");
        }
    }
521423
public function registerWidget($name, \Closure $callable)
    {
        if (isset($this->widgets[$name])) {
            throw new \InvalidArgumentException(sprintf(
                'A widget by the name "%s" already exists and cannot be overridden.',
                $name
            ));
        }

        $this->widgets[$name] = function (array $params = []) use ($callable) {
            static $instance;
            if (null === $instance) {
                $instance = $callable($params);
            }
            return $instance;
        };
    }
883622
public function addMethod(string $name, callable $callback = null): self
    {
        if ($this->isFinalized) {
            throw new FinalizedMockException();
        }
        if (!$callback) {
            $callback = $this->emptyCallback;
        }

        $this->customMethods[$name] = [
            $callback,
            $this->invocableInspector->callbackReflector($callback),
        ];

        return $this;
    }
1023898
public function addMethod(string $methodName, callable $methodClosure): void
    {
        $this->methods[strtolower($methodName)] = $methodClosure->bindTo($this);
    }
355982
public void registerDestructionCallback(String name, Runnable callback) {
		Bean bean = beans.get(name);
		if (null == bean) {
			bean = new Bean();
			beans.put(name, bean);
		}
		bean.destructionCallback = callback;
	}
1251759
public static <V> Callable<V> buildCallableWithLogging(String name,
            Callable<V> callable, Object... params) {
        return () -> supplyAsync(() -> {
            try {
                JMLog.debug(log, name, System.currentTimeMillis(), params);
                return callable.call();
            } catch (Exception e) {
                return JMExceptionManager.handleExceptionAndReturnNull(log, e,
                        name, params);
            }
        }).get();
    }
1334676
@Override
    public void registerDestructionCallback(String name, Runnable callback) {
        synchronized (this) {
            destructionCallbacks.put(name, callback);
        }
    }
1059868
def memoize_method(method_name, freezer)
      memoized_methods[method_name] = Memoizable::MethodBuilder
        .new(self, method_name, freezer).call
    end
410456
public Object invokeMethod(String name, Object args) {
        try {
            return getMetaClass().invokeMethod(this, name, args);
        } catch (MissingMethodException e) {
            // let's apply the method to each item in the collection
            List answer = new ArrayList(size());
            for (Object element : this) {
                Object value = InvokerHelper.invokeMethod(element, name, args);
                answer.add(value);
            }
            return answer;
        }
    }
945657
public function addStaticMethod(
        string $name,
        callable $callback = null
    ): self {
        if ($this->isFinalized) {
            throw new FinalizedMockException();
        }
        if (!$callback) {
            $callback = $this->emptyCallback;
        }

        $this->customStaticMethods[$name] = [
            $callback,
            $this->invocableInspector->callbackReflector($callback),
        ];

        return $this;
    }
762522
public function register($name, Closure $callback)
    {
        $this->checkCallbackName($name);

        $this->callbacks[$name] = $callback;

        return $this;
    }
823081
static <J> MethodId<J> MethodId(String name) {
		for (Method m : JavacTreeMaker.class.getDeclaredMethods()) {
			if (m.getName().equals(name)) {
				@SuppressWarnings("unchecked") Class<J> r = (Class<J>) m.getReturnType();
				Class<?>[] p = m.getParameterTypes();
				return new MethodId<J>(TreeMaker.class, name, r, p);
			}
		}
		
		throw new InternalError("Not found: " + name);
	}
1064733
private function registerMethodHook($method, callable $callable)
    {
        $callableRegistrationTokens = [
            '^(after)(.*)(Hook)',
            '^(before)(.*)(Hook)',
            '^(onceAfter)(.*)(Hook)',
            '^(onceBefore)(.*)(Hook)'
        ];

        if (isset($this->hooksNotRestricted[$method])) {
            $this->hooks[$this->hooksNotRestricted[$method]][] = $callable;

            return true;
        } elseif (($matches = self::matchesAny($callableRegistrationTokens, $method)) !== null) {
            if ( ! empty($matches[2])) {
                self::methodExists($matches[2]);
            }

            $targetMethod = lcfirst($matches[2]);

            self::methodNotRestricted($targetMethod, $method);

            $hookName = $matches[1].$matches[2];

            $this->hooksNotRestricted[$method] = $hookName;

            self::checkCallable($this, $callable, $targetMethod);

            $this->hooks[$hookName][] = $callable;

            return true;
        } elseif (strpos($method, 'call') === false) {
            throw new \BadMethodCallException("There's a typo in $method. Can't properly set up hook.");
        }
    }
1299139
function createMethod(name, fn) {
        return function () {
          var self = this, tmp = self._super, ret;

          self._super = _super[name];
          ret = fn.apply(self, arguments);
          self._super = tmp;

          return ret;
        };
      }