Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.121.0"
".": "0.121.1"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 232
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-4615e5953fac5a76724144fc2e1f9f675a9722dc05adaeab23e4d09c9577086b.yml
openapi_spec_hash: 6db98497c4dda09b575d5ee12371ef83
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-0482ee5f9cf2cd09691221500b562dab1092df43e774e92b714ccebebf618b1b.yml
openapi_spec_hash: 3f1b98e772d86cca81fa3186198a6937
config_hash: b24ba63471a818520cec39b4695e1825
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.121.1 (2026-04-25)

Full Changelog: [v0.121.0...v0.121.1](https://github.com/Increase/increase-php/compare/v0.121.0...v0.121.1)

### Bug Fixes

* revert enum parsing change that lead to unconditional failure ([c7d0ee8](https://github.com/Increase/increase-php/commit/c7d0ee80af07ef8dfcfcda54883400efae1e49ab))

## 0.121.0 (2026-04-22)

Full Changelog: [v0.120.0...v0.121.0](https://github.com/Increase/increase-php/compare/v0.120.0...v0.121.0)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The REST API documentation can be found on [increase.com](https://increase.com/d
<!-- x-release-please-start-version -->

```
composer require "increase/increase 0.121.0"
composer require "increase/increase 0.121.1"
```

<!-- x-release-please-end -->
Expand Down
20 changes: 3 additions & 17 deletions src/Core/Conversion/EnumOf.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@ final class EnumOf implements Converter

/**
* @param list<bool|float|int|string|null> $members
* @param class-string<\BackedEnum>|null $class
*/
public function __construct(
private readonly array $members,
private readonly ?string $class = null,
) {
public function __construct(private readonly array $members)
{
$type = 'NULL';
foreach ($this->members as $member) {
$type = gettype($member);
Expand All @@ -36,24 +33,13 @@ public function __construct(
public static function fromBackedEnum(string $enum): self
{
// @phpstan-ignore-next-line argument.type
return self::$cache[$enum] ??= new self(
array_column($enum::cases(), column_key: 'value'),
class: $enum,
);
return self::$cache[$enum] ??= new self(array_column($enum::cases(), column_key: 'value'));
}

public function coerce(mixed $value, CoerceState $state): mixed
{
$this->tally($value, state: $state);

if ($value instanceof \BackedEnum) {
return $value;
}

if (null !== $this->class && (is_int($value) || is_string($value))) {
return ($this->class)::tryFrom($value) ?? $value;
}

return $value;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
namespace Increase;

// x-release-please-start-version
const VERSION = '0.121.0';
const VERSION = '0.121.1';
// x-release-please-end
62 changes: 0 additions & 62 deletions tests/Core/ModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,30 +47,6 @@ public function __construct(
}
}

enum TicketPriority: string
{
case Low = 'low';
case High = 'high';
}

class Ticket implements BaseModel
{
/** @use SdkModel<array<string, mixed>> */
use SdkModel;

#[Required(enum: TicketPriority::class)]
public TicketPriority $priority;

/** @var list<TicketPriority> */
#[Required(list: TicketPriority::class)]
public array $labels;

public function __construct()
{
$this->initialize();
}
}

/**
* @internal
*
Expand Down Expand Up @@ -165,42 +141,4 @@ public function testSerializeModelWithExplicitNull(): void
json_encode($model)
);
}

#[Test]
public function testScalarEnumCoercesToInstance(): void
{
$model = Ticket::fromArray(['priority' => 'low', 'labels' => []]);
$this->assertSame(TicketPriority::Low, $model->priority);
}

#[Test]
public function testListOfEnumCoercesElementsToInstances(): void
{
$model = Ticket::fromArray(['priority' => 'low', 'labels' => ['low', 'high']]);
$this->assertCount(2, $model->labels);
$this->assertSame(TicketPriority::Low, $model->labels[0]);
$this->assertSame(TicketPriority::High, $model->labels[1]);
}

#[Test]
public function testEnumInstancePassesThrough(): void
{
$model = Ticket::fromArray(['priority' => TicketPriority::High, 'labels' => []]);
$this->assertSame(TicketPriority::High, $model->priority);
}

#[Test]
public function testInvalidEnumScalarFallsBackToData(): void
{
$model = Ticket::fromArray(['priority' => 'urgent', 'labels' => []]);
$this->assertSame('urgent', $model['priority']);
}

#[Test]
public function testEnumWireFormatStableAcrossConstruction(): void
{
$fromScalar = Ticket::fromArray(['priority' => 'low', 'labels' => ['high']]);
$fromInstance = Ticket::fromArray(['priority' => TicketPriority::Low, 'labels' => [TicketPriority::High]]);
$this->assertSame(json_encode($fromScalar), json_encode($fromInstance));
}
}