Initial commit: WordPress wp-content (themes, plugins, languages)

- Theme: momentry (custom theme with REST API routes)
- Plugins: code-snippets (contains all API proxies)
- Languages: zh_TW translations
- Excludes: cache, backups, uploads, logs
This commit is contained in:
OpenCode
2026-05-29 19:07:56 +08:00
commit 09ef1f000f
6521 changed files with 867163 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
<?php
/**
* Part of JsonMapper
*
* PHP version 5
*
* @category Apimatic
* @package JsonMapper
* @author Asad Ali <asad.ali@apimatic.io>
* @license OSL-3.0 http://opensource.org/licenses/osl-3.0
* @link https://www.apimatic.io/
*/
namespace WPForms\Vendor\apimatic\jsonmapper;
/**
* OneOf Validation Exception.
*
* @category Apimatic
* @package JsonMapper
* @author Asad Ali <asad.ali@apimatic.io>
* @license OSL-3.0 http://opensource.org/licenses/osl-3.0
* @link https://www.apimatic.io/
*/
class AnyOfValidationException extends JsonMapperException
{
/**
* JSON does not match any of the types provided.
*
* @param string $type The type JSON could not be mapped to.
* @param string $json JSON string.
*
* @return AnyOfValidationException
*/
static function cannotMapAnyOfException($type, $json)
{
return new self("We could not match any acceptable type from" . " {$type} on: {$json}");
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,153 @@
<?php
/**
* Part of JsonMapper
*
* PHP version 5
*
* @category Netresearch
* @package JsonMapper
* @author Christian Weiske <christian.weiske@netresearch.de>
* @license OSL-3.0 http://opensource.org/licenses/osl-3.0
* @link http://www.netresearch.de/
*/
namespace WPForms\Vendor\apimatic\jsonmapper;
use RuntimeException;
/**
* Simple exception
*
* @category Netresearch
* @package JsonMapper
* @author Christian Weiske <christian.weiske@netresearch.de>
* @license OSL-3.0 http://opensource.org/licenses/osl-3.0
* @link http://www.netresearch.de/
*/
class JsonMapperException extends RuntimeException
{
/**
* Exception for discarded comments setting in configuration.
*
* @param array $concernedKeys Keys (PHP directives) with issues.
*
* @return JsonMapperException
*/
static function commentsDisabledInConfigurationException($concernedKeys)
{
return new self("Comments cannot be discarded in the configuration file i.e." . " the php.ini file; doc comments are a requirement for JsonMapper." . " Following configuration keys must have a value set to \"1\": " . \implode(", ", $concernedKeys) . ".");
}
/**
* Exception for non-existent key in an object.
*
* @param string $key The missing key/property.
* @param string $class The class in which the key is missing.
* @param bool $setterException Raise an exception specific to
* missing a setter within the class for
* the specified string.
*
* @return JsonMapperException
*/
static function undefinedPropertyException($key, $class, $setterException = \false)
{
$err = $setterException ? 'has no public setter method' : 'does not exist';
return new self("JSON property '{$key}' {$err} in object of type '{$class}'");
}
/**
* Exception for non-existent key in an object.
*
* @param string $key The property missing type.
* @param string $strClassName The class in which the property is missing type.
*
* @return JsonMapperException
*/
static function missingTypePropertyException($key, $strClassName)
{
return new self("Empty type at property '{$strClassName}::\${$key}'");
}
/**
* Exception for an unCallable Factory Method.
*
* @param string $factoryMethod The concerned factory method.
* @param string $strClassName Related class name.
*
* @return JsonMapperException
*/
static function unCallableFactoryMethodException($factoryMethod, $strClassName)
{
return new self("Factory method '{$factoryMethod}' referenced by " . "'{$strClassName}' is not callable.");
}
/**
* Exception for not able to call factory method with the given value.
*
* @param string $argType Type of the argument passed in method.
* @param string $reasons Exception message received from factory method.
*
* @return JsonMapperException
*/
static function invalidArgumentFactoryMethodException($argType, $reasons)
{
return new self("Provided factory methods are not callable with " . "the value of Type: {$argType}\n{$reasons}");
}
/**
* Exception when it is not possible to map an object to a specific type.
*
* @param string $typeName Name of type to map json object on.
* @param string $typeGroup Group name of the type provided.
* @param string $value Value that should be mapped by typeGroup
* i.e. JSON string.
*
* @return JsonMapperException
*/
static function unableToMapException($typeName, $typeGroup, $value)
{
return new self("Unable to map {$typeName}: {$typeGroup} on: {$value}");
}
/**
* A property marked as required was missing in the object provided.
*
* @param string $propertyName Concerned property's name.
* @param string $className The class name in which the property wasn't found.
*
* @return JsonMapperException
*/
static function requiredPropertyMissingException($propertyName, $className)
{
return new self("Required property '{$propertyName}' of class " . "'{$className}' is missing in JSON data");
}
/**
* No required arguments were provided.
*
* @param string $class The concerned class name.
* @param int $ctorReqParamNumber The number of req params in constructor.
*
* @return JsonMapperException
*/
static function noArgumentsException($class, $ctorReqParamNumber)
{
return new self("{$class} class requires {$ctorReqParamNumber} " . "arguments in constructor but none provided");
}
/**
* Provided arguments were less than required.
*
* @param string $class The concerned class name.
* @param array $ctorRequiredParamsName Required parameters array.
*
* @return JsonMapperException
*/
static function fewerArgumentsException($class, $ctorRequiredParamsName)
{
return new self("Could not find required constructor arguments for {$class}: " . \implode(", ", $ctorRequiredParamsName));
}
/**
* Provided type was not applicable on the given value.
*
* @param string $type The type value could not be mapped to.
* @param string $value Concerned value.
*
* @return JsonMapperException
*/
static function unableToSetTypeException($type, $value)
{
return new self("Could not set type '{$type}' on value: {$value}");
}
}

View File

@@ -0,0 +1,53 @@
<?php
/**
* Part of JsonMapper
*
* PHP version 5
*
* @category Apimatic
* @package JsonMapper
* @author Asad Ali <asad.ali@apimatic.io>
* @license OSL-3.0 http://opensource.org/licenses/osl-3.0
* @link https://www.apimatic.io/
*/
namespace WPForms\Vendor\apimatic\jsonmapper;
/**
* OneOf Validation Exception.
*
* @category Apimatic
* @package JsonMapper
* @author Asad Ali <asad.ali@apimatic.io>
* @license OSL-3.0 http://opensource.org/licenses/osl-3.0
* @link https://www.apimatic.io/
*/
class OneOfValidationException extends JsonMapperException
{
/**
* Exception raised when a json object maps to more
* than one type within the types specified in OneOf.
*
* @param string $matchedType First type.
* @param string $mappedWith Second type.
* @param string $json JSON string.
*
* @return OneOfValidationException
*/
static function moreThanOneOfException($matchedType, $mappedWith, $json)
{
return new self("There are more than one matching types i.e." . " { {$matchedType} and {$mappedWith} } on: {$json}");
}
/**
* JSON does not match any of the provided types.
*
* @param string $type The type JSON could not be mapped to.
* @param string $json JSON string.
*
* @return OneOfValidationException
*/
static function cannotMapAnyOfException($type, $json)
{
return new self("We could not match any acceptable type from" . " {$type} on: {$json}");
}
}

View File

@@ -0,0 +1,393 @@
<?php
/**
* Part of JsonMapper
*
* PHP version 5
*
* @category Apimatic
* @package JsonMapper
* @author Asad Ali <asad.ali@apimatic.io>
* @license OSL-3.0 http://opensource.org/licenses/osl-3.0
* @link https://www.apimatic.io/
*/
namespace WPForms\Vendor\apimatic\jsonmapper;
/**
* Data class to hold the groups of multiple types.
*
* @category Apimatic
* @package JsonMapper
* @author Asad Ali <asad.ali@apimatic.io>
* @license OSL-3.0 http://opensource.org/licenses/osl-3.0
* @link https://www.apimatic.io/
*/
class TypeCombination
{
/**
* String format of this typeCombinator group.
*
* @var string
*/
private $_format;
/**
* Name of this typeCombinator group i.e. oneOf/anyOf.
*
* @var string
*/
private $_groupName;
/**
* Name of discriminator field for this typeCombinator group.
*
* @var string
*/
private $_discriminatorField;
/**
* Mapping of each discriminator value on types in this typeCombinator group.
* i.e. [typeName => discriminatorValues]
*
* @var array
*/
private $_discriminatorMapping = [];
/**
* Array of string types or TypeCombination objects
*
* @var array
*/
private $_types;
/**
* A list of factory methods to deserialize the given object,
* for one of the wrapped types in this group
*
* @var string[]
*/
private $_deserializers;
/**
* Private constructor for TypeCombination class
*
* @param string $format string format value
* @param string $groupName group name value
* @param array $types types value
* @param string[] $deserializers deserializers value
*/
private function __construct($format, $groupName, $types, $deserializers)
{
$this->_format = $format;
$this->_groupName = $groupName;
$this->_types = $types;
$this->_deserializers = $deserializers;
$this->_insertDiscriminators();
}
/**
* String format of this typeCombinator group.
*
* @return string
*/
public function getFormat()
{
return $this->_format;
}
/**
* Name of this typeCombinator group i.e. oneOf/anyOf/array/map.
*
* @return string
*/
public function getGroupName()
{
return $this->_groupName;
}
/**
* Array of string types or TypeCombination objects
*
* @return array
*/
public function getTypes()
{
return $this->_types;
}
/**
* A list of factory methods to deserialize the given object,
* for one of the wrapped types in this group
*
* @return string[]
*/
public function getDeserializers()
{
return $this->_deserializers;
}
/**
* Get discriminator info as an array (if exists)
*
* @param string $type String type to search
* discriminators
* @param array<string,string> $discriminatorSubs Map of actual discriminator
* values where keys contain
* substituted values in the
* typeGroup string, Default: []
*
* @return array|null An array with format: discriminatorFieldName
* as element 1 and discriminatorValues as
* element 2
*/
public function getDiscriminator($type, $discriminatorSubs = [])
{
if (!isset($this->_discriminatorField) || !isset($this->_discriminatorMapping[$type])) {
return null;
}
$fieldName = $this->_discriminatorField;
if (isset($discriminatorSubs[$fieldName])) {
$fieldName = $discriminatorSubs[$fieldName];
}
$discValues = \array_map(function ($value) use($discriminatorSubs) {
if (isset($discriminatorSubs[$value])) {
return $discriminatorSubs[$value];
}
return $value;
}, $this->_discriminatorMapping[$type]);
return [$fieldName, $discValues];
}
/**
* Extract innermost oneof/anyof group hidden inside array/map
* type group
*
* @return TypeCombination
*/
public function extractOneOfAnyOfGroup()
{
$innerType = $this->getTypes()[0];
if (\in_array($this->getGroupName(), ["array", "map"]) && $innerType instanceof TypeCombination) {
return $innerType->extractOneOfAnyOfGroup();
}
return $this;
}
/**
* Extract all internal groups similar to the given group as a list of
* TypeCombination objects, it will only return similar array/map groups
*
* @param TypeCombination $group All inner groups similar to this array/map
* type group will be extracted
*
* @return TypeCombination[] A list of similar TypeCombination objects
*/
public function extractSimilar($group)
{
$result = [];
if (!\in_array($this->getGroupName(), ["array", "map"])) {
// if group is neither array nor map then call extractSimilar for
// each of the internal groups
foreach ($this->getTypes() as $typ) {
if ($typ instanceof TypeCombination) {
$result = \array_merge($result, $typ->extractSimilar($group));
}
}
} elseif ($group->getGroupName() == $this->getGroupName()) {
// if groupName is same then check inner group type
$internal = $this->getTypes()[0];
$group = $group->getTypes()[0];
if (\in_array($group->getGroupName(), ["array", "map"])) {
// if inner group is array/map then return result after
// extraction of groups similar to innerGroup
$result = $internal->extractSimilar($group);
} else {
// if inner group is oneof/anyof then only extract $internal
$result = [$internal];
}
}
return $result;
}
/**
* Extract type info like: isMap, isArray, and inner type for maps/arrays.
*
* @param string $type Type to be checked and extracted for information.
*
* @return array An array with type info in the format:
* (bool isMap, bool isArray, string $internalType).
*/
public static function extractTypeInfo($type)
{
// Check if the type is map, i.e. wrapped in array<string,...>
if (\preg_match('/^array<string,.*>$/', $type)) {
return [\true, \false, \substr($type, \strlen('array<string,'), -1)];
}
// Check if the type is array, i.e. ends with '[]'
if (\preg_match('/\\[]$/', $type)) {
return [\false, \true, \substr($type, 0, -2)];
}
// Check if the type is array, i.e. wrapped in 'array<...>'
if (\preg_match('/^array<.*>$/', $type)) {
return [\false, \true, \substr($type, \strlen('array<'), -1)];
}
// If the type does not match the array formats, return the original type
return [\false, \false, $type];
}
/**
* Create an oneof/anyof TypeCombination instance, by specifying inner types
*
* @param array $types i.e. (TypeCombination,string)[]
* @param string $gName group name value (anyof, oneof),
* Default: anyof
*
* @return TypeCombination
*/
public static function with($types, $gName = 'anyof')
{
$format = \join(',', \array_map(function ($t) {
return \is_string($t) ? $t : $t->getFormat();
}, $types));
return new self("{$gName}({$format})", $gName, $types, []);
}
/**
* Wrap the given typeGroup string in the TypeCombination class,
* i.e. getTypes() method will return all the grouped types,
* while deserializing factory methods can be obtained by
* getDeserializers() and group name can be obtained from getGroupName()
*
* @param string $typeGroup Format of multiple types i.e oneOf(int,bool)[],
* onyOf(int[], bool,anyOf(string,float)[],...),
* array<string,oneOf(int,float)[]> here []
* represents array types, and array<string,T>
* represents map types, oneOf/anyOf are group
* names, while default group name is anyOf.
* @param string[] $deserializers Callable factory methods for the property,
* Default: []
*
* @return TypeCombination
*/
public static function withFormat($typeGroup, $deserializers = [])
{
$groupName = 'anyOf';
$start = \strpos($typeGroup, '(');
$end = \strrpos($typeGroup, ')');
if ($start !== \false && $end !== \false) {
list($isMap, $isArray, $innerType) = self::extractTypeInfo($typeGroup);
if ($isMap || $isArray) {
return self::_createTypeGroup($isMap ? 'map' : 'array', $innerType, $deserializers);
}
$name = \substr($typeGroup, 0, $start);
$groupName = empty($name) ? $groupName : $name;
$typeGroup = \substr($typeGroup, $start + 1, -1);
}
$format = "({$typeGroup})";
$types = [];
$type = '';
$groupCount = 0;
foreach (\str_split($typeGroup) as $c) {
if ($c == '(' || $c == '<') {
$groupCount++;
}
if ($c == ')' || $c == '>') {
$groupCount--;
}
if ($c == ',' && $groupCount == 0) {
self::_insertType($types, $type, $deserializers);
$type = '';
continue;
}
$type .= $c;
}
self::_insertType($types, $type, $deserializers);
return new self($format, $groupName, $types, $deserializers);
}
/**
* Creates a TypeCombination object with the given name and inner
* types group that must be another typeCombination object
*
* @param string $name Group name for the typeCombination object.
* @param string $type typeGroup to be created and inserted.
* @param string[] $deserializers deserializer for the type group.
*
* @return TypeCombination
*/
private static function _createTypeGroup($name, $type, $deserializers)
{
$format = $name == 'map' ? "array<string,{$type}>" : $type . '[]';
return new self($format, $name, [self::withFormat($type, $deserializers)], $deserializers);
}
/**
* Insert the type in the types array which is passed by reference,
* Also check if type is not empty
*
* @param array $types types array reference
* @param string $type type to be inserted
* @param string[] $deserializers deserializer for the type group
*
* @return void
*/
private static function _insertType(&$types, $type, $deserializers)
{
$type = \trim($type);
if (\strpos($type, '(') !== \false && \strrpos($type, ')') !== \false) {
// If type is Grouped, creating TypeCombination instance for it
$type = self::withFormat($type, $deserializers);
}
if (!empty($type)) {
$types[] = $type;
}
}
/**
* Insert discriminator and discriminators mapping from group and
* type names.
*
* @return void
*/
private function _insertDiscriminators()
{
list($this->_groupName, $this->_discriminatorField) = self::_extractDiscriminator($this->_groupName);
$this->_types = $this->_filterUniqueTypes(\array_map(function ($type) {
if (!\is_string($type)) {
return $type;
}
list($type, $discriminator) = self::_extractDiscriminator($type);
if (\array_key_exists($type, $this->_discriminatorMapping)) {
$this->_discriminatorMapping[$type][] = $discriminator;
} else {
$this->_discriminatorMapping[$type] = [$discriminator];
}
return $type;
}, $this->_types));
if (isset($this->_discriminatorField)) {
$this->_format .= '{' . $this->_discriminatorField . '}';
}
}
/**
* Filter out the same types.
*
* @param array $types Types to be checked for uniqueness.
*
* @return array An array with all the unique types
*/
private function _filterUniqueTypes($types)
{
$seenTypes = [];
$uniqueTypes = [];
foreach ($types as $type) {
if (\is_string($type)) {
if (\in_array($type, $seenTypes, \true)) {
continue;
}
$seenTypes[] = $type;
}
$uniqueTypes[] = $type;
}
return $uniqueTypes;
}
/**
* Extract type discriminator.
*
* @param string $type Type to be checked and extracted for discriminator.
*
* @return array An array with type info in the format:
* (string $typeWithoutDiscriminator, string? discriminator).
*/
private function _extractDiscriminator($type)
{
$start = \strpos($type, '{');
$end = \strpos($type, '}');
$discriminator = null;
if ($start !== \false && $end !== \false) {
$discriminator = \substr($type, $start + 1, $end - \strlen($type));
$type = \substr($type, 0, $start) . \substr($type, $end + 1);
}
return [$type, $discriminator];
}
}