Repository: symfony/symfony
File: src/Symfony/Component/Routing/Attribute/Route.php (PHP)

Code before:
    public function setEnv(?string $env): void
    {
        trigger_deprecation('symfony/routing', '7.4', 'The "%s()" method is deprecated, use "setEnvs()" instead.', __METHOD__);
        $this->env = (array) $env;
    }

    /**
     * @deprecated since Symfony 7.4, use {@see getEnvs()} method instead
     */
    public function getEnv(): ?string
    {
        trigger_deprecation('symfony/routing', '7.4', 'The "%s()" method is deprecated, use "getEnvs()" instead.', __METHOD__);
        if (!$this->env) {
            return null;
        }
        if (\count($this->env) > 1) {
            throw new LogicException(\sprintf('The "env" property has %d environments. Use "getEnvs()" to get all of them.', \count($this->env)));
        }

        return $this->env[0];
    }

    public function setEnvs(array $env): void
    {
        $this->env = $env;
    }

    public function getEnvs(): array
    {
        return $this->env;
    }

    /**
     * @return (string|DeprecatedAlias)[]
     */
    public function getAliases(): array
    {
        return $this->aliases;
    }

    /**
     * @param string|DeprecatedAlias|(string|DeprecatedAlias)[] $aliases
     */
    public function setAliases(string|DeprecatedAlias|array $aliases): void
    {
        $this->aliases = \is_array($aliases) ? $aliases : [$aliases];
    }
}

if (!class_exists(\Symfony\Component\Routing\Annotation\Route::class, false)) {
    class_alias(Route::class, \Symfony\Component\Routing\Annotation\Route::class);

Review comment (suggestion):
To be consistent with `setSchemes` and `setMethods`, this method should probably accept a string.


```suggestion
    public function setEnvs(array|string $env): void
    {
        $this->env = (array) $env;
    }
```

We keep accepting `null` in the constructor for BC. That could be deprecated. But I'm not sure it's worth it.

Code after:
    public function setEnv(?string $env): void
    {
        trigger_deprecation('symfony/routing', '7.4', 'The "%s()" method is deprecated, use "setEnvs()" instead.', __METHOD__);
        $this->env = (array) $env;
    }

    /**
     * @deprecated since Symfony 7.4, use {@see getEnvs()} method instead
     */
    public function getEnv(): ?string
    {
        trigger_deprecation('symfony/routing', '7.4', 'The "%s()" method is deprecated, use "getEnvs()" instead.', __METHOD__);
        if (!$this->env) {
            return null;
        }
        if (\count($this->env) > 1) {
            throw new LogicException(\sprintf('The "env" property has %d environments. Use "getEnvs()" to get all of them.', \count($this->env)));
        }

        return $this->env[0];
    }

    public function setEnvs(array|string $env): void
    {
        $this->env = (array) $env;
    }

    public function getEnvs(): array
    {
        return $this->env;
    }

    /**
     * @return (string|DeprecatedAlias)[]
     */
    public function getAliases(): array
    {
        return $this->aliases;
    }

    /**
     * @param string|DeprecatedAlias|(string|DeprecatedAlias)[] $aliases
     */
    public function setAliases(string|DeprecatedAlias|array $aliases): void
    {
        $this->aliases = \is_array($aliases) ? $aliases : [$aliases];
    }
}

if (!class_exists(\Symfony\Component\Routing\Annotation\Route::class, false)) {
    class_alias(Route::class, \Symfony\Component\Routing\Annotation\Route::class);