fix: build Stripe's default client from utopia-php/client 0.5's Client - #34
Merged
Merged
Conversation
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>
|
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
approved these changes
Sep 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Utopia\Client\Client, the name utopia-php/client 0.5 gives its client, instead of the pre-0.5Utopia\Client.Stripe::__construct()builds its default client from that import (src/Pay/Adapter/Stripe.php:37).composer.jsonrequiresutopia-php/client: ^0.5(was^0.4). 0.4.x has noUtopia\Client\Client.utopia-php/client, from 0.4.3 to 0.5.1.StripeTest::testConstructsWithoutAClient, constructs the adapter without a client.StripeTestcleanup:setUp()reads the secret withgetenv('STRIPE_SECRET') ?: ''instead of callinggetenv()twice in a ternary, andtestNamepassesassertEqualsits expected value first.Why
utopia-php/client 0.5 moved
Utopia\ClienttoUtopia\Client\Client. Releases 0.5.0 and 0.5.1 keep the old name only as aclass_aliasinsrc/compat.php. Clientmain(3216469) has removed that file, so the next client release will not have the alias. appwrite's server-ce (appwrite/server-ce) replacesutopia-php/clientwith its in-repopackages/client, which has dropped the alias as well. Wherever the alias is missing,new Stripe($secretKey)without a client fails: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:
use Utopia\Client;)use Utopia\Client\Client;)^0.5locksOK (1 test, 2 assertions): the alias masks the old nameOK (1 test, 2 assertions)dev-main3216469, alias-freeError: Class "Utopia\Client" not foundatStripe.php:37, raised fromsetUp()(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 --strictreports the file valid, andcomposer lintpasses on 14 files.CreditTest,DiscountTestandInvoiceTestgive 45 tests and 187 assertions.StripeTest'stestNameand the new test give 2 tests and 3 assertions.composer checkstill 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 isargument.typeatStripeTest.php:17: the ternary passedstring|falseto theStripeconstructor.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/clientfloor from 0.4 to 0.5.🤖 Generated with Claude Code