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 PHP 8 Constructor Promotions #189

Open
klesun opened this issue Jul 30, 2021 · 0 comments
Open

Support PHP 8 Constructor Promotions #189

klesun opened this issue Jul 30, 2021 · 0 comments

Comments

@klesun
Copy link
Owner

klesun commented Jul 30, 2021

image

Consider this ctor.

When I instantiate this class, I don't get suggestions of ro-user or ro-password for $config array (first argument)

See https://php.watch/versions/8.0/constructor-property-promotion#:~:text=Constructor%20Property%20Promotion%20is%20a%20shorthand%20syntax%20to%20declare%20and,additional%20code%20within%20the%20constructor.

For time being a workaround is to go the pre-php8 way:

private $config;
private $adminConfig;

/**
 * @param array{
 *     user: string,
 *     pass: string,
 *     host: string,
 *     ro-user: string,
 *     ro-pass: string,
 *     ro-host: string,
 *     dbname: string,
 * } $config
 *
 * @param array {
 *     user: string,
 *     pass: string,
 * } $adminConfig
 */
public function __construct($config, $adminConfig)
{
    $this->config = $config;
    $this->adminConfig = $adminConfig;
}
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