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

@@ -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;
}
}