Bump DataTable from 2.3.3 to 2.3.4, TinyMCE 8.0.2 to 8.2.0, Stripe-PHP 17.6.0 to 18.1.0, PHPMailer from 6.10.0 to 7.0.0, chartjs from 4.5.0 to 4.5.1

This commit is contained in:
johnnyq
2025-11-02 16:44:59 -05:00
parent 7ea39eb545
commit f733a27ad7
170 changed files with 2280 additions and 885 deletions

View File

@@ -6,6 +6,6 @@ namespace Stripe\Util;
class ApiVersion
{
const CURRENT = '2025-08-27.basil';
const CURRENT_MAJOR = 'basil';
const CURRENT = '2025-10-29.clover';
const CURRENT_MAJOR = 'clover';
}

View File

@@ -0,0 +1,14 @@
<?php
namespace Stripe\Util;
class EventNotificationTypes
{
const v2EventMapping = [
// The beginning of the section generated from our OpenAPI spec
\Stripe\Events\V1BillingMeterErrorReportTriggeredEventNotification::LOOKUP_TYPE => \Stripe\Events\V1BillingMeterErrorReportTriggeredEventNotification::class,
\Stripe\Events\V1BillingMeterNoMeterFoundEventNotification::LOOKUP_TYPE => \Stripe\Events\V1BillingMeterNoMeterFoundEventNotification::class,
\Stripe\Events\V2CoreEventDestinationPingEventNotification::LOOKUP_TYPE => \Stripe\Events\V2CoreEventDestinationPingEventNotification::class,
// The end of the section generated from our OpenAPI spec
];
}

View File

@@ -4,7 +4,7 @@ namespace Stripe\Util;
class EventTypes
{
const thinEventMapping = [
const v2EventMapping = [
// The beginning of the section generated from our OpenAPI spec
\Stripe\Events\V1BillingMeterErrorReportTriggeredEvent::LOOKUP_TYPE => \Stripe\Events\V1BillingMeterErrorReportTriggeredEvent::class,
\Stripe\Events\V1BillingMeterNoMeterFoundEvent::LOOKUP_TYPE => \Stripe\Events\V1BillingMeterNoMeterFoundEvent::class,

View File

@@ -23,6 +23,7 @@ class ObjectTypes
\Stripe\ApplicationFeeRefund::OBJECT_NAME => \Stripe\ApplicationFeeRefund::class,
\Stripe\Apps\Secret::OBJECT_NAME => \Stripe\Apps\Secret::class,
\Stripe\Balance::OBJECT_NAME => \Stripe\Balance::class,
\Stripe\BalanceSettings::OBJECT_NAME => \Stripe\BalanceSettings::class,
\Stripe\BalanceTransaction::OBJECT_NAME => \Stripe\BalanceTransaction::class,
\Stripe\BankAccount::OBJECT_NAME => \Stripe\BankAccount::class,
\Stripe\Billing\Alert::OBJECT_NAME => \Stripe\Billing\Alert::class,
@@ -89,11 +90,14 @@ class ObjectTypes
\Stripe\LineItem::OBJECT_NAME => \Stripe\LineItem::class,
\Stripe\LoginLink::OBJECT_NAME => \Stripe\LoginLink::class,
\Stripe\Mandate::OBJECT_NAME => \Stripe\Mandate::class,
\Stripe\PaymentAttemptRecord::OBJECT_NAME => \Stripe\PaymentAttemptRecord::class,
\Stripe\PaymentIntent::OBJECT_NAME => \Stripe\PaymentIntent::class,
\Stripe\PaymentIntentAmountDetailsLineItem::OBJECT_NAME => \Stripe\PaymentIntentAmountDetailsLineItem::class,
\Stripe\PaymentLink::OBJECT_NAME => \Stripe\PaymentLink::class,
\Stripe\PaymentMethod::OBJECT_NAME => \Stripe\PaymentMethod::class,
\Stripe\PaymentMethodConfiguration::OBJECT_NAME => \Stripe\PaymentMethodConfiguration::class,
\Stripe\PaymentMethodDomain::OBJECT_NAME => \Stripe\PaymentMethodDomain::class,
\Stripe\PaymentRecord::OBJECT_NAME => \Stripe\PaymentRecord::class,
\Stripe\Payout::OBJECT_NAME => \Stripe\Payout::class,
\Stripe\Person::OBJECT_NAME => \Stripe\Person::class,
\Stripe\Plan::OBJECT_NAME => \Stripe\Plan::class,
@@ -162,8 +166,8 @@ class ObjectTypes
\Stripe\V2\Billing\MeterEvent::OBJECT_NAME => \Stripe\V2\Billing\MeterEvent::class,
\Stripe\V2\Billing\MeterEventAdjustment::OBJECT_NAME => \Stripe\V2\Billing\MeterEventAdjustment::class,
\Stripe\V2\Billing\MeterEventSession::OBJECT_NAME => \Stripe\V2\Billing\MeterEventSession::class,
\Stripe\V2\Event::OBJECT_NAME => \Stripe\V2\Event::class,
\Stripe\V2\EventDestination::OBJECT_NAME => \Stripe\V2\EventDestination::class,
\Stripe\V2\Core\Event::OBJECT_NAME => \Stripe\V2\Core\Event::class,
\Stripe\V2\Core\EventDestination::OBJECT_NAME => \Stripe\V2\Core\EventDestination::class,
// v2 object classes: The end of the section generated from our OpenAPI spec
];
}

View File

@@ -3,9 +3,9 @@
namespace Stripe\Util;
/**
* @phpstan-type RequestOptionsArray array{api_key?: string, idempotency_key?: string, stripe_account?: string, stripe_context?: string, stripe_version?: string, api_base?: string, max_network_retries?: int }
* @phpstan-type RequestOptionsArray array{api_key?: string, idempotency_key?: string, stripe_account?: string, stripe_context?: string|\Stripe\StripeContext, stripe_version?: string, api_base?: string, max_network_retries?: int }
*
* @psalm-type RequestOptionsArray = array{api_key?: string, idempotency_key?: string, stripe_account?: string, stripe_context?: string, stripe_version?: string, api_base?: string, max_network_retries?: int }
* @psalm-type RequestOptionsArray = array{api_key?: string, idempotency_key?: string, stripe_account?: string, stripe_context?: string|\Stripe\StripeContext, stripe_version?: string, api_base?: string, max_network_retries?: int }
*/
class RequestOptions
{
@@ -14,6 +14,7 @@ class RequestOptions
*/
public static $HEADERS_TO_PERSIST = [
'Stripe-Account',
'Stripe-Context',
'Stripe-Version',
];
@@ -79,6 +80,12 @@ class RequestOptions
}
$other_options->headers = \array_merge($this->headers, $other_options->headers);
// special handling for stripe_context
// if other sent an empty string, then we should unset
if (\array_key_exists('Stripe-Context', $other_options->headers) && '' === $other_options->headers['Stripe-Context']) {
unset($other_options->headers['Stripe-Context']);
}
return $other_options;
}
@@ -147,7 +154,7 @@ class RequestOptions
}
if (\array_key_exists('stripe_context', $options)) {
if (null !== $options['stripe_context']) {
$headers['Stripe-Context'] = $options['stripe_context'];
$headers['Stripe-Context'] = (string) $options['stripe_context'];
}
unset($options['stripe_context']);
}

View File

@@ -3,6 +3,7 @@
namespace Stripe\Util;
use Stripe\StripeObject;
use Stripe\V2\DeletedObject;
abstract class Util
{
@@ -39,10 +40,11 @@ abstract class Util
* @param array $resp the response from the Stripe API
* @param array|RequestOptions $opts
* @param 'v1'|'v2' $apiMode whether the response is from a v1 or v2 API
* @param bool $isV2DeletedObject whether we should ignore the `object` field and treat the response as a v2 deleted object
*
* @return array|StripeObject
*/
public static function convertToStripeObject($resp, $opts, $apiMode = 'v1')
public static function convertToStripeObject($resp, $opts, $apiMode = 'v1', $isV2DeletedObject = false)
{
$types = 'v1' === $apiMode ? ObjectTypes::mapping
: ObjectTypes::v2Mapping;
@@ -55,16 +57,19 @@ abstract class Util
return $mapped;
}
if (\is_array($resp)) {
if (isset($resp['object']) && \is_string($resp['object'])
if ($isV2DeletedObject) {
$class = DeletedObject::class;
} elseif (
isset($resp['object']) && \is_string($resp['object'])
&& isset($types[$resp['object']])
) {
$class = $types[$resp['object']];
if ('v2' === $apiMode && ('v2.core.event' === $resp['object'])) {
$eventTypes = EventTypes::thinEventMapping;
$eventTypes = EventTypes::v2EventMapping;
if (\array_key_exists('type', $resp) && \array_key_exists($resp['type'], $eventTypes)) {
$class = $eventTypes[$resp['type']];
} else {
$class = \Stripe\V2\Event::class;
$class = \Stripe\V2\Core\Event::class;
}
}
} elseif (\array_key_exists('data', $resp) && \array_key_exists('next_page_url', $resp)) {
@@ -81,41 +86,6 @@ abstract class Util
return $resp;
}
/**
* @param mixed $json
* @param mixed $class
*
* @throws \ReflectionException
*/
public static function json_decode_thin_event_object($json, $class)
{
$reflection = new \ReflectionClass($class);
$instance = $reflection->newInstanceWithoutConstructor();
$json = json_decode($json, true);
$properties = $reflection->getProperties();
foreach ($properties as $key => $property) {
if (\array_key_exists($property->getName(), $json)) {
if ('related_object' === $property->getName()) {
$related_object = new \Stripe\RelatedObject();
$related_object->id = $json['related_object']['id'];
$related_object->url = $json['related_object']['url'];
$related_object->type = $json['related_object']['type'];
$property->setValue($instance, $related_object);
} elseif ('reason' === $property->getName()) {
$reason = new \Stripe\Reason();
$reason->id = $json['reason']['id'];
$reason->idempotency_key = $json['reason']['idempotency_key'];
$property->setValue($instance, $reason);
} else {
$property->setAccessible(true);
$property->setValue($instance, $json[$property->getName()]);
}
}
}
return $instance;
}
/**
* @param mixed|string $value a string to UTF8-encode
*
@@ -131,15 +101,16 @@ abstract class Util
if (!self::$isMbstringAvailable) {
\trigger_error(
'It looks like the mbstring extension is not enabled. '
. 'UTF-8 strings will not properly be encoded. Ask your system '
. 'administrator to enable the mbstring extension, or write to '
. 'support@stripe.com if you have any questions.',
. 'UTF-8 strings will not properly be encoded. Ask your system '
. 'administrator to enable the mbstring extension, or write to '
. 'support@stripe.com if you have any questions.',
\E_USER_WARNING
);
}
}
if (\is_string($value) && self::$isMbstringAvailable
if (
\is_string($value) && self::$isMbstringAvailable
&& 'UTF-8' !== \mb_detect_encoding($value, 'UTF-8', true)
) {
return mb_convert_encoding($value, 'UTF-8', 'ISO-8859-1');
@@ -357,4 +328,17 @@ abstract class Util
return $apiMode;
}
/**
* Useful for determining if we should trust the object type when turning a response into a StripeObject.
*
* @param 'delete'|'get'|'post' $method the HTTP method
* @param 'v1'|'v2' $apiMode the API version
*
* @return bool true if the method is a DELETE request for v2 API, false otherwise
*/
public static function isV2DeleteRequest($method, $apiMode)
{
return 'delete' === $method && 'v2' === $apiMode;
}
}