Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[TypeInfo] AddArrayShapeType class#59827

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
GromNaN merged 1 commit intosymfony:7.3frommtarld:feat/array-shape
Mar 14, 2025

Conversation

mtarld
Copy link
Contributor

QA
Branch?7.3
Bug fix?no
New feature?yes
Deprecations?no
Issues
LicenseMIT

Introduces theArrayShapeType that holds the exact shape of an array. Also enables theStringTypeResolver to parsearray{foo: int, bar?: string} and to create the appropriate type.

This PR needs#59824 to be merged first.

kaznovac and GromNaN reacted with thumbs up emojijaviereguiluz, kaznovac, and Zuruuh reacted with heart emoji
foreach ($value as $key => $itemValue) {
$valueType = $this->shape[$key]['type'] ?? false;
if (!$valueType) {
return false;
Copy link
Member

Choose a reason for hiding this comment

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

For extra keys, the behavior is different betweenPHPStan (allow) andpsalm (restrict). You implemented the strict version:false is returned when an extra key is present. This is consistent with psalm and PHPStorm 👍🏻

There is a syntax using... to allow extra keys (demo); but this is not supported by PHPStorm and PHP_CodeSniffer.

/** @param array{foo: string, ...} $a */function fun(array$a):int

This feature can wait for a subsequent PR.

@GromNaN
Copy link
Member

Thank you Mathias.

@GromNaNGromNaN merged commitcf5270c intosymfony:7.3Mar 14, 2025
11 checks passed
@mtarldmtarld deleted the feat/array-shape branchMarch 14, 2025 09:22
fabpot added a commit that referenced this pull requestMar 26, 2025
This PR was merged into the 7.3 branch.Discussion----------[TypeInfo] Add `ArrayShapeType::$sealed`| Q             | A| ------------- | ---| Branch?       | 7.3| Bug fix?      | no| New feature?  | yes| Deprecations? | no| Issues        || License       | MITImplement sealed syntax for array shape type, as suggested in#59827 (comment).Commits-------fded1eb [TypeInfo] Add `ArrayShapeType::$extraKeyType` and `ArrayShapeType::$extraValueType`
symfony-splitter pushed a commit to symfony/type-info that referenced this pull requestMar 26, 2025
This PR was merged into the 7.3 branch.Discussion----------[TypeInfo] Add `ArrayShapeType::$sealed`| Q             | A| ------------- | ---| Branch?       | 7.3| Bug fix?      | no| New feature?  | yes| Deprecations? | no| Issues        || License       | MITImplement sealed syntax for array shape type, as suggested insymfony/symfony#59827 (comment).Commits-------fded1eb5030 [TypeInfo] Add `ArrayShapeType::$extraKeyType` and `ArrayShapeType::$extraValueType`
@fabpotfabpot mentioned this pull requestMay 2, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@GromNaNGromNaNGromNaN approved these changes

@chalasrchalasrchalasr approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
7.3
Development

Successfully merging this pull request may close these issues.

4 participants
@mtarld@GromNaN@chalasr@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp