PHP: class Router { private array $routes = []; public function addRoute(string $pattern, string|array $handler, array $methods = []): void { $this->routes[] = [ 'pattern' => $pattern, 'handler' => $handler, 'methods' => $methods ]; } #[ArrayShape(['handler' => "mixed", 'attribs' => "array"])] public function match(Request $request): array { foreach ($this->routes as $route) { if ($route['methods'] && !in_array($request->getMethod(), $route['methods'], true)) { continue; } $pattern = preg_replace('#{([a-z]+)}#', '(?P<$1>[a-z]+)', $route['pattern']); $pattern = preg_replace('#{([a-z]+):([^}]+)}#', '(?P<$1>$2)', $pattern); if (preg_match("#^$pattern$#", $request->getPath(), $matches)) { return [ 'handler' => $route['handler'], 'attribs' => array_filter($matches, 'is_string', ARRAY_FILTER_USE_KEY) ]; } } throw new Error("Не найден маршрут пути: {$request->getPath()}"); } } Для метода match шторм сам предложил добавить атрибут ArrayShape и в полученном из него результате работает автозаполнение ключей массива. А как мне сделать такое же для метода addRoute или для свойства route?