Traverses the contents folders and files calling $callback for each node
@param Funtion $callback Three arguents will be passed to the the callback:
The path preceding the Name
The name
PATHINFO_BASENAME is the name is a file or PATHINFO_DIRNAME
183886
public function traverseContents( $callback )
	{
		if ( ! $callback ) return;

		$traverse = function( $nodes, $path = "" ) use ( &$traverse, &$callback )
		{
			if ( is_string( $nodes ) )
			{
				return $callback( $path, $nodes, PATHINFO_BASENAME );
			}

			foreach ( $nodes as $name => $children )
			{
				if ( ! is_array( $children ) ) // It's a file
				{
					if ( ! $traverse( $children, $path ) ) return false;
					continue;
				}

				if ( ! $callback( $path, $name, PATHINFO_DIRNAME ) ) return false;

				if ( ! $traverse( $children, "$path$name/" ) )
				{
					return false;
				}
			}

			return true;
		};

		$traverse( $this->contents );
	}
141205
public function each(callable $callback)
    {
        foreach ($this->nodes as $index => $node) {
            $return_value = \call_user_func($callback, $node, $index);

            if ($return_value === false) {
                break;
            }
        }

        return $this;
    }
984564
public function getContent($key, $callback)
    {
        if ($this->nestedContentFilter) {
            return $this->nestedContentFilter->getContent($key, $callback);
        } else {
            return call_user_func($callback);
        }
    }
483926
static function chdir($dir, $callback = null, $argv = array())
    {
        if (!is_dir($dir)) {
            throw new \InvalidArgumentException("$dir does not exist.");
        }

        $cwd = getcwd();
        chdir($dir);

        if (null === $callback) {
            return;
        }

        $returnValue = call_user_func_array($callback, $argv);

        chdir($cwd);
        return $returnValue;
    }
992562
public function setCallback($callback = NULL) {

		if (NULL !== $callback) {

			// taken from http://www.geekality.net/2011/08/03/valid-javascript-identifier/
			$pattern = '/^[$_\p{L}][$_\p{L}\p{Mn}\p{Mc}\p{Nd}\p{Pc}\x{200C}\x{200D}]*+$/u';

			foreach (explode('.', $callback) as $part) {
				if (!preg_match($pattern, $part)) {
					throw new \InvalidArgumentException(sprintf("The callback name '%s' is not valid.", $part));
				}
			}
		}

		$this->callback = $callback;

		return $this->update();

	}
308003
protected function resolvingCallback(Closure $callback)
    {
        $abstract = $this->getFunctionHint($callback);

        if ($abstract) {
            $this->resolvingCallbacks[$abstract][] = $callback;
        } else {
            $this->globalResolvingCallbacks[] = $callback;
        }
    }
605928
protected function commandCallback($callback)
    {
        return (
            function ($output) use ($callback) {
                $this->output .= $output;
                if (is_callable($callback)) {
                    return call_user_func($callback, $output);
                }
            }
        );
    }
1011887
public function recursiveWalk(callable $callback)
    {
        $stack = $this->toArray();
        while (!empty($stack)) {
            /** @var FormField $field */
            $field = array_shift($stack);
            $callback($field);
            if ($field instanceof CompositeField) {
                $stack = array_merge($field->getChildren()->toArray(), $stack);
            }
        }
    }
1130173
protected static function controllerCallback($callback)
    {
        $datas      = Structure::data($callback);
        $function   = $datas['function'];
        $parameters = $datas['parameters'];
        $class      = $datas['namespace'] . $datas['page'];

        return function() use($class, $function, $parameters)
        { 
            (new $class)->$function(...$parameters); 
        };
    }
335263
public function mapSurname(Closure $callback)
    {
        $surnames = $this->path.'/surnames';

        if (file_exists($surnames)) {
            $dictionary = (array) include $surnames;
            $callback($dictionary);
        }
    }
640972
function traverse(node, callback) {
    callback(node);
    for (var i = 0, cn = node.childNodes, len = cn.length; i < len; i++) {
        var childNode = cn[i];
        if (childNode.tagName) {
            traverse(childNode, callback);
        }
    }
}
660900
private function generateCallback(Closure $callback): Closure
    {
        return function ($match) use ($callback) {
            if ($match[1] == '[' && $match[6] == ']') {
                return substr($match[0], 1, -1);
            }

            $content = isset($match[5]) ? $match[5] : null;
            $atts = isset($match[3]) ? $this->parseAttributes($match[3]) : [];

            return $callback($match[2], $content, $atts);
        };
    }
1002243
public static function _printCallback($callback)
    {
        if (is_array($callback)) {
            if (is_object($callback[0])) {
                $className = get_class($callback[0]);
            } else {
                $className = strval($callback[0]);
            }
            $functionName = $className . '::' . strval($callback[1]);
        }
        else {
            $functionName = strval($callback);
        }
        return $functionName;
    }
1219251
public function map($callback)
    {
        if (!is_callable($callback)) {
            throw new InvalidArgumentException('Callback has to be a valid callable, '.gettype($callback).' given.');
        }

        for ($i = 0; $this->checkIfLineNumberIsValid($i, false); $i++) {
            $this->setCurrentLineNumber($i);
            call_user_func($callback, $this->getLine($i), $i, $this);
        }
    }
518146
public function mapSurname(Closure $callback)
    {
        if (empty($this->surnames)) {
            $surnames = $this->path.'/surnames';

            if (file_exists($surnames)) {
                $this->surnames = (array) include $surnames;
            }
        }

        $callback($this->surnames);
    }
765223
function(callback) {
      fs.readdir(args['<directory>'], function(err, files) {
        // error here means it does not exist, which is good.
        if (err || args['--force']) {
          return callback(null, args['<directory>']);
        }
        if (files.length > 0) {
          return callback(new Error(format('destination '
            + 'directory %s is not empty.', path.resolve(args['<directory>']))));
        }
        return callback(null, args['<directory>']);
      });
    }
931549
function(callback) {
		var self = this;
		var sections = [Path.join("/")];
		var paths_to_traverse = [];

		var should_exclude = function(entry) {
			return entry[0] === "." || entry[0] === "_" || entry === "shared";
		};

		var traverse_path = function() {
			var current_path = paths_to_traverse.shift() || "";
			Fs.readdir(Path.join(self.contentDir, current_path), function(err, entries) {
				if (err) {
					throw err;
				}

				var run_callbacks = function() {
					if (entries.length) {
						return next_entry();
					} else if (paths_to_traverse.length) {
						return traverse_path();
					} else {
						return callback(sections);
					}
				};

				var next_entry = function() {
					var current_entry = entries.shift();
					if (should_exclude(current_entry)) {
						return run_callbacks();
					}

					var current_entry_path = Path.join(current_path, current_entry);
					Fs.stat(Path.join(self.contentDir, current_entry_path), function(err, stat) {
						if (err) {
							return run_callbacks();
						}

						if (stat.isDirectory()) {
							sections.push(Path.join("/",current_entry_path));
							paths_to_traverse.push(current_entry_path);
						}

						return run_callbacks();
					});
				};

				return run_callbacks();
			});
		};
		return traverse_path();
	}