Skip to content

[TypeInfo] Add ArrayShapeType::$sealed #59981

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
Mar 26, 2025

Conversation

mtarld
Copy link
Contributor

@mtarld mtarld commented Mar 15, 2025

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

Implement sealed syntax for array shape type, as suggested in #59827 (comment).

@mtarld
Copy link
Contributor Author

mtarld commented Mar 15, 2025

As 7.3 has been released yet, I think that 8.2 low-deps failures can be ignored.

@mtarld mtarld requested a review from GromNaN March 15, 2025 13:29
@mtarld mtarld force-pushed the feat/array-shape-sealed branch from 62a0dab to 1e70c86 Compare March 15, 2025 23:20
@mtarld mtarld force-pushed the feat/array-shape-sealed branch from 1e70c86 to 9030a26 Compare March 16, 2025 12:04
@@ -56,6 +60,14 @@ public function __construct(array $shape)
ksort($sortedShape);

$this->shape = $sortedShape;

if ($this->extraKeyType xor $this->extraValueType) {
throw new InvalidArgumentException(\sprintf('You must provide as value for "$%s" when "$%s" is provided.', ...($this->extraKeyType ? ['extraValueType', 'extraKeyType'] : ['extraKeyType', 'extraValueType'])));
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand this error message.

@@ -56,6 +60,14 @@ public function __construct(array $shape)
ksort($sortedShape);

$this->shape = $sortedShape;

if ($this->extraKeyType xor $this->extraValueType) {
throw new InvalidArgumentException(\sprintf('You must provide as value for "$%s" when "$%s" is provided.', ...($this->extraKeyType ? ['extraValueType', 'extraKeyType'] : ['extraKeyType', 'extraValueType'])));
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
throw new InvalidArgumentException(\sprintf('You must provide as value for "$%s" when "$%s" is provided.', ...($this->extraKeyType ? ['extraValueType', 'extraKeyType'] : ['extraKeyType', 'extraValueType'])));
throw new InvalidArgumentException(\sprintf('You must provide a value for "$%s" when "$%s" is provided.', $this->extraKeyType ? 'extraValueType' : 'extraKeyType', $this->extraKeyType ? 'extraKeyType' : 'extraValueType'));

@fabpot fabpot force-pushed the feat/array-shape-sealed branch from 0bd93a0 to fded1eb Compare March 26, 2025 07:17
@fabpot
Copy link
Member

fabpot commented Mar 26, 2025

Thank you @mtarld.

@fabpot fabpot merged commit 452ad95 into symfony:7.3 Mar 26, 2025
4 of 11 checks passed
@fabpot fabpot mentioned this pull request May 2, 2025
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