Skip to content

Navigation Menu

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

Appearance settings

Type Hinting in ScopedClientConfig.php extra function #60320

Copy link
Copy link
Open
@gobalopper

Description

@gobalopper
Issue body actions

Symfony version(s) affected

7.2.4

Description

The extra function in the generated file var/cache/dev/Symfony/Config/Framework/HttpClient/ScopedClientConfig.php is typehinted as @param ParamConfigurator|list<ParamConfigurator|mixed> $value which is causing an issue in my framework.php config file.

Here is an example config that gets the error from phpstan:

<?php
// config/packages/framework.php
use Symfony\Config\FrameworkConfig;

return static function (FrameworkConfig $framework): void {
    // append the client cert to the scoped client
    $framework->httpClient()->scopedClient('account.server.client')
        ->baseUri('%env(ACCOUNT_SERVER_BASEURI)%')
        ->passphrase('%env(ACCOUNT_SERVER_CLIENT_PASSPHRASE)%')
        ->extra([
            'curl' => [
                CURLOPT_SSLCERT_BLOB => '%env(base64::ACCOUNT_SERVER_CLIENT_SSLCERT)%',
                CURLOPT_SSLKEY_BLOB => '%env(base64::ACCOUNT_SERVER_CLIENT_SSLCERT)%',
            ],
        ])
    ;

The message from PHPStan is:

Parameter #1 $value of method Symfony\Config\Framework\HttpClient\ScopedClientConfig::extra() expects list|Symfony\Component\Config\Loader\ParamConfigurator, array{curl: array{40291: '%env(base64:…', 40292: '%env(base64:…'}} given.
💡 Type #1 from the union: array{curl: array{40291: '%env(base64:…', 40292: '%env(base64:…'}} is not a list.

I think the proper typehint would be @param ParamConfigurator|array<ParamConfigurator|mixed> $value because list expects the array to be sequential integer keys starting at 0. This is all generated code so I'm not quite sure where the fix would be needed as I'm not familiar with that part of the codebase.

How to reproduce

To repro ensure PHPStan in installed and add the following contents to app/config/packages/framework.php:

<?php
// config/packages/framework.php
use Symfony\Config\FrameworkConfig;

return static function (FrameworkConfig $framework): void {
    // append the client cert to the scoped client
    $framework->httpClient()->scopedClient('account.server.client')
        ->baseUri('http://google.com/')
        ->passphrase('PASSWORD')
        ->extra([
            'curl' => [
                CURLOPT_SSLCERT_BLOB => 'CERT',
                CURLOPT_SSLKEY_BLOB => 'KEY',
            ],
        ])
    ;
};

Possible Solution

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.