Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[DependencyInjection] Allow extending #[AsAlias] attribute #60819

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 18, 2025

Conversation

ruudk
Copy link
Contributor

@ruudk ruudk commented Jun 18, 2025

Q A
Branch? 7.4
Bug fix? no
New feature? yes
Deprecations? no
Issues
License MIT

This allows people to extend the #[AsAlias] attribute with something like this:

namespace App\Symfony;

use Symfony\Component\DependencyInjection\Attribute\AsAlias;

final class AsProductionAlias extends AsAlias
{
    /**
     * @param string|null         $id     The id of the alias
     * @param bool                $public Whether to declare the alias public
     */
    public function __construct(
        public ?string $id = null,
        public bool $public = false,
    ) {
        parent::__construct($id, $public, ['prod']);
    }
}

This is similar to a previous change I did for the #[When] attribute, that was accepted:

@nicolas-grekas nicolas-grekas force-pushed the allow-extending-as-alias branch from cde21b1 to 90fd3ff Compare June 18, 2025 11:24
@nicolas-grekas
Copy link
Member

Thank you @ruudk.

@nicolas-grekas nicolas-grekas merged commit 08e4c09 into symfony:7.4 Jun 18, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants