Skip to content

MistralConversation: Uninitialized typed properties cause errors on fresh instances #84

@petarbasic

Description

@petarbasic

When creating a new MistralConversation via the empty constructor and then calling toArray() or any getter, PHP throws a "Typed property must not be accessed before initialization" error.

The constructor is empty, but several nullable/typed properties like $name, $description, $model, $stop, $temperature, $toolChoice etc. have no default values. They only get initialized through fromArray(), which means freshly constructed instances break immediately.

Steps to reproduce:

  $conversation = new MistralConversation();
  $conversation->setAgentId('some-agent-id');
  $conversation->toArray(); // TypeError: must not be accessed before initialization

Fix: Add default values to all property declarations, matching the defaults already used in fromArray() (temperature = 0.3, toolChoice = 'auto', everything else null).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions