Get unique hash from callable
@param $callable
@return string
518924
private function hashCallable($callable)
    {
        $result = '';
        if (is_string($callable)) {
            $result = $callable;
        } else if (is_array($callable)) {
            $callableEntity = array_shift($callable);
            $result = is_object($callableEntity) ? get_class($callableEntity) : serialize($callableEntity);
            $result .= serialize($callable[0]);
        } else if ($callable instanceof \Closure) {
            $serializer = new Serializer();
            return $serializer->serialize($callable);
        } else if (is_object($callable)) {
            $result = serialize($callable);
        }
        return md5($result);
    }
829399
public function getHashCode()
    {
        return md5(
            $this->renderingFunction .
            $this->mimeType .
            $this->uniqueName .
            parent::getHashCode() .
            __CLASS__
        );
    }
676048
protected static function share($callable)
    {
        if (!is_object($callable) || !method_exists($callable, '__invoke')) {
            throw new InvalidArgumentException('Service definition is not a Closure or invokable object.');
        }

        return function ($container) use ($callable) {
            static $object;

            if (null === $object) {
                $object = $callable($container);
            }

            return $object;
        };
    }
418534
private function createResponseObject(callable $callable)
    {
        try {
            $response = new JsonResponse($callable());
        } catch (EntityNotFoundException $notFoundException) {
            $response = new JsonResponse(
                $notFoundException->getMessage(),
                404
            );
        } catch (Exception $e) {
            $response = new JsonResponse(
                'API exception. Please contact your webmaster',
                500
            );
        }

        return $response;
    }
625594
public function findOneBy($directory, $callable)
    {
        if (!is_callable($callable)) {
            throw new \InvalidArgumentException(sprintf("Cannot filter results. Expected callable, got %s", gettype($callable)));
        }

        if ($directory instanceof Directory) {
            $directory = $directory->getRealpath();
        }

        $directory = '/'.ltrim($directory, "/");
        $raw       = $this->wrapper->rawlist($directory);

        if (false === $raw) {
            throw new DirectoryException(sprintf("Directory %s not found", $directory));
        }

        foreach ($raw as $item) {
            $fs = $this->factory->build($item, $directory);

            if ('/.' === substr($fs->getRealpath(), -2) || '/..' === substr($fs->getRealpath(), -3)) {
                continue;
            }

            if (true === call_user_func_array($callable, array($fs))) {
                return $fs;
            }
        }

        return null;
    }
1120542
protected function getAllFromProviders(callable $callable)
    {
        $values = array_filter(array_map($callable, $this->providers));
        $all = [];

        foreach ($values as $value) {
            foreach ($value as $v) {
                if (!in_array($v, $all, true)) {
                    $all[] = $v;
                }
            }
        }

        return $all;
    }
933611
public function generateHash()
    {
        $this->createCallableObjects();

        $sHash = '';
        foreach($this->aNamespaces as $sNamespace => $aOptions)
        {
            $sHash .= $sNamespace . $aOptions['separator'];
        }
        foreach($this->aCallableObjects as $sClassName => $xCallableObject)
        {
            $sHash .= $sClassName . implode('|', $xCallableObject->getMethods());
        }

        return md5($sHash);
    }
699329
public function some(callable $callback) {
		$match = false;
		foreach ($this->collection as $element) {
			$match = $match || $callback($element);
		}

		return $match;
	}
562078
protected static function cacheId($callable)
    {

        if (is_array($callable)) {
            $class = is_string($callable[0]) ? $callable[0] : get_class($callable[0]);
            return "$class::" . $callable[1];
        }

        if (is_string($callable)) {
            return $callable;
        }

        if (!$callable instanceof \Closure) {
            return get_class($callable);
        }

        $r = new ReflectionFunction($callable);
        return 'Closure:' . $r->getFileName() . ':' . $r->getStartLine() . ':' . $r->getEndLine();

    }
742777
public function map( $callable ) {
		$elements = array();
		$type = null;
		foreach ( $this->elements as $element ) {
			$result = call_user_func( $callable, $element );

			if ( null === $type ) {
				$type = gettype( $result );

				if ( 'object' === $type ) {
					$type = get_class( $result );
				}
			}

			$elements[] = $result;
		}

		return $this->new_from_trusted( $elements, $type ? : $this->get_type() );
	}
891145
public function map(callable $callable)
    {
        $keys = array_keys($this->items);
        $results = array_map($callable, $this->items, $keys);

        return new self($results);
    }
94935
public static function formatMessage($callable, $parameterName)
    {

        switch (true) {
            case is_array($callable):
                $message = sprintf('%s::%s()', get_class($callable[0]), $callable[1]);
                break;
            case is_object($callable):
                $message = get_class($callable);
                break;
            default:
                $message = (string)$callable;
                break;
        }


        return 'Unable to match parameter named [' . $parameterName . '] for the callable [' . $message . ']';
    }
1002371
protected static function getReflection($callable)
    {

        if (is_array($callable)) {
            return new ReflectionMethod($callable[0], $callable[1]);
        }

        if ($callable instanceof \Closure) {
            return new ReflectionFunction($callable);
        }

        if (is_object($callable)) {
            return new ReflectionMethod($callable, '__invoke');
        }

        // Should be a string until here
        if (strpos($callable, '::')) {
            list($class, $method) = explode('::', $callable);
            return new ReflectionMethod($class, $method);
        }

        return new ReflectionFunction($callable);
    }
69813
private function explodeCallable(callable $method)
    {
        if (is_array($method)) {
            return $method;
        }

        if (is_string($method)) {
            return explode('::', $method);
        }

        return [$method];
    }
522247
public function filter(callable $callable)
    {
        $result = [];

        foreach ($this->value as $key => $value) {
            if ($callable($value, $key, $this)) {
                $result[$key] = $value;
            }
        }

        return static::of($result);
    }
944371
public function map(callable $callable)
    {
        $keys = $this->keys();
        $items = array_map($callable, $this->attributes, $keys);

        return new static(array_combine($keys, $items));
    }
666270
public function unique( $callback = null ) {

			$result = [];

			if ( $callback === null ) {

				$n = 0;

				for ( $i=0; $i < $this->len; $i++ ) {

					$exists = false;

					for ( $j=0; $j < $n; $j++ ) {
						if ( $this->compare( $result[$j], $this->items[$i] ) === 0 ) {
							$exists = true;
							break;
						}
					}

					if ( !$exists ) {
						$result[] = $this->items[$i];
						$n++;
					}

				}

			} else
			if ( is_callable( $callback ) ) {

				$n = 0;

				for ( $i=0; $i<$this->len; $i++ ) {

					$exists = false;

					for ( $j = 0; $j < $n; $j++ ) {
						if ( call_user_func( $callback, $result[$j], $this->items[$i] ) === 0 ) {
							$exists = true;
							break;
						}
					}

					if ( !$exists ) {
						$result[] = $this->items[$i];
						$n++;
					}

				}

			} else {
				throw new \browserfs\Exception('Invalid argument: $callback. Expected: function( any, any ): int | null' );
			}

			return new self( $result );

		}