Upgrade to 3.8.3

This commit is contained in:
Bastian Allgeier
2022-12-06 15:37:13 +01:00
parent f9e812cb0c
commit 8381ccb96c
69 changed files with 752 additions and 966 deletions

View File

@@ -15,25 +15,39 @@ use Kirby\Toolkit\Collection;
* @copyright Bastian Allgeier
* @license https://opensource.org/licenses/MIT
*/
final class Arguments extends Collection
class Arguments extends Collection
{
public const NO_PNTH = '\([^(]+\)(*SKIP)(*FAIL)';
// skip all matches inside of parantheses
public const NO_PNTH = '\([^)]+\)(*SKIP)(*FAIL)';
// skip all matches inside of square brackets
public const NO_SQBR = '\[[^]]+\](*SKIP)(*FAIL)';
// skip all matches inside of double quotes
public const NO_DLQU = '\"(?:[^"\\\\]|\\\\.)*\"(*SKIP)(*FAIL)';
// skip all matches inside of single quotes
public const NO_SLQU = '\'(?:[^\'\\\\]|\\\\.)*\'(*SKIP)(*FAIL)';
// skip all matches inside of any of the above skip groups
public const OUTSIDE = self::NO_PNTH . '|' . self::NO_SQBR . '|' .
self::NO_DLQU . '|' . self::NO_SLQU;
/**
* Splits list of arguments into individual
* Argument instances while respecting skip groups
*/
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),
preg_split('!,|' . self::OUTSIDE . '!', $arguments),
fn ($argument) => Argument::factory($argument)
);
return new static($arguments);
}
/**
* Resolve each argument, so that they can
* passed together to the actual method call
*/
public function resolve(array|object $data = []): array
{
return A::map(