Skip to content

Commit 37d53e4

Browse files
committed
Replace readonly keyword on classes with readonly properties for BC promise
1 parent 8139bd8 commit 37d53e4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+250
-250
lines changed

src/agent/src/Agent.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,29 @@
2121
/**
2222
* @author Christopher Hertel <[email protected]>
2323
*/
24-
final readonly class Agent implements AgentInterface
24+
final class Agent implements AgentInterface
2525
{
2626
/**
2727
* @var InputProcessorInterface[]
2828
*/
29-
private array $inputProcessors;
29+
private readonly array $inputProcessors;
3030

3131
/**
3232
* @var OutputProcessorInterface[]
3333
*/
34-
private array $outputProcessors;
34+
private readonly array $outputProcessors;
3535

3636
/**
3737
* @param InputProcessorInterface[] $inputProcessors
3838
* @param OutputProcessorInterface[] $outputProcessors
3939
* @param non-empty-string $model
4040
*/
4141
public function __construct(
42-
private PlatformInterface $platform,
43-
private string $model,
42+
private readonly PlatformInterface $platform,
43+
private readonly string $model,
4444
iterable $inputProcessors = [],
4545
iterable $outputProcessors = [],
46-
private string $name = 'agent',
46+
private readonly string $name = 'agent',
4747
) {
4848
$this->inputProcessors = $this->initializeProcessors($inputProcessors, InputProcessorInterface::class);
4949
$this->outputProcessors = $this->initializeProcessors($outputProcessors, OutputProcessorInterface::class);

src/agent/src/Attribute/AsInputProcessor.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
* @author Vincent Langlet <[email protected]>
1616
*/
1717
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)]
18-
final readonly class AsInputProcessor
18+
final class AsInputProcessor
1919
{
2020
/**
2121
* @param string|null $agent the service id of the agent which will use this processor,
2222
* null to register this processor for all existing agents
2323
*/
2424
public function __construct(
25-
public ?string $agent = null,
26-
public int $priority = 0,
25+
public readonly ?string $agent = null,
26+
public readonly int $priority = 0,
2727
) {
2828
}
2929
}

src/agent/src/Attribute/AsOutputProcessor.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
* @author Vincent Langlet <[email protected]>
1616
*/
1717
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)]
18-
final readonly class AsOutputProcessor
18+
final class AsOutputProcessor
1919
{
2020
/**
2121
* @param string|null $agent the service id of the agent which will use this processor,
2222
* null to register this processor for all existing agents
2323
*/
2424
public function __construct(
25-
public ?string $agent = null,
26-
public int $priority = 0,
25+
public readonly ?string $agent = null,
26+
public readonly int $priority = 0,
2727
) {
2828
}
2929
}

src/agent/src/InputProcessor/SystemPromptInputProcessor.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@
2626
/**
2727
* @author Christopher Hertel <[email protected]>
2828
*/
29-
final readonly class SystemPromptInputProcessor implements InputProcessorInterface
29+
final class SystemPromptInputProcessor implements InputProcessorInterface
3030
{
3131
/**
3232
* @param \Stringable|TranslatableInterface|string|File $systemPrompt the system prompt to prepend to the input messages, or a File object to read from
3333
* @param ToolboxInterface|null $toolbox the tool box to be used to append the tool definitions to the system prompt
3434
*/
3535
public function __construct(
36-
private \Stringable|TranslatableInterface|string|File $systemPrompt,
37-
private ?ToolboxInterface $toolbox = null,
38-
private ?TranslatorInterface $translator = null,
39-
private LoggerInterface $logger = new NullLogger(),
36+
private readonly \Stringable|TranslatableInterface|string|File $systemPrompt,
37+
private readonly ?ToolboxInterface $toolbox = null,
38+
private readonly ?TranslatorInterface $translator = null,
39+
private readonly LoggerInterface $logger = new NullLogger(),
4040
) {
4141
if ($this->systemPrompt instanceof TranslatableInterface && !$this->translator) {
4242
throw new RuntimeException('Translatable system prompt is not supported when no translator is provided.');

src/agent/src/Memory/EmbeddingProvider.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
/**
2424
* @author Denis Zunke <[email protected]>
2525
*/
26-
final readonly class EmbeddingProvider implements MemoryProviderInterface
26+
final class EmbeddingProvider implements MemoryProviderInterface
2727
{
2828
public function __construct(
29-
private PlatformInterface $platform,
30-
private Model $model,
31-
private StoreInterface $vectorStore,
29+
private readonly PlatformInterface $platform,
30+
private readonly Model $model,
31+
private readonly StoreInterface $vectorStore,
3232
) {
3333
}
3434

src/agent/src/Memory/Memory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
/**
1515
* @author Denis Zunke <[email protected]>
1616
*/
17-
final readonly class Memory
17+
final class Memory
1818
{
1919
public function __construct(
20-
private string $content,
20+
private readonly string $content,
2121
) {
2222
}
2323

src/agent/src/Memory/MemoryInputProcessor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
/**
1919
* @author Denis Zunke <[email protected]>
2020
*/
21-
final readonly class MemoryInputProcessor implements InputProcessorInterface
21+
final class MemoryInputProcessor implements InputProcessorInterface
2222
{
2323
private const MEMORY_PROMPT_MESSAGE = <<<MARKDOWN
2424
# Conversation Memory
@@ -31,7 +31,7 @@
3131
/**
3232
* @var MemoryProviderInterface[]
3333
*/
34-
private array $memoryProviders;
34+
private readonly array $memoryProviders;
3535

3636
public function __construct(
3737
MemoryProviderInterface ...$memoryProviders,

src/agent/src/Memory/StaticMemoryProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
/**
1717
* @author Denis Zunke <[email protected]>
1818
*/
19-
final readonly class StaticMemoryProvider implements MemoryProviderInterface
19+
final class StaticMemoryProvider implements MemoryProviderInterface
2020
{
2121
/**
2222
* @var array<string>
2323
*/
24-
private array $memory;
24+
private readonly array $memory;
2525

2626
public function __construct(string ...$memory)
2727
{

src/agent/src/MultiAgent/Handoff.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
*
2020
* @author Oskar Stark <[email protected]>
2121
*/
22-
final readonly class Handoff
22+
final class Handoff
2323
{
2424
/**
2525
* @param string[] $when Keywords or phrases that indicate this handoff
2626
*/
2727
public function __construct(
28-
private AgentInterface $to,
29-
private array $when,
28+
private readonly AgentInterface $to,
29+
private readonly array $when,
3030
) {
3131
if ([] === $when) {
3232
throw new InvalidArgumentException('Handoff must have at least one "when" condition.');

src/agent/src/MultiAgent/Handoff/Decision.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616
*
1717
* @author Oskar Stark <[email protected]>
1818
*/
19-
final readonly class Decision
19+
final class Decision
2020
{
2121
/**
2222
* @param string $agentName The name of the selected agent, or empty string if no specific agent is selected
2323
* @param string $reasoning The reasoning behind the selection
2424
*/
2525
public function __construct(
26-
private string $agentName,
27-
private string $reasoning = 'No reasoning provided',
26+
private readonly string $agentName,
27+
private readonly string $reasoning = 'No reasoning provided',
2828
) {
2929
}
3030

0 commit comments

Comments
 (0)