Subida del módulo y tema de PrestaShop

This commit is contained in:
Kaloyan
2026-04-09 18:31:51 +02:00
parent 12c253296f
commit 16b3ff9424
39262 changed files with 7418797 additions and 0 deletions

68
vendor/symfony/form/Util/FormUtil.php vendored Normal file
View File

@@ -0,0 +1,68 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Form\Util;
/**
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class FormUtil
{
/**
* This class should not be instantiated.
*/
private function __construct()
{
}
/**
* Returns whether the given data is empty.
*
* This logic is reused multiple times throughout the processing of
* a form and needs to be consistent. PHP keyword `empty` cannot
* be used as it also considers 0 and "0" to be empty.
*/
public static function isEmpty(mixed $data): bool
{
// Should not do a check for [] === $data!!!
// This method is used in occurrences where arrays are
// not considered to be empty, ever.
return null === $data || '' === $data;
}
/**
* Recursively replaces or appends elements of the first array with elements
* of second array. If the key is an integer, the values will be appended to
* the new array; otherwise, the value from the second array will replace
* the one from the first array.
*/
public static function mergeParamsAndFiles(array $params, array $files): array
{
$isFilesList = array_is_list($files);
foreach ($params as $key => $value) {
if (\is_array($value) && \is_array($files[$key] ?? null)) {
$params[$key] = self::mergeParamsAndFiles($value, $files[$key]);
unset($files[$key]);
}
}
if (!$isFilesList) {
return array_replace($params, $files);
}
foreach ($files as $value) {
$params[] = $value;
}
return $params;
}
}

View File

@@ -0,0 +1,37 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Form\Util;
/**
* Iterator that traverses an array of forms.
*
* Contrary to \ArrayIterator, this iterator recognizes changes in the original
* array during iteration.
*
* You can wrap the iterator into a {@link \RecursiveIteratorIterator} in order to
* enter any child form that inherits its parent's data and iterate the children
* of that form as well.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class InheritDataAwareIterator extends \IteratorIterator implements \RecursiveIterator
{
public function getChildren(): static
{
return new static($this->current());
}
public function hasChildren(): bool
{
return (bool) $this->current()->getConfig()->getInheritData();
}
}

View File

@@ -0,0 +1,110 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Form\Util;
use Symfony\Component\OptionsResolver\Exception\AccessException;
use Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* @author Yonel Ceruto <yonelceruto@gmail.com>
*
* @internal
*/
class OptionsResolverWrapper extends OptionsResolver
{
private array $undefined = [];
/**
* @return $this
*/
public function setNormalizer(string $option, \Closure $normalizer): static
{
try {
parent::setNormalizer($option, $normalizer);
} catch (UndefinedOptionsException) {
$this->undefined[$option] = true;
}
return $this;
}
/**
* @return $this
*/
public function setAllowedValues(string $option, mixed $allowedValues): static
{
try {
parent::setAllowedValues($option, $allowedValues);
} catch (UndefinedOptionsException) {
$this->undefined[$option] = true;
}
return $this;
}
/**
* @return $this
*/
public function addAllowedValues(string $option, mixed $allowedValues): static
{
try {
parent::addAllowedValues($option, $allowedValues);
} catch (UndefinedOptionsException) {
$this->undefined[$option] = true;
}
return $this;
}
/**
* @param string|array $allowedTypes
*
* @return $this
*/
public function setAllowedTypes(string $option, $allowedTypes): static
{
try {
parent::setAllowedTypes($option, $allowedTypes);
} catch (UndefinedOptionsException) {
$this->undefined[$option] = true;
}
return $this;
}
/**
* @param string|array $allowedTypes
*
* @return $this
*/
public function addAllowedTypes(string $option, $allowedTypes): static
{
try {
parent::addAllowedTypes($option, $allowedTypes);
} catch (UndefinedOptionsException) {
$this->undefined[$option] = true;
}
return $this;
}
public function resolve(array $options = []): array
{
throw new AccessException('Resolve options is not supported.');
}
public function getUndefinedOptions(): array
{
return array_keys($this->undefined);
}
}

View File

@@ -0,0 +1,162 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Form\Util;
/**
* A hash map which keeps track of deletions and additions.
*
* Like in associative arrays, elements can be mapped to integer or string keys.
* Unlike associative arrays, the map keeps track of the order in which keys
* were added and removed. This order is reflected during iteration.
*
* The map supports concurrent modification during iteration. That means that
* you can insert and remove elements from within a foreach loop and the
* iterator will reflect those changes accordingly.
*
* While elements that are added during the loop are recognized by the iterator,
* changed elements are not. Otherwise the loop could be infinite if each loop
* changes the current element:
*
* $map = new OrderedHashMap();
* $map[1] = 1;
* $map[2] = 2;
* $map[3] = 3;
*
* foreach ($map as $index => $value) {
* echo "$index: $value\n"
* if (1 === $index) {
* $map[1] = 4;
* $map[] = 5;
* }
* }
*
* print_r(iterator_to_array($map));
*
* // => 1: 1
* // 2: 2
* // 3: 3
* // 4: 5
* // Array
* // (
* // [1] => 4
* // [2] => 2
* // [3] => 3
* // [4] => 5
* // )
*
* The map also supports multiple parallel iterators. That means that you can
* nest foreach loops without affecting each other's iteration:
*
* foreach ($map as $index => $value) {
* foreach ($map as $index2 => $value2) {
* // ...
* }
* }
*
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @template TValue
*
* @implements \ArrayAccess<string, TValue>
* @implements \IteratorAggregate<string, TValue>
*/
class OrderedHashMap implements \ArrayAccess, \IteratorAggregate, \Countable
{
/**
* The elements of the map, indexed by their keys.
*
* @var TValue[]
*/
private array $elements = [];
/**
* The keys of the map in the order in which they were inserted or changed.
*
* @var list<string>
*/
private array $orderedKeys = [];
/**
* References to the cursors of all open iterators.
*
* @var array<int, int>
*/
private array $managedCursors = [];
/**
* Creates a new map.
*
* @param TValue[] $elements The elements to insert initially
*/
public function __construct(array $elements = [])
{
$this->elements = $elements;
// the explicit string type-cast is necessary as digit-only keys would be returned as integers otherwise
$this->orderedKeys = array_map(strval(...), array_keys($elements));
}
public function offsetExists(mixed $key): bool
{
return isset($this->elements[$key]);
}
public function offsetGet(mixed $key): mixed
{
if (!isset($this->elements[$key])) {
throw new \OutOfBoundsException(\sprintf('The offset "%s" does not exist.', $key));
}
return $this->elements[$key];
}
public function offsetSet(mixed $key, mixed $value): void
{
if (null === $key || !isset($this->elements[$key])) {
if (null === $key) {
$key = [] === $this->orderedKeys
// If the array is empty, use 0 as key
? 0
// Imitate PHP behavior of generating a key that equals
// the highest existing integer key + 1
: 1 + (int) max($this->orderedKeys);
}
$this->orderedKeys[] = (string) $key;
}
$this->elements[$key] = $value;
}
public function offsetUnset(mixed $key): void
{
if (false !== ($position = array_search((string) $key, $this->orderedKeys))) {
array_splice($this->orderedKeys, $position, 1);
unset($this->elements[$key]);
foreach ($this->managedCursors as $i => $cursor) {
if ($cursor >= $position) {
--$this->managedCursors[$i];
}
}
}
}
public function getIterator(): \Traversable
{
return new OrderedHashMapIterator($this->elements, $this->orderedKeys, $this->managedCursors);
}
public function count(): int
{
return \count($this->elements);
}
}

View File

@@ -0,0 +1,128 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Form\Util;
/**
* Iterator for {@link OrderedHashMap} objects.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @internal
*
* @template-covariant TValue
*
* @implements \Iterator<string, TValue>
*/
class OrderedHashMapIterator implements \Iterator
{
/** @var TValue[] */
private array $elements;
/** @var list<string> */
private array $orderedKeys;
private int $cursor = 0;
private int $cursorId;
/** @var array<int, int> */
private array $managedCursors;
private ?string $key = null;
/** @var TValue|null */
private mixed $current = null;
/**
* @param TValue[] $elements The elements of the map, indexed by their
* keys
* @param list<string> $orderedKeys The keys of the map in the order in which
* they should be iterated
* @param array<int, int> $managedCursors An array from which to reference the
* iterator's cursor as long as it is alive.
* This array is managed by the corresponding
* {@link OrderedHashMap} instance to support
* recognizing the deletion of elements.
*/
public function __construct(array &$elements, array &$orderedKeys, array &$managedCursors)
{
$this->elements = &$elements;
$this->orderedKeys = &$orderedKeys;
$this->managedCursors = &$managedCursors;
$this->cursorId = \count($managedCursors);
$this->managedCursors[$this->cursorId] = &$this->cursor;
}
public function __sleep(): array
{
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}
/**
* @return void
*/
public function __wakeup()
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
}
/**
* Removes the iterator's cursors from the managed cursors of the
* corresponding {@link OrderedHashMap} instance.
*/
public function __destruct()
{
// Use array_splice() instead of unset() to prevent holes in the
// array indices, which would break the initialization of $cursorId
array_splice($this->managedCursors, $this->cursorId, 1);
}
public function current(): mixed
{
return $this->current;
}
public function next(): void
{
++$this->cursor;
if (isset($this->orderedKeys[$this->cursor])) {
$this->key = $this->orderedKeys[$this->cursor];
$this->current = $this->elements[$this->key];
} else {
$this->key = null;
$this->current = null;
}
}
public function key(): mixed
{
if (null === $this->key) {
return null;
}
return $this->key;
}
public function valid(): bool
{
return null !== $this->key;
}
public function rewind(): void
{
$this->cursor = 0;
if (isset($this->orderedKeys[0])) {
$this->key = $this->orderedKeys[0];
$this->current = $this->elements[$this->key];
} else {
$this->key = null;
$this->current = null;
}
}
}

View File

@@ -0,0 +1,93 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Form\Util;
use Symfony\Component\HttpFoundation\RequestStack;
/**
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class ServerParams
{
private ?RequestStack $requestStack;
public function __construct(?RequestStack $requestStack = null)
{
$this->requestStack = $requestStack;
}
/**
* Returns true if the POST max size has been exceeded in the request.
*/
public function hasPostMaxSizeBeenExceeded(): bool
{
$contentLength = $this->getContentLength();
$maxContentLength = $this->getPostMaxSize();
return $maxContentLength && $contentLength > $maxContentLength;
}
/**
* Returns maximum post size in bytes.
*/
public function getPostMaxSize(): int|float|null
{
$iniMax = strtolower($this->getNormalizedIniPostMaxSize());
if ('' === $iniMax) {
return null;
}
$max = ltrim($iniMax, '+');
if (str_starts_with($max, '0x')) {
$max = \intval($max, 16);
} elseif (str_starts_with($max, '0')) {
$max = \intval($max, 8);
} else {
$max = (int) $max;
}
switch (substr($iniMax, -1)) {
case 't': $max *= 1024;
// no break
case 'g': $max *= 1024;
// no break
case 'm': $max *= 1024;
// no break
case 'k': $max *= 1024;
}
return $max;
}
/**
* Returns the normalized "post_max_size" ini setting.
*/
public function getNormalizedIniPostMaxSize(): string
{
return strtoupper(trim(\ini_get('post_max_size')));
}
/**
* Returns the content length of the request.
*/
public function getContentLength(): mixed
{
if (null !== $this->requestStack && null !== $request = $this->requestStack->getCurrentRequest()) {
return $request->server->get('CONTENT_LENGTH');
}
return isset($_SERVER['CONTENT_LENGTH'])
? (int) $_SERVER['CONTENT_LENGTH']
: null;
}
}

53
vendor/symfony/form/Util/StringUtil.php vendored Normal file
View File

@@ -0,0 +1,53 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Form\Util;
/**
* @author Issei Murasawa <issei.m7@gmail.com>
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class StringUtil
{
/**
* This class should not be instantiated.
*/
private function __construct()
{
}
/**
* Returns the trimmed data.
*/
public static function trim(string $string): string
{
if (null !== $result = @preg_replace('/^[\pZ\p{Cc}\p{Cf}]+|[\pZ\p{Cc}\p{Cf}]+$/u', '', $string)) {
return $result;
}
return trim($string);
}
/**
* Converts a fully-qualified class name to a block prefix.
*
* @param string $fqcn The fully-qualified class name
*/
public static function fqcnToBlockPrefix(string $fqcn): ?string
{
// Non-greedy ("+?") to match "type" suffix, if present
if (preg_match('~([^\\\\]+?)(type)?$~i', $fqcn, $matches)) {
return strtolower(preg_replace(['/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'], ['\\1_\\2', '\\1_\\2'], $matches[1]));
}
return null;
}
}