Upgrade to 3.8.2

This commit is contained in:
Bastian Allgeier
2022-11-15 13:26:12 +01:00
parent fe2baa1b7a
commit f9e812cb0c
45 changed files with 760 additions and 346 deletions

View File

@@ -0,0 +1,44 @@
<?php
namespace Kirby\Query;
use Kirby\Toolkit\A;
use Kirby\Toolkit\Collection;
/**
* The Argument class represents a single
* parameter passed to a method in a chained query
*
* @package Kirby Query
* @author Nico Hoffmann <nico@getkirby.com>
* @link https://getkirby.com
* @copyright Bastian Allgeier
* @license https://opensource.org/licenses/MIT
*/
final class Arguments extends Collection
{
public const NO_PNTH = '\([^(]+\)(*SKIP)(*FAIL)';
public const NO_SQBR = '\[[^]]+\](*SKIP)(*FAIL)';
public const NO_DLQU = '\"(?:[^"\\\\]|\\\\.)*\"(*SKIP)(*FAIL)';
public const NO_SLQU = '\'(?:[^\'\\\\]|\\\\.)*\'(*SKIP)(*FAIL)';
public static function factory(string $arguments): static
{
$arguments = A::map(
// split by comma, but not inside skip groups
preg_split('!,|' . self::NO_PNTH . '|' . self::NO_SQBR . '|' .
self::NO_DLQU . '|' . self::NO_SLQU . '!', $arguments),
fn ($argument) => Argument::factory($argument)
);
return new static($arguments);
}
public function resolve(array|object $data = []): array
{
return A::map(
$this->data,
fn ($argument) => $argument->resolve($data)
);
}
}