private function resolveRouteParameters(array $attributes): array
    {
        if (!isset($attributes['_route'])) {
            return [];
        }

        $routeParameters = array_keys($attributes['_route_params']);
        $routeParameters = array_combine($routeParameters, $routeParameters);

        if (!$this->annotatedRouteControllerLoader) {
            return $routeParameters;
        }

        // AnnotatedRouteControllerLoader from BeSimpleI18nRoutingBundle loads routes differently than the default one from Symfony.
        // It populates _route_params with all default parameter values from controller action even with ones which placeholders are not present in route definition.
        // The following workaround relies on the fact that URL generator generates URL with parameters which placeholders are not present in route definition as query string.
        // @see https://github.com/BeSimple/BeSimpleI18nRoutingBundle/blob/83d2cf7c9ba6e6e3caed5d063b185ae54645eeee/src/Routing/Loader/AnnotatedRouteControllerLoader.php#L43
        // @see https://github.com/symfony/symfony/blob/8ab7077225eadee444ba76c83c667688763c56fb/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php#L202

        if ($this->configurableUrlGenerator) {
            $isStrictRequirements = $this->configurableUrlGenerator->isStrictRequirements();
            $this->configurableUrlGenerator->setStrictRequirements(null);
        }

        $url = $this->urlGenerator->generate($attributes['_route'], $routeParameters);

        if (isset($isStrictRequirements)) {
            $this->configurableUrlGenerator->setStrictRequirements($isStrictRequirements);
        }

        parse_str(parse_url($url, PHP_URL_QUERY), $additionalAttributes);

        return array_diff_key($routeParameters, $additionalAttributes);
    }