Specify a callback to be called to load the collection.
TODO: Figure out how to declare the arguments

@param string $function_name
@param null $obj_or_class

@throws CollectionException
4968
public function setLoadCallback($function_name, $obj_or_class = null) : void
    {
        if ($obj_or_class) {
            $callback = array($obj_or_class, $function_name);
        } else {
            $callback = $function_name;
        }
        // Make sure the function is valid
        if (!is_callable($callback, false, $callableName)) {
            throw new CollectionException('Invalid callback specified.');
        }
        $this->onload = $callback;
    }
272284
protected function defineDate($app_name, $ext_name)
	{
		$app_callable = function ($date) {
			return $date instanceof MongoDate ? new \DateTime('@' . $date->sec) : null;
		};

		$ext_callable = function ($date) {
			if (empty($date)) {
				return null;
			}

			$date = $date instanceof \DateTime ? $date->getTimestamp() : strtotime($date);

			return new MongoDate($date);
		};

		$this->define($app_name, $ext_name, $app_callable, $ext_callable);
	}
272126
private function functionCall(Node $function_reference, $dynamic = FALSE) {
    if ($dynamic) {
      $node = new CallbackCallNode();
      $node->addChild($function_reference, 'callback');
    }
    else {
      if ($function_reference instanceof NameNode && $function_reference->childCount() === 1 && $function_reference == 'define') {
        $node = new DefineNode();
      }
      else {
        $node = new FunctionCallNode();
      }
      $node->addChild($function_reference, 'name');
    }
    $this->functionCallParameterList($node);
    return $this->objectDereference($this->arrayDeference($node));
  }
199117
public function addItem($object, ?string $key = null) : void
    {
        $this->checkCallback();

        if (null !== $key) {
            if (isset($this->members[$key])) {
                throw new CollectionException('Unable to add to collection - key ' . $key . ' already used.');
            } else {
                $this->members[$key] = $object;
            }
        } else {
            $this->members[] = $object;
        }
    }
877357
public function importsFunction($function_name = NULL) {
    if (!$this->useFunction) {
      return FALSE;
    }
    if ($function_name) {
      foreach ($this->getDeclarations() as $declaration) {
        if ($declaration->getName()->getPath() === $function_name) {
          return TRUE;
        }
      }
      return FALSE;
    }
    else {
      return TRUE;
    }
  }
914934
public void call(String name, Collection coll, @DelegatesTo(StreamingJsonDelegate.class) Closure c) throws IOException {
        call(name, (Iterable)coll, c);
    }
957905
public function loadObjectList($class_name = "stdClass")
    {
        if ($this->stmt === null) {
            return null;
        }

        $objectList = array();
        while ($object = $this->stmt->fetchObject($class_name)) {
            $objectList[] = $object;
        }
        return $objectList;
    }
70556
private function classMethodCall($class_name, $colon_node, $method_name) {
    $node = new ClassMethodCallNode();
    $node->addChild($class_name, 'className');
    $node->mergeNode($colon_node);
    $node->addChild($method_name, 'methodName');
    $this->functionCallParameterList($node);
    return $this->objectDereference($this->arrayDeference($node));
  }
952317
function _initCollections() {
    if (!this._collections) {
      return;
    }

    for (var coll in this._collections) {
      this[coll] = new this._collections[coll](null, { parent: this, parse: true });
    }
  }
317648
protected function getClosure(string $class_name, string $class_key): callable
    {
        $parent_class_names = class_parents($class_name);
        $all_class_names    = $parent_class_names;
        $all_class_names[]  = $class_name;

        $class                      = new \ReflectionClass($class_name);
        $constructor                = $class->getConstructor(); // Null if no constructor.
        $class_rule                 = $this->getRule($class_name, $class_key, $parent_class_names);
        $constructor_params_closure = $constructor ? $this->getParamsClosure($constructor, $class_rule) : null;

        if (!$this->rules['*']['new_instances'] || !array_intersect($all_class_names, $this->rules['*']['new_instances'])) {
            return function (array $args) use ($class, $class_key, $constructor, $constructor_params_closure) {
                if ($constructor && $constructor_params_closure) {
                    return $this->instances[$class_key] = $class->newInstanceArgs($constructor_params_closure($args));
                } else {
                    return $this->instances[$class_key] = $class->newInstanceWithoutConstructor();
                }
            };
        } elseif ($constructor && $constructor_params_closure) {
            return function (array $args) use ($class, $constructor_params_closure) {
                return $class->newInstanceArgs($constructor_params_closure($args));
            };
        } else {
            return function (array $args) use ($class) {
                return $class->newInstanceWithoutConstructor();
            };
        }
    }
309129
function callback(unknown) {
    // returns the cb if a cb
    // returns a noop function if undefined
    // throws an error if neither
    // -------------------------
    // assume it is a function to be returned
    var returnFunction = unknown;
    // check if it's undefined
    if (unknown === undefined) {
        // if it is, replace it with a noop function
        returnFunction = _.noop;
    // otherwise, check if it's a function
    } else if (!_.isFunction(unknown)) {
        // if not a function and not undefined, something
        // is unexpected, programmatically.
        var error = new VError("Defined object passed as a callback is not a function");
        error.object = unknown;
        throw error;
    }
    // get here if either it was a function in the first place
    // or was undefined and we defined it.  Return the function.
    return returnFunction;
}
946073
function fetchCollection($class_name = "stdClass")
    {
        /* backward compatibility, you can use object instead of class name */
        if (is_object($class_name)) {
            $class_name = get_class($class_name);
        }

        return $this->fetchAll(DB::FETCH_CLASS, $class_name);
    }
745148
function (collectionName, sessionCallbacks) {
  var self = this;
  self.collectionName = collectionName;
  self.documents = {};
  self.callbacks = sessionCallbacks;
}
36440
public static function bindAndCall(callable $fn, $newThis, $args = [], $bindClass = null)
    {
        $func = \Closure::bind($fn, $newThis, $bindClass ?: get_class($newThis));
        if ($args) {
            call_user_func_array($func, $args);
        } else {
            $func(); //faster
        }
    }
350444
def method_missing(method, *args, &block)
      return super unless method =~ /^find_(all_|last_|or_(initialize_|create_))?by_/

      result = object_class.send(method, *args, &block)
      options = args.extract_options!

      if method =~ /^find_all/
        decorate_collection(result, options)
      else
        decorate(result, options)
      end
    end
705807
function loadObject(data, db, callback) {
    callback = callback || function() {};
    var iterator = function(modelName, next){
        insertCollection(modelName, data[modelName], db, next);
    };
    async.forEachSeries(Object.keys(data), iterator, callback);
}
815893
function bindCallbacks( o, callbacks, args ) {
		var prop = QUnit.objectType( o );
		if ( prop ) {
			if ( QUnit.objectType( callbacks[ prop ] ) === "function" ) {
				return callbacks[ prop ].apply( callbacks, args );
			} else {
				return callbacks[ prop ]; // or undefined
			}
		}
	}