Skip to content

Conversation

@alexndlm
Copy link
Contributor

@alexndlm alexndlm commented Sep 4, 2023

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

When the config node doesn't have normalization, using the config object is impossible.

When the config node has some array normalization (like http_codes in \Symfony\Bundle\FrameworkBundle\DependencyInjection\Configuration::addHttpClientRetrySection), it is not possible to use the config object.

This PR relates to changes introduced in:

Снимок экрана 2023-09-01 в 22 22 28

@nicolas-grekas
Copy link
Member

Thanks for working on this, it's related to the limitation I found in #51273
Can you please rebase+target 6.4? That's an improvement, not a bugfix to me.

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes on the Config components are BC breaks. Can we find a way that doesn't break BC?

if ($this->default) {
if (!\is_array($this->defaultValue)) {
throw new \InvalidArgumentException(sprintf('%s: the default value of an array node has to be an array.', $node->getPath()));
throw new \InvalidArgumentException(sprintf('"%s": the default value of an array node has to be an array.', $node->getPath()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be reverted, that's a false-positive from fabbot I suppose


protected $node;

public $allowedTypes;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing consts and public properties is a BC break, we need to figure out a way that doesn't break BC

@alexndlm alexndlm force-pushed the feature/config-allow-to-always-use-config-classes branch from f4bb242 to 72e1fd0 Compare November 11, 2023 14:08
@alexndlm alexndlm marked this pull request as draft November 11, 2023 14:13
@alexndlm alexndlm changed the base branch from 6.3 to 6.4 November 11, 2023 14:13
@nicolas-grekas nicolas-grekas modified the milestones: 6.3, 6.4 Feb 1, 2024
$parameterTypes = $this->getParameterTypes($node);
$comment .= ' * @param ParamConfigurator|'.implode('|', $parameterTypes).' $value'."\n";
$parameterType = $this->getParameterType($node);
if (null === $parameterType || '' === $parameterType) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why returning an empty string to mean mixed instead of returning mixed ?

* @template TValue
* @param TValue $value
* @return \Symfony\Config\NodeInitialValues\MessengerConfig|$this
* @psalm-return (TValue is array ? \Symfony\Config\NodeInitialValues\MessengerConfig : static)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why should passing an array return a MessengerConfig while passing another kind of value would be fluent ? What does this correspond to ?

Copy link
Member

@nicolas-grekas nicolas-grekas Sep 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wondered about the same and I think I've got the answer:

  • When you pass a non-array, you likely won't want to configure anything else nested in the tree you're configuring. That's what happens for other config formats, structurally.
  • When you pass an array, you can configure nested options, so that then it might make sense to return the nested config-builder.

I'm just wondering about the check: should we return the config-builder when the array is non empty?
Or should we do this?

Suggested change
* @psalm-return (TValue is array ? \Symfony\Config\NodeInitialValues\MessengerConfig : static)
* @psalm-return (TValue is non-empty-array ? $this :\Symfony\Config\NodeInitialValues\MessengerConfig)

* @return $this
*/
public function keyedArray(string $name, ParamConfigurator|string|array $value): static
public function keyedArray(string $name, mixed $value): static
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this type becoming wider looks like a regression to me.

@nicolas-grekas nicolas-grekas modified the milestones: 6.4, 7.4 Sep 24, 2025
@nicolas-grekas
Copy link
Member

Let me close as stalled and superseded by #51273
Feel free to open an issue to describe any remauning issue of course.

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