deep-assoc-completion icon indicating copy to clipboard operation
deep-assoc-completion copied to clipboard

Support PHP 8 Constructor Promotions

Open klesun opened this issue 4 years ago • 0 comments

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;
}

klesun avatar Jul 30 '21 07:07 klesun