Skip to content

[Config] Invalid PHP config format #60282

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

Open
robotomarvin opened this issue Apr 27, 2025 · 0 comments
Open

[Config] Invalid PHP config format #60282

robotomarvin opened this issue Apr 27, 2025 · 0 comments

Comments

@robotomarvin
Copy link

Symfony version(s) affected

6.4, 7.0, 7.1, 7.2

Description

Generated messenger config has invalid signature for routing config

    /**
     * @template TValue
     * @param TValue $value
     * @return \Symfony\Config\Framework\Messenger\RoutingConfig|$this
     * @psalm-return (TValue is array ? \Symfony\Config\Framework\Messenger\RoutingConfig : static)
     */
    public function routing(string $message_class, array $value = []): \Symfony\Config\Framework\Messenger\RoutingConfig|static
    {
        if (!\is_array($value)) {
            $this->_usedProperties['routing'] = true;
            $this->routing[$message_class] = $value;

            return $this;
        }

        if (!isset($this->routing[$message_class]) || !$this->routing[$message_class] instanceof \Symfony\Config\Framework\Messenger\RoutingConfig) {
            $this->_usedProperties['routing'] = true;
            $this->routing[$message_class] = new \Symfony\Config\Framework\Messenger\RoutingConfig($value);
        } elseif (1 < \func_num_args()) {
            throw new InvalidConfigurationException('The node created by "routing()" has already been initialized. You cannot pass values the second time you call routing().');
        }

        return $this->routing[$message_class];
    }

above code contains dead code because $value would be always and array (ensured by native type hint), making return type always \Symfony\Config\Framework\Messenger\RoutingConfig

$value param should be type hinted as array|\Symfony\Config\Framework\Messenger\RoutingConfig

How to reproduce

Warmup fresh application with installed messenger config, and look into generated Symfony\Config\Framework\MessengerConfig

Possible Solution

No response

Additional Context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants