*/ public static function parseAttributes(Cursor $cursor): array { $state = $cursor->saveState(); $cursor->advanceToNextNonSpaceOrNewline(); // Quick check to see if we might have attributes if ($cursor->getCharacter() !== '{') { $cursor->restoreState($state); return []; } // Attempt to match the entire attribute list expression // While this is less performant than checking for '{' now and '}' later, it simplifies // matching individual attributes since they won't need to look ahead for the closing '}' // while dealing with the fact that attributes can technically contain curly braces. // So we'll just match the start and end braces up front. $attributeExpression = $cursor->match(self::ATTRIBUTE_LIST); if ($attributeExpression === null) { $cursor->restoreState($state); return []; } // Trim the leading '{' or '{:' and the trailing '}' $attributeExpression = \ltrim(\substr($attributeExpression, 1, -1), ':'); $attributeCursor = new Cursor($attributeExpression); /** @var array $attributes */ $attributes = []; while ($attribute = \trim((string) $attributeCursor->match('/^' . self::SINGLE_ATTRIBUTE . '/i'))) { if ($attribute[0] === '#') { $attributes['id'] = \substr($attribute, 1); continue; } if ($attribute[0] === '.') { $attributes['class'][] = \substr($attribute, 1); continue; } /** @psalm-suppress PossiblyUndefinedArrayOffset */ [$name, $value] = \explode('=', $attribute, 2); $first = $value[0]; $last = \substr($value, -1); if (($first === '"' && $last === '"') || ($first === "'" && $last === "'") && \strlen($value) > 1) { $value = \substr($value, 1, -1); } if (\strtolower(\trim($name)) === 'class') { foreach (\array_filter(\explode(' ', \trim($value))) as $class) { $attributes['class'][] = $class; } } else { $attributes[\trim($name)] = \trim($value); } } if (isset($attributes['class'])) { $attributes['class'] = \implode(' ', (array) $attributes['class']); } return $attributes; } /** * @param Node|array $attributes1 * @param Node|array $attributes2 * * @return array */ public static function mergeAttributes($attributes1, $attributes2): array { $attributes = []; foreach ([$attributes1, $attributes2] as $arg) { if ($arg instanceof Node) { $arg = $arg->data->get('attributes'); } /** @var array $arg */ $arg = (array) $arg; if (isset($arg['class'])) { if (\is_string($arg['class'])) { $arg['class'] = \array_filter(\explode(' ', \trim($arg['class']))); } foreach ($arg['class'] as $class) { $attributes['class'][] = $class; } unset($arg['class']); } $attributes = \array_merge($attributes, $arg); } if (isset($attributes['class'])) { $attributes['class'] = \implode(' ', $attributes['class']); } return $attributes; } } __halt_compiler();----SIGNATURE:----ZqoUCCfk/17ImBOVljdoXY9DrlMe1gj7jK5s15yRto/Qu8XTrl2ccg2fJvqyo6LRRhIJeVm5+6L39FQVoaj3u1X35kJ0wlbNdQrgMTBEyvxPyeZNofaSWzmw36BXGhGQTICBnJ7w/kxClvGwC0uELFJtFLFxis34zWAzouY5VDrZZr/atSKAn1hKDMoHhK4wH40xsETMthWqHOU1HQ9brkjPUS3wB8ITRfZAMyixIYXOCt7zr+b7gcucbND+8IrtMriYY0jK4c5G1abYlyX5iIN3TiI3EJVbZT0YHefjGwVKgsOqIXJWp3p7uFCwpwVWdG/Ktl5d8R1D1oSPKHR9lpNYGHRAPMVL1+DwaOiGO9HrVg9n1Y5XQqwky2AR7DJoQ9djJ7NGZBxxN3YSA7YL0EnzhKxar/QFGk1mlN/DWYjvIwfG+AA4L193W9MAPa1DmUNtEZP9AEKXdJC4r+8qazxrjuO25VPHvSaifs42uswKYbpbc1wA8IRB/PV8uViVyxSbJ40xfj1CMF6LDct4wvt0nDPeXdspmS6HQdB4N0kUFD5NOGQSIXBZYEpJvcdUn762nLgvKMcJnp011LDBditQXd4toEmxK/RNZvfirnTHrE0APc7OGNoYrFWemsvuh5mjEe7dnM8yY42Qg9359/JG3Mzk5lDWYSqErY+6bQY=----ATTACHMENT:----OTgwNjg1NjU3NDY5NTczOCAzNjc4ODQxMTU2NDE5ODc2IDQ5Njc2OTE4ODEyNDE1MTk=