Skip to content
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

Support new in initializers #302

Closed
dakur opened this issue Dec 14, 2023 · 1 comment
Closed

Support new in initializers #302

dakur opened this issue Dec 14, 2023 · 1 comment

Comments

@dakur
Copy link
Contributor

dakur commented Dec 14, 2023

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.

@dg dg closed this as completed in 6c422d0 Dec 14, 2023
@dakur
Copy link
Contributor Author

dakur commented Dec 20, 2023

Thanks!

dg added a commit that referenced this issue Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant