Upgrade to 3.9.0
This commit is contained in:
@@ -38,18 +38,23 @@ class Argument
|
||||
$argument = trim(substr($argument, 1, -1));
|
||||
}
|
||||
|
||||
// string with single or double quotes
|
||||
// string with single quotes
|
||||
if (
|
||||
(
|
||||
Str::startsWith($argument, '"') &&
|
||||
Str::endsWith($argument, '"')
|
||||
) || (
|
||||
Str::startsWith($argument, "'") &&
|
||||
Str::endsWith($argument, "'")
|
||||
)
|
||||
Str::startsWith($argument, "'") &&
|
||||
Str::endsWith($argument, "'")
|
||||
) {
|
||||
$string = substr($argument, 1, -1);
|
||||
$string = str_replace(['\"', "\'"], ['"', "'"], $string);
|
||||
$string = str_replace("\'", "'", $string);
|
||||
return new static($string);
|
||||
}
|
||||
|
||||
// string with double quotes
|
||||
if (
|
||||
Str::startsWith($argument, '"') &&
|
||||
Str::endsWith($argument, '"')
|
||||
) {
|
||||
$string = substr($argument, 1, -1);
|
||||
$string = str_replace('\"', '"', $string);
|
||||
return new static($string);
|
||||
}
|
||||
|
||||
|
@@ -6,8 +6,8 @@ use Kirby\Toolkit\A;
|
||||
use Kirby\Toolkit\Collection;
|
||||
|
||||
/**
|
||||
* The Argument class represents a single
|
||||
* parameter passed to a method in a chained query
|
||||
* The Arguments class helps splitting a
|
||||
* parameter string into processable arguments
|
||||
*
|
||||
* @package Kirby Query
|
||||
* @author Nico Hoffmann <nico@getkirby.com>
|
||||
@@ -26,8 +26,9 @@ class Arguments extends Collection
|
||||
// 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;
|
||||
public const OUTSIDE =
|
||||
self::NO_PNTH . '|' . self::NO_SQBR . '|' .
|
||||
self::NO_DLQU . '|' . self::NO_SLQU;
|
||||
|
||||
/**
|
||||
* Splits list of arguments into individual
|
||||
|
@@ -22,6 +22,9 @@ class Expression
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses an expression string into its parts
|
||||
*/
|
||||
public static function factory(string $expression, Query $parent = null): static|Segments
|
||||
{
|
||||
// split into different expression parts and operators
|
||||
|
@@ -124,7 +124,6 @@ Query::$entries['site'] = function (): Site {
|
||||
return App::instance()->site();
|
||||
};
|
||||
|
||||
|
||||
Query::$entries['t'] = function (
|
||||
string $key,
|
||||
string|array $fallback = null,
|
||||
|
@@ -51,6 +51,11 @@ class Segment
|
||||
throw new BadMethodCallException($error);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a segment into the property/method name and its arguments
|
||||
*
|
||||
* @param int $position String position of the segment inside the full query
|
||||
*/
|
||||
public static function factory(
|
||||
string $segment,
|
||||
int $position = 0
|
||||
@@ -69,6 +74,10 @@ class Segment
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Automatically resolves the segment depending on the
|
||||
* segment position and the type of the base
|
||||
*/
|
||||
public function resolve(mixed $base = null, array|object $data = []): mixed
|
||||
{
|
||||
// resolve arguments to array
|
||||
|
@@ -81,8 +81,9 @@ class Segments extends Collection
|
||||
return null;
|
||||
}
|
||||
|
||||
// for regular connectors, just skip
|
||||
if ($segment === '.') {
|
||||
// for regular connectors and optional chaining on non-null,
|
||||
// just skip this connecting segment
|
||||
if ($segment === '.' || $segment === '?.') {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user