public function eachMarked(callable $callback, $result = null)
    {
        $ref = new \ReflectionFunction($callback);
        $params = $ref->getParameters();
        
        if (\count($params) < 2) {
            throw new \InvalidArgumentException(\sprintf('Callback for marker processing must declare at least 2 arguments (object and marker)'));
        }
        
        try {
            $markerType = $params[1]->getClass();
        } catch (\ReflectionException $e) {
            throw new \InvalidArgumentException(\sprintf('Marker class not found: %s', $params[1]->getType()), 0, $e);
        }
        
        if ($markerType === null) {
            throw new \InvalidArgumentException(\sprintf('Argument #2 of marker callback needs to declare a type-hint for the marker'));
        }
        
        $marker = $markerType->getName();
        
        if (!$markerType->isSubclassOf(Marker::class)) {
            throw new \InvalidArgumentException(\sprintf('Marker implementation %s must extend %s', $marker, Marker::class));
        }
        
        if (!isset($this->marked[$marker])) {
            $this->cacheMarkers($marker);
        }
        
        foreach ($this->marked[$marker] as list ($definition, $registration)) {
            $result = $callback($this->shared[$definition->typeName] ?? $this->get($definition->typeName), clone $registration, $result);
        }
        
        return $result;
    }