Skip to content

Support new in initializers #302

Description

@dakur

As of PHP 8.1, it's possible to use new syntax as default value to functions params (rfc). However this doesn't seem to be supported in nette/di yet.

For example with lcobucci/jwt configuration.

Method annotation

ref

 public static function forSymmetricSigner(
        Signer $signer,
        Key $key,
        Encoder $encoder = new JoseEncoder(), // optional argument
        Decoder $decoder = new JoseEncoder(), // optional argument
    ): self {
        // ...
    }

DI config

- Configuration::forSymmetricSigner(
	signer: [instance of Signer]
	key: [instance of Key]
        # no $encoder or $decoder param passed
)

Output

Service of type Encoder required by $encoder in Configuration::forSymmetricSigner not found

When I pass JoseEncoder explicitly, it works.

Note: I removed FQNs for better readability.

Activity

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

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