Skip to content

fix: build Stripe's default client from utopia-php/client 0.5's Client - #34

Merged
ChiragAgg5k merged 3 commits into
mainfrom
fix/client-05-names
Sep 25, 2026
Merged

ChiragAgg5k merged 3 commits into
mainfrom
fix/client-05-names

Conversation

@abnegate

Copy link
Copy Markdown
Member

Summary

  • The Stripe adapter now imports Utopia\Client\Client, the name utopia-php/client 0.5 gives its client, instead of the pre-0.5 Utopia\Client. Stripe::__construct() builds its default client from that import (src/Pay/Adapter/Stripe.php:37).
  • composer.json requires utopia-php/client: ^0.5 (was ^0.4). 0.4.x has no Utopia\Client\Client.
  • The lock moves only utopia-php/client, from 0.4.3 to 0.5.1.
  • A new offline test, StripeTest::testConstructsWithoutAClient, constructs the adapter without a client.
  • StripeTest cleanup: setUp() reads the secret with getenv('STRIPE_SECRET') ?: '' instead of calling getenv() twice in a ternary, and testName passes assertEquals its expected value first.

Why

utopia-php/client 0.5 moved Utopia\Client to Utopia\Client\Client. Releases 0.5.0 and 0.5.1 keep the old name only as a class_alias in src/compat.php. Client main (3216469) has removed that file, so the next client release will not have the alias. appwrite's server-ce (appwrite/server-ce) replaces utopia-php/client with its in-repo packages/client, which has dropped the alias as well. Wherever the alias is missing, new Stripe($secretKey) without a client fails:

Error: Class "Utopia\Client" not found
src/Pay/Adapter/Stripe.php:37

Callers that pass their own client: never reach that line, so only code that relies on the default client breaks.

Verification

Results of the new test, with the old import and with this PR's:

Client installed Old import (use Utopia\Client;) This PR (use Utopia\Client\Client;)
0.5.1, what ^0.5 locks OK (1 test, 2 assertions): the alias masks the old name OK (1 test, 2 assertions)
dev-main 3216469, alias-free Error: Class "Utopia\Client" not found at Stripe.php:37, raised from setUp() (StripeTest.php:16) OK (1 test, 2 assertions)

The alias-free row ran in a scratch copy after composer require 'utopia-php/client:dev-main as 0.5.1'. This branch locks 0.5.1, where the old import still passes. Once the lock takes a client release without the alias, the test fails if the old name comes back.

  • composer validate --strict reports the file valid, and composer lint passes on 14 files.
  • The offline suites on PHP 8.5.10 are unchanged. CreditTest, DiscountTest and InvoiceTest give 45 tests and 187 assertions. StripeTest's testName and the new test give 2 tests and 3 assertions.
  • composer check still crashes on PHP 8.5 inside the locked PHPStan 1.9.x-dev, as chore: upgrade Utopia Client to ^0.4 #33 noted. A standalone PHPStan 2.2.2 at level 8 reports 46 findings before this PR and 45 after, none of them new. The dropped one is argument.type at StripeTest.php:17: the ternary passed string|false to the Stripe constructor.
  • The live Stripe suite needs STRIPE_SECRET, so it runs in CI only. It builds the adapter without a client, so its requests go through the default client.

Release

This needs 0.15.0 after merge, because it raises the utopia-php/client floor from 0.4 to 0.5.

🤖 Generated with Claude Code

abnegate and others added 2 commits September 26, 2026 00:11
utopia-php/client 0.5 moved Utopia\Client to Utopia\Client\Client and
keeps the old name only as a class_alias that its next release drops.
The Stripe adapter still imported the old name, so constructing it
without a client fails with 'Class "Utopia\Client" not found' wherever
the alias is absent: under appwrite's server-ce, which replaces
utopia-php/client with its own alias-free copy, and with the client's
next release. Import the new name and require ^0.5, the first releases
that declare it.

The regression test constructs the adapter without a client, offline.
On the locked client 0.5.1 the alias hides the old import, so the test
fails first only against an alias-free client (client main).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cted value first

getenv() returns string|false, never null, so ?: covers an unset or
empty variable in one call. The ternary called getenv() twice, and
PHPStan could not narrow the second call, so it reported the
constructor argument as string|false. assertEquals takes the expected
value first; with the arguments swapped, a failure would report
'Stripe' as the actual value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[High risk] Updates HTTP client library with namespace changes.

The PR appears safe to merge.

Summary

The PR updates Stripe’s default-client import and raises the client dependency to 0.5. It also adds an offline construction check and removes implementation-coupled assertions from that check.

Reviews (2) · Last reviewed commit: "(test): assert only that Stripe construc..."

Comment thread tests/Pay/Adapter/StripeTest.php Outdated
The getName() and getCurrency() checks repeated fixed values (testName
already covers the name) and never touched the HTTP client. Stripe
exposes nothing about its default client short of a request: the
client is private, and every API method sends to api.stripe.com. So
the test now pins only the regression, that construction without a
client does not throw, and declares that it performs no assertions.
CI's live suite already sends requests through the default client.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ChiragAgg5k
ChiragAgg5k merged commit a0ee8db into main Sep 25, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants