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

Support for array shape for ArrayAccess classes. #7650

Closed
@alexander-schranz

Description

Feature request

In Symfony there is the OptionResolver component which returns a Options object which is a ArrayAccess object. This is used inside symfony forms to define form options.

As the input here is already validated I want to define the Symfony Options object like an array shape e.g.:

 return (new OptionsResolver())
 ->setDefault('account', null)
 ->setNormalizer('account', fn (Options $options, ?AccountInterface $account) => $account ?: $this->accountFactory->create([]))
 ->setDefault('visitorList', null)
 ->setNormalizer(
 'visitorList',
 function (Options $options, ?VisitorList $visitorList) {
 /** @var Options{account: Account} $options */
 return $visitorList ?: $this->visitorListFactory->create([
 'account' => $options['account'],
 ]);
 },
 );

But currently phpstan does not support this. It would be great if phpstan does support array shapes also on ArrayAccess objects.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /