feat(Docker): Upgrade to PHP 8.5.0RC3 with native ext-uri support
BREAKING CHANGE: Requires PHP 8.5.0RC3 Changes: - Update Docker base image from php:8.4-fpm to php:8.5.0RC3-fpm - Enable ext-uri for native WHATWG URL parsing support - Update composer.json PHP requirement from ^8.4 to ^8.5 - Add ext-uri as required extension in composer.json - Move URL classes from Url.php85/ to Url/ directory (now compatible) - Remove temporary PHP 8.4 compatibility workarounds Benefits: - Native URL parsing with Uri\WhatWg\Url class - Better performance for URL operations - Future-proof with latest PHP features - Eliminates PHP version compatibility issues
This commit is contained in:
@@ -55,8 +55,9 @@ final class PlaceholderReplacer implements StringProcessor
|
||||
|
||||
// Standard Variablen und Methoden: {{ $item.getRelativeFile() }} or {{ item.getRelativeFile() }}
|
||||
// Supports both old and new syntax for backwards compatibility
|
||||
// Also supports array bracket syntax: {{ $model['key'] }} or {{ $model["key"] }}
|
||||
return preg_replace_callback(
|
||||
'/{{\\s*\\$?([\\w.]+)(?:\\(\\s*([^)]*)\\s*\\))?\\s*}}/',
|
||||
'/{{\\s*\\$?([\\w.\\[\\]\'\"]+)(?:\\(\\s*([^)]*)\\s*\\))?\\s*}}/',
|
||||
function ($matches) use ($context) {
|
||||
$expression = $matches[1];
|
||||
$params = isset($matches[2]) ? trim($matches[2]) : null;
|
||||
@@ -276,16 +277,34 @@ final class PlaceholderReplacer implements StringProcessor
|
||||
|
||||
private function resolveValue(array $data, string $expr): mixed
|
||||
{
|
||||
$keys = explode('.', $expr);
|
||||
// Handle array bracket syntax: $var['key'] or $var["key"]
|
||||
// Can be chained: $var['key1']['key2'] or mixed: $var.prop['key']
|
||||
$originalExpr = $expr;
|
||||
$value = $data;
|
||||
|
||||
foreach ($keys as $key) {
|
||||
if (is_array($value) && array_key_exists($key, $value)) {
|
||||
$value = $value[$key];
|
||||
} elseif (is_object($value) && isset($value->$key)) {
|
||||
$value = $value->$key;
|
||||
} else {
|
||||
return null;
|
||||
// Split expression into parts, handling both dot notation and bracket notation
|
||||
$pattern = '/([\\w]+)|\\[([\'"])([^\\2]+?)\\2\\]/';
|
||||
preg_match_all($pattern, $expr, $matches, PREG_SET_ORDER);
|
||||
|
||||
foreach ($matches as $match) {
|
||||
if (!empty($match[1])) {
|
||||
// Dot notation: variable.property
|
||||
$key = $match[1];
|
||||
if (is_array($value) && array_key_exists($key, $value)) {
|
||||
$value = $value[$key];
|
||||
} elseif (is_object($value) && isset($value->$key)) {
|
||||
$value = $value->$key;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} elseif (!empty($match[3])) {
|
||||
// Bracket notation: variable['key'] or variable["key"]
|
||||
$key = $match[3];
|
||||
if (is_array($value) && array_key_exists($key, $value)) {
|
||||
$value = $value[$key];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user