*/ 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:----qkbdf6j8Hyd/1GLAtq25DYyUdQ8ZMkJidmC4jdXaj6/6i0uty9gRXoZDNTjw477lHWR88mLMF7dbY2bv2XeN2NkACL3O6glQ0alLkHeAt+3BgU8UPTtD7emGAE+KYHkjLdIpqO3N16+9QPXNXdA69WLIe6uRaZNs/Gc9jKzQCt2iVkn+xDgpOvHGbsp+rw2VmBViCQjtc+m2MR3fcfUNoBAN97EETxCL5DqOFtFaCbIdeM2vcxLG5jzAtHz5ucXhkVrqCKXLU7bMh1wAJGUQW+IXIaLrwc9S+uzxSjljhAG082bCPZWxWBv+VZPUWlOM4kubAjJDwT1JZ0glXE6Z/bR5J8xPr2N28V2O2wI/QxVLxQOGCsBrwK8NlnWcDzuNy2oA2m7lxk8QhXUwRaem974un/WapabdEPtn/VRCrKdxczTHxKErZ+S5hfHiPvfHtUehCZER0rg2SAbchrll9ubphJxXTf0yfWPS8Kfe7XFMkIpOOvZYMLUPLGXsIUXcS2DVgq1mcH4mUjgQhy5ySu2IyjGwFeM2MwSIevz3xaj7WmhfeVDo1ztrKF8EX5uCNx7pkewcSiF2DSjrIjmngqZOSVh/1rNtP2jF0oV4n+eICUsHjGJRg8TzP0TJIyVmjarzU3ypqZyAH5E9FrZjyoIE/rwZNVlxAVledK6dnhM=----ATTACHMENT:----NTE0MjQzOTM4NDUxNTI3MCA1MjYxMjE1MDQwNTExNjU5IDM3OTIyMDgyMTY2NTc4ODY=