Skip to content

Commit

Permalink
Replaced all cases of explicit class strings with the SomeClass:class…
Browse files Browse the repository at this point in the history
… constant available in 5.6.
  • Loading branch information
nickdnk authored and ob-stripe committed Aug 2, 2019
1 parent 4b2be0e commit e573ad2
Show file tree
Hide file tree
Showing 72 changed files with 411 additions and 411 deletions.
8 changes: 4 additions & 4 deletions lib/ApiOperations/All.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ public static function all($params = null, $opts = null)

list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
if (!is_a($obj, 'Stripe\\Collection')) {
$class = get_class($obj);
$message = "Expected type \"Stripe\\Collection\", got \"$class\" instead";
throw new \Stripe\Error\Api($message);
if (!($obj instanceof \Stripe\Collection)) {
throw new \Stripe\Error\Api(
'Expected type ' . \Stripe\Collection::class . ', got "' . get_class($obj) . '" instead.'
);
}
$obj->setLastResponse($response);
$obj->setRequestParams($params);
Expand Down
162 changes: 81 additions & 81 deletions lib/Util/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,88 +67,88 @@ public static function convertToStripeObject($resp, $opts)
{
$types = [
// data structures
\Stripe\Collection::OBJECT_NAME => 'Stripe\\Collection',
\Stripe\Collection::OBJECT_NAME => \Stripe\Collection::class,

// business objects
\Stripe\Account::OBJECT_NAME => 'Stripe\\Account',
\Stripe\AccountLink::OBJECT_NAME => 'Stripe\\AccountLink',
\Stripe\AlipayAccount::OBJECT_NAME => 'Stripe\\AlipayAccount',
\Stripe\ApplePayDomain::OBJECT_NAME => 'Stripe\\ApplePayDomain',
\Stripe\ApplicationFee::OBJECT_NAME => 'Stripe\\ApplicationFee',
\Stripe\Balance::OBJECT_NAME => 'Stripe\\Balance',
\Stripe\BalanceTransaction::OBJECT_NAME => 'Stripe\\BalanceTransaction',
\Stripe\BankAccount::OBJECT_NAME => 'Stripe\\BankAccount',
\Stripe\BitcoinReceiver::OBJECT_NAME => 'Stripe\\BitcoinReceiver',
\Stripe\BitcoinTransaction::OBJECT_NAME => 'Stripe\\BitcoinTransaction',
\Stripe\Capability::OBJECT_NAME => 'Stripe\\Capability',
\Stripe\Card::OBJECT_NAME => 'Stripe\\Card',
\Stripe\Charge::OBJECT_NAME => 'Stripe\\Charge',
\Stripe\Checkout\Session::OBJECT_NAME => 'Stripe\\Checkout\\Session',
\Stripe\CountrySpec::OBJECT_NAME => 'Stripe\\CountrySpec',
\Stripe\Coupon::OBJECT_NAME => 'Stripe\\Coupon',
\Stripe\CreditNote::OBJECT_NAME => 'Stripe\\CreditNote',
\Stripe\Customer::OBJECT_NAME => 'Stripe\\Customer',
\Stripe\CustomerBalanceTransaction::OBJECT_NAME => 'Stripe\\CustomerBalanceTransaction',
\Stripe\Discount::OBJECT_NAME => 'Stripe\\Discount',
\Stripe\Dispute::OBJECT_NAME => 'Stripe\\Dispute',
\Stripe\EphemeralKey::OBJECT_NAME => 'Stripe\\EphemeralKey',
\Stripe\Event::OBJECT_NAME => 'Stripe\\Event',
\Stripe\ExchangeRate::OBJECT_NAME => 'Stripe\\ExchangeRate',
\Stripe\ApplicationFeeRefund::OBJECT_NAME => 'Stripe\\ApplicationFeeRefund',
\Stripe\File::OBJECT_NAME => 'Stripe\\File',
\Stripe\File::OBJECT_NAME_ALT => 'Stripe\\File',
\Stripe\FileLink::OBJECT_NAME => 'Stripe\\FileLink',
\Stripe\Invoice::OBJECT_NAME => 'Stripe\\Invoice',
\Stripe\InvoiceItem::OBJECT_NAME => 'Stripe\\InvoiceItem',
\Stripe\InvoiceLineItem::OBJECT_NAME => 'Stripe\\InvoiceLineItem',
\Stripe\IssuerFraudRecord::OBJECT_NAME => 'Stripe\\IssuerFraudRecord',
\Stripe\Issuing\Authorization::OBJECT_NAME => 'Stripe\\Issuing\\Authorization',
\Stripe\Issuing\Card::OBJECT_NAME => 'Stripe\\Issuing\\Card',
\Stripe\Issuing\CardDetails::OBJECT_NAME => 'Stripe\\Issuing\\CardDetails',
\Stripe\Issuing\Cardholder::OBJECT_NAME => 'Stripe\\Issuing\\Cardholder',
\Stripe\Issuing\Dispute::OBJECT_NAME => 'Stripe\\Issuing\\Dispute',
\Stripe\Issuing\Transaction::OBJECT_NAME => 'Stripe\\Issuing\\Transaction',
\Stripe\LoginLink::OBJECT_NAME => 'Stripe\\LoginLink',
\Stripe\Order::OBJECT_NAME => 'Stripe\\Order',
\Stripe\OrderItem::OBJECT_NAME => 'Stripe\\OrderItem',
\Stripe\OrderReturn::OBJECT_NAME => 'Stripe\\OrderReturn',
\Stripe\PaymentIntent::OBJECT_NAME => 'Stripe\\PaymentIntent',
\Stripe\PaymentMethod::OBJECT_NAME => 'Stripe\\PaymentMethod',
\Stripe\Payout::OBJECT_NAME => 'Stripe\\Payout',
\Stripe\Person::OBJECT_NAME => 'Stripe\\Person',
\Stripe\Plan::OBJECT_NAME => 'Stripe\\Plan',
\Stripe\Product::OBJECT_NAME => 'Stripe\\Product',
\Stripe\Radar\EarlyFraudWarning::OBJECT_NAME => 'Stripe\\Radar\\EarlyFraudWarning',
\Stripe\Radar\ValueList::OBJECT_NAME => 'Stripe\\Radar\\ValueList',
\Stripe\Radar\ValueListItem::OBJECT_NAME => 'Stripe\\Radar\\ValueListItem',
\Stripe\Recipient::OBJECT_NAME => 'Stripe\\Recipient',
\Stripe\RecipientTransfer::OBJECT_NAME => 'Stripe\\RecipientTransfer',
\Stripe\Refund::OBJECT_NAME => 'Stripe\\Refund',
\Stripe\Reporting\ReportRun::OBJECT_NAME => 'Stripe\\Reporting\\ReportRun',
\Stripe\Reporting\ReportType::OBJECT_NAME => 'Stripe\\Reporting\\ReportType',
\Stripe\Review::OBJECT_NAME => 'Stripe\\Review',
\Stripe\SetupIntent::OBJECT_NAME => 'Stripe\\SetupIntent',
\Stripe\SKU::OBJECT_NAME => 'Stripe\\SKU',
\Stripe\Sigma\ScheduledQueryRun::OBJECT_NAME => 'Stripe\\Sigma\\ScheduledQueryRun',
\Stripe\Source::OBJECT_NAME => 'Stripe\\Source',
\Stripe\SourceTransaction::OBJECT_NAME => 'Stripe\\SourceTransaction',
\Stripe\Subscription::OBJECT_NAME => 'Stripe\\Subscription',
\Stripe\SubscriptionItem::OBJECT_NAME => 'Stripe\\SubscriptionItem',
\Stripe\SubscriptionSchedule::OBJECT_NAME => 'Stripe\\SubscriptionSchedule',
\Stripe\SubscriptionScheduleRevision::OBJECT_NAME => 'Stripe\\SubscriptionScheduleRevision',
\Stripe\TaxId::OBJECT_NAME => 'Stripe\\TaxId',
\Stripe\TaxRate::OBJECT_NAME => 'Stripe\\TaxRate',
\Stripe\ThreeDSecure::OBJECT_NAME => 'Stripe\\ThreeDSecure',
\Stripe\Terminal\ConnectionToken::OBJECT_NAME => 'Stripe\\Terminal\\ConnectionToken',
\Stripe\Terminal\Location::OBJECT_NAME => 'Stripe\\Terminal\\Location',
\Stripe\Terminal\Reader::OBJECT_NAME => 'Stripe\\Terminal\\Reader',
\Stripe\Token::OBJECT_NAME => 'Stripe\\Token',
\Stripe\Topup::OBJECT_NAME => 'Stripe\\Topup',
\Stripe\Transfer::OBJECT_NAME => 'Stripe\\Transfer',
\Stripe\TransferReversal::OBJECT_NAME => 'Stripe\\TransferReversal',
\Stripe\UsageRecord::OBJECT_NAME => 'Stripe\\UsageRecord',
\Stripe\UsageRecordSummary::OBJECT_NAME => 'Stripe\\UsageRecordSummary',
\Stripe\WebhookEndpoint::OBJECT_NAME => 'Stripe\\WebhookEndpoint',
\Stripe\Account::OBJECT_NAME => \Stripe\Account::class,
\Stripe\AccountLink::OBJECT_NAME => \Stripe\AccountLink::class,
\Stripe\AlipayAccount::OBJECT_NAME => \Stripe\AlipayAccount::class,
\Stripe\ApplePayDomain::OBJECT_NAME => \Stripe\ApplePayDomain::class,
\Stripe\ApplicationFee::OBJECT_NAME => \Stripe\ApplicationFee::class,
\Stripe\ApplicationFeeRefund::OBJECT_NAME => \Stripe\ApplicationFeeRefund::class,
\Stripe\Balance::OBJECT_NAME => \Stripe\Balance::class,
\Stripe\BalanceTransaction::OBJECT_NAME => \Stripe\BalanceTransaction::class,
\Stripe\BankAccount::OBJECT_NAME => \Stripe\BankAccount::class,
\Stripe\BitcoinReceiver::OBJECT_NAME => \Stripe\BitcoinReceiver::class,
\Stripe\BitcoinTransaction::OBJECT_NAME => \Stripe\BitcoinTransaction::class,
\Stripe\Capability::OBJECT_NAME => \Stripe\Capability::class,
\Stripe\Card::OBJECT_NAME => \Stripe\Card::class,
\Stripe\Charge::OBJECT_NAME => \Stripe\Charge::class,
\Stripe\Checkout\Session::OBJECT_NAME => \Stripe\Checkout\Session::class,
\Stripe\CountrySpec::OBJECT_NAME => \Stripe\CountrySpec::class,
\Stripe\Coupon::OBJECT_NAME => \Stripe\Coupon::class,
\Stripe\CreditNote::OBJECT_NAME => \Stripe\CreditNote::class,
\Stripe\Customer::OBJECT_NAME => \Stripe\Customer::class,
\Stripe\CustomerBalanceTransaction::OBJECT_NAME => \Stripe\CustomerBalanceTransaction::class,
\Stripe\Discount::OBJECT_NAME => \Stripe\Discount::class,
\Stripe\Dispute::OBJECT_NAME => \Stripe\Dispute::class,
\Stripe\EphemeralKey::OBJECT_NAME => \Stripe\EphemeralKey::class,
\Stripe\Event::OBJECT_NAME => \Stripe\Event::class,
\Stripe\ExchangeRate::OBJECT_NAME => \Stripe\ExchangeRate::class,
\Stripe\File::OBJECT_NAME => \Stripe\File::class,
\Stripe\File::OBJECT_NAME_ALT => \Stripe\File::class,
\Stripe\FileLink::OBJECT_NAME => \Stripe\FileLink::class,
\Stripe\Invoice::OBJECT_NAME => \Stripe\Invoice::class,
\Stripe\InvoiceItem::OBJECT_NAME => \Stripe\InvoiceItem::class,
\Stripe\InvoiceLineItem::OBJECT_NAME => \Stripe\InvoiceLineItem::class,
\Stripe\IssuerFraudRecord::OBJECT_NAME => \Stripe\IssuerFraudRecord::class,
\Stripe\Issuing\Authorization::OBJECT_NAME => \Stripe\Issuing\Authorization::class,
\Stripe\Issuing\Card::OBJECT_NAME => \Stripe\Issuing\Card::class,
\Stripe\Issuing\CardDetails::OBJECT_NAME => \Stripe\Issuing\CardDetails::class,
\Stripe\Issuing\Cardholder::OBJECT_NAME => \Stripe\Issuing\Cardholder::class,
\Stripe\Issuing\Dispute::OBJECT_NAME => \Stripe\Issuing\Dispute::class,
\Stripe\Issuing\Transaction::OBJECT_NAME => \Stripe\Issuing\Transaction::class,
\Stripe\LoginLink::OBJECT_NAME => \Stripe\LoginLink::class,
\Stripe\Order::OBJECT_NAME => \Stripe\Order::class,
\Stripe\OrderItem::OBJECT_NAME => \Stripe\OrderItem::class,
\Stripe\OrderReturn::OBJECT_NAME => \Stripe\OrderReturn::class,
\Stripe\PaymentIntent::OBJECT_NAME => \Stripe\PaymentIntent::class,
\Stripe\PaymentMethod::OBJECT_NAME => \Stripe\PaymentMethod::class,
\Stripe\Payout::OBJECT_NAME => \Stripe\Payout::class,
\Stripe\Person::OBJECT_NAME => \Stripe\Person::class,
\Stripe\Plan::OBJECT_NAME => \Stripe\Plan::class,
\Stripe\Product::OBJECT_NAME => \Stripe\Product::class,
\Stripe\Radar\EarlyFraudWarning::OBJECT_NAME => \Stripe\Radar\EarlyFraudWarning::class,
\Stripe\Radar\ValueList::OBJECT_NAME => \Stripe\Radar\ValueList::class,
\Stripe\Radar\ValueListItem::OBJECT_NAME => \Stripe\Radar\ValueListItem::class,
\Stripe\Recipient::OBJECT_NAME => \Stripe\Recipient::class,
\Stripe\RecipientTransfer::OBJECT_NAME => \Stripe\RecipientTransfer::class,
\Stripe\Refund::OBJECT_NAME => \Stripe\Refund::class,
\Stripe\Reporting\ReportRun::OBJECT_NAME => \Stripe\Reporting\ReportRun::class,
\Stripe\Reporting\ReportType::OBJECT_NAME => \Stripe\Reporting\ReportType::class,
\Stripe\Review::OBJECT_NAME => \Stripe\Review::class,
\Stripe\SetupIntent::OBJECT_NAME => \Stripe\SetupIntent::class,
\Stripe\Sigma\ScheduledQueryRun::OBJECT_NAME => \Stripe\Sigma\ScheduledQueryRun::class,
\Stripe\SKU::OBJECT_NAME => \Stripe\SKU::class,
\Stripe\Source::OBJECT_NAME => \Stripe\Source::class,
\Stripe\SourceTransaction::OBJECT_NAME => \Stripe\SourceTransaction::class,
\Stripe\Subscription::OBJECT_NAME => \Stripe\Subscription::class,
\Stripe\SubscriptionItem::OBJECT_NAME => \Stripe\SubscriptionItem::class,
\Stripe\SubscriptionSchedule::OBJECT_NAME => \Stripe\SubscriptionSchedule::class,
\Stripe\SubscriptionScheduleRevision::OBJECT_NAME => \Stripe\SubscriptionScheduleRevision::class,
\Stripe\TaxId::OBJECT_NAME => \Stripe\TaxId::class,
\Stripe\TaxRate::OBJECT_NAME => \Stripe\TaxRate::class,
\Stripe\ThreeDSecure::OBJECT_NAME => \Stripe\ThreeDSecure::class,
\Stripe\Terminal\ConnectionToken::OBJECT_NAME => \Stripe\Terminal\ConnectionToken::class,
\Stripe\Terminal\Location::OBJECT_NAME => \Stripe\Terminal\Location::class,
\Stripe\Terminal\Reader::OBJECT_NAME => \Stripe\Terminal\Reader::class,
\Stripe\Token::OBJECT_NAME => \Stripe\Token::class,
\Stripe\Topup::OBJECT_NAME => \Stripe\Topup::class,
\Stripe\Transfer::OBJECT_NAME => \Stripe\Transfer::class,
\Stripe\TransferReversal::OBJECT_NAME => \Stripe\TransferReversal::class,
\Stripe\UsageRecord::OBJECT_NAME => \Stripe\UsageRecord::class,
\Stripe\UsageRecordSummary::OBJECT_NAME => \Stripe\UsageRecordSummary::class,
\Stripe\WebhookEndpoint::OBJECT_NAME => \Stripe\WebhookEndpoint::class,
];
if (self::isList($resp)) {
$mapped = [];
Expand All @@ -160,7 +160,7 @@ public static function convertToStripeObject($resp, $opts)
if (isset($resp['object']) && is_string($resp['object']) && isset($types[$resp['object']])) {
$class = $types[$resp['object']];
} else {
$class = 'Stripe\\StripeObject';
$class = \Stripe\StripeObject::class;
}
return $class::constructFrom($resp, $opts);
} else {
Expand Down
2 changes: 1 addition & 1 deletion tests/Stripe/AccountLinkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ public function testIsCreatable()
"success_url" => "https://stripe.com/success",
"type" => "custom_account_verification",
]);
$this->assertInstanceOf("Stripe\\AccountLink", $resource);
$this->assertInstanceOf(\Stripe\AccountLink::class, $resource);
}
}
Loading

0 comments on commit e573ad2

Please sign in to comment.