Skip to content

Documentation mismatch: HttpTransporter constructor requires 5 arguments in v2.6.0, but README shows only 3 #169

@ahilespelid

Description

@ahilespelid

Describe the issue

In version 2.6.0 the constructor of Gemini\Transporters\HttpTransporter actually requires 5 arguments, but:

  • The README.md shows only 3 arguments:
  $transporter = new HttpTransporter($guzzle, $apiKey, $headers);

The source code in 2.6.0 clearly shows 5 parameters:PHP

public function __construct(
    ClientInterface $client,
    string $baseUri,
    string $apiKey,
    array $headers = [],
    ?Closure $streamHandler = null
)

Especially confusing:

The 5th argument is a Closure (?Closure $streamHandler = null), which is not mentioned anywhere in the documentation or examples.
Passing only 3 arguments results in ArgumentCountError: Too few arguments ... exactly 5 expected.
There is no mention of $streamHandler being a Closure in README, examples, or changelog.

Expected behavior
Documentation (README, examples) should match the actual constructor signature for the tagged version (2.6.0).
Either:

Update README to show correct 5-argument call (with optional Closure)
Or explain that Closure is optional and can be null
Or add a convenience factory method like in later versions

Actual behavior
Users following README get fatal error on constructor call.
Environment

Package version: 2.6.0 (composer show google-gemini-php/client)
PHP: 8.1+
Relevant code: new HttpTransporter($guzzle, $apiKey, [])

Suggested fix

Add note in README:Note: in v2.6.0 HttpTransporter requires 5 arguments. The 5th is optional Closure for stream handling (can be null).
Example:PHP$transporter = new HttpTransporter($guzzle, 'https://generativelanguage.googleapis.com/v1beta/', $apiKey, [], null);
Or backport Client::make() from 2.7+ to simplify creation.

Thanks for the great package — just a documentation gap that trips people up when pinning to 2.6.0.

The working version

$transporter = new HttpTransporter(
    $guzzle,                                      	   // 1. ClientInterface
    'https://generativelanguage.googleapis.com/v1beta/', // 2. baseUri (строка)
    $api_key,                                     	   // 3. apiKey (строка)
    [],                                           	   // 4. headers (массив)
    null                                          	   // 5. streamHandler (Closure или null)
);
Image Image

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