├── .gitignore ├── LICENSE.md ├── README.md ├── composer.json └── src ├── AnnotatedTextEdit.php ├── ApplyWorkspaceEditParams.php ├── ApplyWorkspaceEditRequest.php ├── ApplyWorkspaceEditResult.php ├── BaseSymbolInformation.php ├── CallHierarchyIncomingCall.php ├── CallHierarchyItem.php ├── CallHierarchyOutgoingCall.php ├── ChangeAnnotation.php ├── ClientCapabilities.php ├── CodeAction.php ├── CodeActionClientCapabilities.php ├── CodeActionContext.php ├── CodeActionKind.php ├── CodeActionOptions.php ├── CodeActionParams.php ├── CodeActionRegistrationOptions.php ├── CodeActionRequest.php ├── CodeActionResolveRequest.php ├── CodeActionTriggerKind.php ├── CodeDescription.php ├── CodeLens.php ├── CodeLensClientCapabilities.php ├── CodeLensOptions.php ├── CodeLensParams.php ├── CodeLensRefreshRequest.php ├── CodeLensRegistrationOptions.php ├── CodeLensRequest.php ├── CodeLensResolveRequest.php ├── CodeLensWorkspaceClientCapabilities.php ├── Color.php ├── ColorInformation.php ├── ColorPresentation.php ├── ColorPresentationParams.php ├── ColorPresentationRequest.php ├── Command.php ├── CompletionClientCapabilities.php ├── CompletionContext.php ├── CompletionItem.php ├── CompletionItemKind.php ├── CompletionItemLabelDetails.php ├── CompletionItemTag.php ├── CompletionList.php ├── CompletionOptions.php ├── CompletionParams.php ├── CompletionRegistrationOptions.php ├── CompletionRequest.php ├── CompletionResolveRequest.php ├── CompletionTriggerKind.php ├── ConfigurationItem.php ├── ConfigurationParams.php ├── ConfigurationRequest.php ├── CreateFile.php ├── CreateFileOptions.php ├── CreateFilesParams.php ├── DeclarationClientCapabilities.php ├── DeclarationOptions.php ├── DeclarationParams.php ├── DeclarationRegistrationOptions.php ├── DeclarationRequest.php ├── DefinitionClientCapabilities.php ├── DefinitionOptions.php ├── DefinitionParams.php ├── DefinitionRegistrationOptions.php ├── DefinitionRequest.php ├── DeleteFile.php ├── DeleteFileOptions.php ├── DeleteFilesParams.php ├── Diagnostic.php ├── DiagnosticRelatedInformation.php ├── DiagnosticSeverity.php ├── DiagnosticTag.php ├── DidChangeConfigurationClientCapabilities.php ├── DidChangeConfigurationNotification.php ├── DidChangeConfigurationParams.php ├── DidChangeConfigurationRegistrationOptions.php ├── DidChangeTextDocumentNotification.php ├── DidChangeTextDocumentParams.php ├── DidChangeWatchedFilesClientCapabilities.php ├── DidChangeWatchedFilesNotification.php ├── DidChangeWatchedFilesParams.php ├── DidChangeWatchedFilesRegistrationOptions.php ├── DidChangeWorkspaceFoldersNotification.php ├── DidChangeWorkspaceFoldersParams.php ├── DidCloseTextDocumentNotification.php ├── DidCloseTextDocumentParams.php ├── DidCreateFilesNotification.php ├── DidDeleteFilesNotification.php ├── DidOpenTextDocumentNotification.php ├── DidOpenTextDocumentParams.php ├── DidRenameFilesNotification.php ├── DidSaveTextDocumentNotification.php ├── DidSaveTextDocumentParams.php ├── DocumentColorClientCapabilities.php ├── DocumentColorOptions.php ├── DocumentColorParams.php ├── DocumentColorRegistrationOptions.php ├── DocumentColorRequest.php ├── DocumentFormattingClientCapabilities.php ├── DocumentFormattingOptions.php ├── DocumentFormattingParams.php ├── DocumentFormattingRegistrationOptions.php ├── DocumentFormattingRequest.php ├── DocumentHighlight.php ├── DocumentHighlightClientCapabilities.php ├── DocumentHighlightKind.php ├── DocumentHighlightOptions.php ├── DocumentHighlightParams.php ├── DocumentHighlightRegistrationOptions.php ├── DocumentHighlightRequest.php ├── DocumentLink.php ├── DocumentLinkClientCapabilities.php ├── DocumentLinkOptions.php ├── DocumentLinkParams.php ├── DocumentLinkRegistrationOptions.php ├── DocumentLinkRequest.php ├── DocumentLinkResolveRequest.php ├── DocumentOnTypeFormattingClientCapabilities.php ├── DocumentOnTypeFormattingOptions.php ├── DocumentOnTypeFormattingParams.php ├── DocumentOnTypeFormattingRegistrationOptions.php ├── DocumentOnTypeFormattingRequest.php ├── DocumentRangeFormattingClientCapabilities.php ├── DocumentRangeFormattingOptions.php ├── DocumentRangeFormattingParams.php ├── DocumentRangeFormattingRegistrationOptions.php ├── DocumentRangeFormattingRequest.php ├── DocumentSymbol.php ├── DocumentSymbolClientCapabilities.php ├── DocumentSymbolOptions.php ├── DocumentSymbolParams.php ├── DocumentSymbolRegistrationOptions.php ├── DocumentSymbolRequest.php ├── ExecuteCommandClientCapabilities.php ├── ExecuteCommandOptions.php ├── ExecuteCommandParams.php ├── ExecuteCommandRegistrationOptions.php ├── ExecuteCommandRequest.php ├── ExitNotification.php ├── FileChangeType.php ├── FileCreate.php ├── FileDelete.php ├── FileEvent.php ├── FileOperationClientCapabilities.php ├── FileOperationFilter.php ├── FileOperationOptions.php ├── FileOperationPattern.php ├── FileOperationPatternKind.php ├── FileOperationPatternOptions.php ├── FileOperationRegistrationOptions.php ├── FileRename.php ├── FileSystemWatcher.php ├── FoldingRange.php ├── FoldingRangeClientCapabilities.php ├── FoldingRangeKind.php ├── FoldingRangeOptions.php ├── FoldingRangeParams.php ├── FoldingRangeRegistrationOptions.php ├── FoldingRangeRequest.php ├── FormattingOptions.php ├── GeneralClientCapabilities.php ├── Hover.php ├── HoverClientCapabilities.php ├── HoverOptions.php ├── HoverParams.php ├── HoverRegistrationOptions.php ├── HoverRequest.php ├── ImplementationClientCapabilities.php ├── ImplementationOptions.php ├── ImplementationParams.php ├── ImplementationRegistrationOptions.php ├── ImplementationRequest.php ├── InitializeError.php ├── InitializeErrorCodes.php ├── InitializeParams.php ├── InitializeRequest.php ├── InitializeResult.php ├── InitializedNotification.php ├── InitializedParams.php ├── InlayHint.php ├── InlayHintKind.php ├── InlayHintOptions.php ├── InlayHintParams.php ├── InlayHintRefreshRequest.php ├── InlayHintRegistrationOptions.php ├── InlayHintRequest.php ├── InlayHintResolveRequest.php ├── InlineValueEvaluatableExpression.php ├── InlineValueParams.php ├── InlineValueRefreshRequest.php ├── InlineValueRegistrationOptions.php ├── InlineValueRequest.php ├── InlineValueText.php ├── InlineValueVariableLookup.php ├── InsertReplaceEdit.php ├── InsertTextFormat.php ├── InsertTextMode.php ├── Location.php ├── LocationLink.php ├── LogMessageNotification.php ├── LogMessageParams.php ├── MarkdownClientCapabilities.php ├── MarkupContent.php ├── MarkupKind.php ├── MessageActionItem.php ├── MessageType.php ├── NotebookDocumentClientCapabilities.php ├── OptionalVersionedTextDocumentIdentifier.php ├── ParameterInformation.php ├── PartialResultParams.php ├── Position.php ├── PrepareRenameParams.php ├── PrepareRenameRequest.php ├── PrepareSupportDefaultBehavior.php ├── PublishDiagnosticsClientCapabilities.php ├── PublishDiagnosticsNotification.php ├── PublishDiagnosticsParams.php ├── Range.php ├── ReferenceClientCapabilities.php ├── ReferenceContext.php ├── ReferenceOptions.php ├── ReferenceParams.php ├── ReferenceRegistrationOptions.php ├── ReferencesRequest.php ├── Registration.php ├── RegistrationParams.php ├── RegistrationRequest.php ├── RegularExpressionsClientCapabilities.php ├── RelativePattern.php ├── RenameClientCapabilities.php ├── RenameFile.php ├── RenameFileOptions.php ├── RenameFilesParams.php ├── RenameOptions.php ├── RenameParams.php ├── RenameRegistrationOptions.php ├── RenameRequest.php ├── ResourceOperation.php ├── SaveOptions.php ├── SelectionRange.php ├── SelectionRangeClientCapabilities.php ├── SelectionRangeOptions.php ├── SelectionRangeParams.php ├── SelectionRangeRegistrationOptions.php ├── SelectionRangeRequest.php ├── SemanticTokens.php ├── SemanticTokensDelta.php ├── SemanticTokensEdit.php ├── SemanticTokensLegend.php ├── ServerCapabilities.php ├── ShowMessageNotification.php ├── ShowMessageParams.php ├── ShowMessageRequest.php ├── ShowMessageRequestClientCapabilities.php ├── ShowMessageRequestParams.php ├── ShutdownRequest.php ├── SignatureHelp.php ├── SignatureHelpClientCapabilities.php ├── SignatureHelpContext.php ├── SignatureHelpOptions.php ├── SignatureHelpParams.php ├── SignatureHelpRegistrationOptions.php ├── SignatureHelpRequest.php ├── SignatureHelpTriggerKind.php ├── SignatureInformation.php ├── StaticRegistrationOptions.php ├── SymbolInformation.php ├── SymbolKind.php ├── SymbolTag.php ├── TelemetryEventNotification.php ├── TextDocument.php ├── TextDocumentChangeRegistrationOptions.php ├── TextDocumentClientCapabilities.php ├── TextDocumentEdit.php ├── TextDocumentIdentifier.php ├── TextDocumentItem.php ├── TextDocumentPositionParams.php ├── TextDocumentRegistrationOptions.php ├── TextDocumentSaveReason.php ├── TextDocumentSaveRegistrationOptions.php ├── TextDocumentSyncClientCapabilities.php ├── TextDocumentSyncKind.php ├── TextDocumentSyncOptions.php ├── TextEdit.php ├── TextEditChange.php ├── TypeDefinitionClientCapabilities.php ├── TypeDefinitionOptions.php ├── TypeDefinitionParams.php ├── TypeDefinitionRegistrationOptions.php ├── TypeDefinitionRequest.php ├── Unregistration.php ├── UnregistrationParams.php ├── UnregistrationRequest.php ├── VersionedTextDocumentIdentifier.php ├── WatchKind.php ├── WillCreateFilesRequest.php ├── WillDeleteFilesRequest.php ├── WillRenameFilesRequest.php ├── WillSaveTextDocumentNotification.php ├── WillSaveTextDocumentParams.php ├── WillSaveTextDocumentWaitUntilRequest.php ├── WindowClientCapabilities.php ├── WorkDoneProgressBegin.php ├── WorkDoneProgressCancelNotification.php ├── WorkDoneProgressCancelParams.php ├── WorkDoneProgressCreateParams.php ├── WorkDoneProgressCreateRequest.php ├── WorkDoneProgressEnd.php ├── WorkDoneProgressOptions.php ├── WorkDoneProgressParams.php ├── WorkDoneProgressReport.php ├── WorkspaceClientCapabilities.php ├── WorkspaceEdit.php ├── WorkspaceEditClientCapabilities.php ├── WorkspaceFolder.php ├── WorkspaceFoldersChangeEvent.php ├── WorkspaceFoldersInitializeParams.php ├── WorkspaceFoldersRequest.php ├── WorkspaceFoldersServerCapabilities.php ├── WorkspaceSymbol.php ├── WorkspaceSymbolClientCapabilities.php ├── WorkspaceSymbolOptions.php ├── WorkspaceSymbolParams.php ├── WorkspaceSymbolRegistrationOptions.php ├── WorkspaceSymbolRequest.php ├── WorkspaceSymbolResolveRequest.php ├── _InitializeParams.php ├── integer.php └── uinteger.php /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | node_modules/ 3 | php/ 4 | composer.lock 5 | 6 | /vendor/ 7 | /.vscode 8 | /vendor 9 | .php_cs.cache -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | ## License 2 | 3 | ``` 4 | Copyright (c) 2018 Daniel Leech 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is furnished 11 | to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | ``` 24 | 25 | ## Third Party License 26 | 27 | The software is derived from [vscode-languageserver-node](https://github.com/microsoft/vscode-languageserver-node) with the followoing license: 28 | 29 | ``` 30 | Copyright (c) Microsoft Corporation 31 | 32 | All rights reserved. 33 | 34 | MIT License 35 | 36 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation 37 | files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, 38 | modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software 39 | is furnished to do so, subject to the following conditions: 40 | 41 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 42 | 43 | THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 44 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 45 | BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 46 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 47 | ``` 48 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | PHP Language Server Protocol Generator 2 | ====================================== 3 | 4 | ![CI](https://github.com/phpactor/language-server-protocol/workflows/CI/badge.svg) 5 | 6 | This package _transpiles_ the `vscode-language-server-protocol` library to PHP, 7 | providing the protocol classes required to create Language Server 8 | with PHP. 9 | 10 | Notes on using the library 11 | -------------------------- 12 | 13 | Most (if not all) of the upstream Typescript types have no constructors, 14 | therefore the argument order of the constructors can change on _every 15 | release_. 16 | 17 | It is therefore **strongly recommended** to use named arguments. 18 | 19 | Generation 20 | ---------- 21 | 22 | Generating the code: 23 | 24 | - `npm run generate`: Build and transpile 25 | - `npm run watch`: Watch and compile on Typescript changes. 26 | 27 | Running the PHP tests: 28 | 29 | - `composer integrate` 30 | 31 | Usage 32 | ----- 33 | 34 | ### Deserialization 35 | 36 | This library will use the type information form typescript to generate 37 | `fromArray` static constructors for each type: 38 | 39 | ```php 40 | $item = CompletionItem::fromArray([ 41 | 'label' => 'Foobar', 42 | 'kind' => 1, 43 | 'detail' => 'This is foobar', 44 | 'documentation' => [ 45 | 'kind' => 'markdown', 46 | 'value' => 'Foobar', 47 | ], 48 | 'additionalTextEdits' => [ 49 | [ 50 | 'range' => [ 51 | 'start' => [ 52 | 'line' => 5, 53 | 'character' => 10, 54 | ], 55 | 'end' => [ 56 | 'line' => 10, 57 | 'character' => 10, 58 | ], 59 | ], 60 | 'newText' => 'Foobar', 61 | ], 62 | ], 63 | 'command' => [ 64 | 'title' => 'Foobar', 65 | 'command' => 'my.command', 66 | ], 67 | ]); 68 | ``` 69 | 70 | Will return a fully hydrated completion item with concrete sub-types. 71 | 72 | **NOTE**: that when deserializing from a language server client request, it is 73 | probably a good idea to ignore additional parameters (the second argument to 74 | `fromArray`). This is because it is perfectly valid to pass unknown properties 75 | to some of the LSP objects. 76 | 77 | ### Serialization 78 | 79 | Properties in classes are public to enable JSON serialization. Call 80 | `json_encode($lspObject)` to get the valid LSP JSON object. 81 | 82 | Contributing 83 | ------------ 84 | 85 | This package is open source and welcomes contributions! Feel free to open a 86 | pull request on this repository. 87 | 88 | Support 89 | ------- 90 | 91 | - Create an issue on the main [Phpactor](https://github.com/phpactor/phpactor) repository. 92 | - Join the `#phpactor` channel on the Slack [Symfony Devs](https://symfony.com/slack-invite) channel. 93 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "phpactor/language-server-protocol", 3 | "type": "library", 4 | "description": "Langauge Server Protocol for PHP (transpiled)", 5 | "license": "MIT", 6 | "authors": [ 7 | { 8 | "name": "Daniel Leech", 9 | "email": "daniel@dantleech.com" 10 | } 11 | ], 12 | "require": { 13 | "dantleech/invoke": "^2.0", 14 | "php": "^7.3 || ^8.0" 15 | }, 16 | "require-dev": { 17 | "ergebnis/composer-normalize": "^2.0", 18 | "friendsofphp/php-cs-fixer": "^2.17", 19 | "phpstan/phpstan": "^2.0", 20 | "phpunit/phpunit": "^9.2" 21 | }, 22 | "autoload": { 23 | "psr-4": { 24 | "Phpactor\\LanguageServerProtocol\\": "src/" 25 | } 26 | }, 27 | "autoload-dev": { 28 | "psr-4": { 29 | "Phpactor\\LanguageServerProtocol\\Tests\\": "tests/" 30 | } 31 | }, 32 | "minimum-stability": "dev", 33 | "prefer-stable": true, 34 | "scripts": { 35 | "integrate": [ 36 | "./vendor/bin/phpunit", 37 | "./vendor/bin/phpstan analyze" 38 | ] 39 | }, 40 | "extra": { 41 | "branch-alias": { 42 | "dev-master": "0.3.x-dev" 43 | } 44 | }, 45 | "config": { 46 | "allow-plugins": { 47 | "ergebnis/composer-normalize": true 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/ApplyWorkspaceEditRequest.php: -------------------------------------------------------------------------------- 1 | href = $href; 27 | } 28 | 29 | /** 30 | * @param array $array 31 | * @return self 32 | */ 33 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 34 | { 35 | $map = [ 36 | 'href' => ['names' => [], 'iterable' => false], 37 | ]; 38 | 39 | foreach ($array as $key => &$value) { 40 | if (!isset($map[$key])) { 41 | if ($allowUnknownKeys) { 42 | unset($array[$key]); 43 | continue; 44 | } 45 | 46 | throw new RuntimeException(sprintf( 47 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 48 | $key, 49 | self::class, 50 | implode('", "', array_keys($map)) 51 | )); 52 | } 53 | 54 | // from here we only care about arrays that can be transformed into 55 | // objects 56 | if (!is_array($value)) { 57 | continue; 58 | } 59 | 60 | if (empty($map[$key]['names'])) { 61 | continue; 62 | } 63 | 64 | if ($map[$key]['iterable']) { 65 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 66 | if (!is_array($object)) { 67 | return $object; 68 | } 69 | 70 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 71 | }, $value); 72 | continue; 73 | } 74 | 75 | $names = $map[$key]['names']; 76 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 77 | } 78 | 79 | return Invoke::new(self::class, $array); 80 | } 81 | 82 | /** 83 | * @param array $classNames 84 | * @param array $object 85 | */ 86 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 87 | { 88 | $lastException = null; 89 | foreach ($classNames as $className) { 90 | try { 91 | // @phpstan-ignore-next-line 92 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 93 | } catch (Exception $exception) { 94 | $lastException = $exception; 95 | continue; 96 | } 97 | } 98 | 99 | throw $lastException; 100 | } 101 | 102 | } -------------------------------------------------------------------------------- /src/CodeLensClientCapabilities.php: -------------------------------------------------------------------------------- 1 | dynamicRegistration = $dynamicRegistration; 27 | } 28 | 29 | /** 30 | * @param array $array 31 | * @return self 32 | */ 33 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 34 | { 35 | $map = [ 36 | 'dynamicRegistration' => ['names' => [], 'iterable' => false], 37 | ]; 38 | 39 | foreach ($array as $key => &$value) { 40 | if (!isset($map[$key])) { 41 | if ($allowUnknownKeys) { 42 | unset($array[$key]); 43 | continue; 44 | } 45 | 46 | throw new RuntimeException(sprintf( 47 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 48 | $key, 49 | self::class, 50 | implode('", "', array_keys($map)) 51 | )); 52 | } 53 | 54 | // from here we only care about arrays that can be transformed into 55 | // objects 56 | if (!is_array($value)) { 57 | continue; 58 | } 59 | 60 | if (empty($map[$key]['names'])) { 61 | continue; 62 | } 63 | 64 | if ($map[$key]['iterable']) { 65 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 66 | if (!is_array($object)) { 67 | return $object; 68 | } 69 | 70 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 71 | }, $value); 72 | continue; 73 | } 74 | 75 | $names = $map[$key]['names']; 76 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 77 | } 78 | 79 | return Invoke::new(self::class, $array); 80 | } 81 | 82 | /** 83 | * @param array $classNames 84 | * @param array $object 85 | */ 86 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 87 | { 88 | $lastException = null; 89 | foreach ($classNames as $className) { 90 | try { 91 | // @phpstan-ignore-next-line 92 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 93 | } catch (Exception $exception) { 94 | $lastException = $exception; 95 | continue; 96 | } 97 | } 98 | 99 | throw $lastException; 100 | } 101 | 102 | } -------------------------------------------------------------------------------- /src/CodeLensRefreshRequest.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | public $items; 19 | 20 | /** 21 | * @param array $items 22 | */ 23 | public function __construct(array $items) 24 | { 25 | $this->items = $items; 26 | } 27 | 28 | /** 29 | * @param array $array 30 | * @return self 31 | */ 32 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 33 | { 34 | $map = [ 35 | 'items' => ['names' => [ConfigurationItem::class], 'iterable' => true], 36 | ]; 37 | 38 | foreach ($array as $key => &$value) { 39 | if (!isset($map[$key])) { 40 | if ($allowUnknownKeys) { 41 | unset($array[$key]); 42 | continue; 43 | } 44 | 45 | throw new RuntimeException(sprintf( 46 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 47 | $key, 48 | self::class, 49 | implode('", "', array_keys($map)) 50 | )); 51 | } 52 | 53 | // from here we only care about arrays that can be transformed into 54 | // objects 55 | if (!is_array($value)) { 56 | continue; 57 | } 58 | 59 | if (empty($map[$key]['names'])) { 60 | continue; 61 | } 62 | 63 | if ($map[$key]['iterable']) { 64 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 65 | if (!is_array($object)) { 66 | return $object; 67 | } 68 | 69 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 70 | }, $value); 71 | continue; 72 | } 73 | 74 | $names = $map[$key]['names']; 75 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 76 | } 77 | 78 | return Invoke::new(self::class, $array); 79 | } 80 | 81 | /** 82 | * @param array $classNames 83 | * @param array $object 84 | */ 85 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 86 | { 87 | $lastException = null; 88 | foreach ($classNames as $className) { 89 | try { 90 | // @phpstan-ignore-next-line 91 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 92 | } catch (Exception $exception) { 93 | $lastException = $exception; 94 | continue; 95 | } 96 | } 97 | 98 | throw $lastException; 99 | } 100 | 101 | } -------------------------------------------------------------------------------- /src/ConfigurationRequest.php: -------------------------------------------------------------------------------- 1 | 19 | */ 20 | public $files; 21 | 22 | /** 23 | * @param array $files 24 | */ 25 | public function __construct(array $files) 26 | { 27 | $this->files = $files; 28 | } 29 | 30 | /** 31 | * @param array $array 32 | * @return self 33 | */ 34 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 35 | { 36 | $map = [ 37 | 'files' => ['names' => [FileCreate::class], 'iterable' => true], 38 | ]; 39 | 40 | foreach ($array as $key => &$value) { 41 | if (!isset($map[$key])) { 42 | if ($allowUnknownKeys) { 43 | unset($array[$key]); 44 | continue; 45 | } 46 | 47 | throw new RuntimeException(sprintf( 48 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 49 | $key, 50 | self::class, 51 | implode('", "', array_keys($map)) 52 | )); 53 | } 54 | 55 | // from here we only care about arrays that can be transformed into 56 | // objects 57 | if (!is_array($value)) { 58 | continue; 59 | } 60 | 61 | if (empty($map[$key]['names'])) { 62 | continue; 63 | } 64 | 65 | if ($map[$key]['iterable']) { 66 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 67 | if (!is_array($object)) { 68 | return $object; 69 | } 70 | 71 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 72 | }, $value); 73 | continue; 74 | } 75 | 76 | $names = $map[$key]['names']; 77 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 78 | } 79 | 80 | return Invoke::new(self::class, $array); 81 | } 82 | 83 | /** 84 | * @param array $classNames 85 | * @param array $object 86 | */ 87 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 88 | { 89 | $lastException = null; 90 | foreach ($classNames as $className) { 91 | try { 92 | // @phpstan-ignore-next-line 93 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 94 | } catch (Exception $exception) { 95 | $lastException = $exception; 96 | continue; 97 | } 98 | } 99 | 100 | throw $lastException; 101 | } 102 | 103 | } -------------------------------------------------------------------------------- /src/DeclarationOptions.php: -------------------------------------------------------------------------------- 1 | workDoneProgress = $workDoneProgress; 26 | } 27 | 28 | /** 29 | * @param array $array 30 | * @return self 31 | */ 32 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 33 | { 34 | $map = [ 35 | 'workDoneProgress' => ['names' => [], 'iterable' => false], 36 | ]; 37 | 38 | foreach ($array as $key => &$value) { 39 | if (!isset($map[$key])) { 40 | if ($allowUnknownKeys) { 41 | unset($array[$key]); 42 | continue; 43 | } 44 | 45 | throw new RuntimeException(sprintf( 46 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 47 | $key, 48 | self::class, 49 | implode('", "', array_keys($map)) 50 | )); 51 | } 52 | 53 | // from here we only care about arrays that can be transformed into 54 | // objects 55 | if (!is_array($value)) { 56 | continue; 57 | } 58 | 59 | if (empty($map[$key]['names'])) { 60 | continue; 61 | } 62 | 63 | if ($map[$key]['iterable']) { 64 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 65 | if (!is_array($object)) { 66 | return $object; 67 | } 68 | 69 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 70 | }, $value); 71 | continue; 72 | } 73 | 74 | $names = $map[$key]['names']; 75 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 76 | } 77 | 78 | return Invoke::new(self::class, $array); 79 | } 80 | 81 | /** 82 | * @param array $classNames 83 | * @param array $object 84 | */ 85 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 86 | { 87 | $lastException = null; 88 | foreach ($classNames as $className) { 89 | try { 90 | // @phpstan-ignore-next-line 91 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 92 | } catch (Exception $exception) { 93 | $lastException = $exception; 94 | continue; 95 | } 96 | } 97 | 98 | throw $lastException; 99 | } 100 | 101 | } -------------------------------------------------------------------------------- /src/DeclarationRequest.php: -------------------------------------------------------------------------------- 1 | workDoneProgress = $workDoneProgress; 28 | } 29 | 30 | /** 31 | * @param array $array 32 | * @return self 33 | */ 34 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 35 | { 36 | $map = [ 37 | 'workDoneProgress' => ['names' => [], 'iterable' => false], 38 | ]; 39 | 40 | foreach ($array as $key => &$value) { 41 | if (!isset($map[$key])) { 42 | if ($allowUnknownKeys) { 43 | unset($array[$key]); 44 | continue; 45 | } 46 | 47 | throw new RuntimeException(sprintf( 48 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 49 | $key, 50 | self::class, 51 | implode('", "', array_keys($map)) 52 | )); 53 | } 54 | 55 | // from here we only care about arrays that can be transformed into 56 | // objects 57 | if (!is_array($value)) { 58 | continue; 59 | } 60 | 61 | if (empty($map[$key]['names'])) { 62 | continue; 63 | } 64 | 65 | if ($map[$key]['iterable']) { 66 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 67 | if (!is_array($object)) { 68 | return $object; 69 | } 70 | 71 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 72 | }, $value); 73 | continue; 74 | } 75 | 76 | $names = $map[$key]['names']; 77 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 78 | } 79 | 80 | return Invoke::new(self::class, $array); 81 | } 82 | 83 | /** 84 | * @param array $classNames 85 | * @param array $object 86 | */ 87 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 88 | { 89 | $lastException = null; 90 | foreach ($classNames as $className) { 91 | try { 92 | // @phpstan-ignore-next-line 93 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 94 | } catch (Exception $exception) { 95 | $lastException = $exception; 96 | continue; 97 | } 98 | } 99 | 100 | throw $lastException; 101 | } 102 | 103 | } -------------------------------------------------------------------------------- /src/DefinitionRequest.php: -------------------------------------------------------------------------------- 1 | 19 | */ 20 | public $files; 21 | 22 | /** 23 | * @param array $files 24 | */ 25 | public function __construct(array $files) 26 | { 27 | $this->files = $files; 28 | } 29 | 30 | /** 31 | * @param array $array 32 | * @return self 33 | */ 34 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 35 | { 36 | $map = [ 37 | 'files' => ['names' => [FileDelete::class], 'iterable' => true], 38 | ]; 39 | 40 | foreach ($array as $key => &$value) { 41 | if (!isset($map[$key])) { 42 | if ($allowUnknownKeys) { 43 | unset($array[$key]); 44 | continue; 45 | } 46 | 47 | throw new RuntimeException(sprintf( 48 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 49 | $key, 50 | self::class, 51 | implode('", "', array_keys($map)) 52 | )); 53 | } 54 | 55 | // from here we only care about arrays that can be transformed into 56 | // objects 57 | if (!is_array($value)) { 58 | continue; 59 | } 60 | 61 | if (empty($map[$key]['names'])) { 62 | continue; 63 | } 64 | 65 | if ($map[$key]['iterable']) { 66 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 67 | if (!is_array($object)) { 68 | return $object; 69 | } 70 | 71 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 72 | }, $value); 73 | continue; 74 | } 75 | 76 | $names = $map[$key]['names']; 77 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 78 | } 79 | 80 | return Invoke::new(self::class, $array); 81 | } 82 | 83 | /** 84 | * @param array $classNames 85 | * @param array $object 86 | */ 87 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 88 | { 89 | $lastException = null; 90 | foreach ($classNames as $className) { 91 | try { 92 | // @phpstan-ignore-next-line 93 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 94 | } catch (Exception $exception) { 95 | $lastException = $exception; 96 | continue; 97 | } 98 | } 99 | 100 | throw $lastException; 101 | } 102 | 103 | } -------------------------------------------------------------------------------- /src/DiagnosticSeverity.php: -------------------------------------------------------------------------------- 1 | dynamicRegistration = $dynamicRegistration; 24 | } 25 | 26 | /** 27 | * @param array $array 28 | * @return self 29 | */ 30 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 31 | { 32 | $map = [ 33 | 'dynamicRegistration' => ['names' => [], 'iterable' => false], 34 | ]; 35 | 36 | foreach ($array as $key => &$value) { 37 | if (!isset($map[$key])) { 38 | if ($allowUnknownKeys) { 39 | unset($array[$key]); 40 | continue; 41 | } 42 | 43 | throw new RuntimeException(sprintf( 44 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 45 | $key, 46 | self::class, 47 | implode('", "', array_keys($map)) 48 | )); 49 | } 50 | 51 | // from here we only care about arrays that can be transformed into 52 | // objects 53 | if (!is_array($value)) { 54 | continue; 55 | } 56 | 57 | if (empty($map[$key]['names'])) { 58 | continue; 59 | } 60 | 61 | if ($map[$key]['iterable']) { 62 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 63 | if (!is_array($object)) { 64 | return $object; 65 | } 66 | 67 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 68 | }, $value); 69 | continue; 70 | } 71 | 72 | $names = $map[$key]['names']; 73 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 74 | } 75 | 76 | return Invoke::new(self::class, $array); 77 | } 78 | 79 | /** 80 | * @param array $classNames 81 | * @param array $object 82 | */ 83 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 84 | { 85 | $lastException = null; 86 | foreach ($classNames as $className) { 87 | try { 88 | // @phpstan-ignore-next-line 89 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 90 | } catch (Exception $exception) { 91 | $lastException = $exception; 92 | continue; 93 | } 94 | } 95 | 96 | throw $lastException; 97 | } 98 | 99 | } -------------------------------------------------------------------------------- /src/DidChangeConfigurationNotification.php: -------------------------------------------------------------------------------- 1 | settings = $settings; 27 | } 28 | 29 | /** 30 | * @param array $array 31 | * @return self 32 | */ 33 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 34 | { 35 | $map = [ 36 | 'settings' => ['names' => [], 'iterable' => false], 37 | ]; 38 | 39 | foreach ($array as $key => &$value) { 40 | if (!isset($map[$key])) { 41 | if ($allowUnknownKeys) { 42 | unset($array[$key]); 43 | continue; 44 | } 45 | 46 | throw new RuntimeException(sprintf( 47 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 48 | $key, 49 | self::class, 50 | implode('", "', array_keys($map)) 51 | )); 52 | } 53 | 54 | // from here we only care about arrays that can be transformed into 55 | // objects 56 | if (!is_array($value)) { 57 | continue; 58 | } 59 | 60 | if (empty($map[$key]['names'])) { 61 | continue; 62 | } 63 | 64 | if ($map[$key]['iterable']) { 65 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 66 | if (!is_array($object)) { 67 | return $object; 68 | } 69 | 70 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 71 | }, $value); 72 | continue; 73 | } 74 | 75 | $names = $map[$key]['names']; 76 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 77 | } 78 | 79 | return Invoke::new(self::class, $array); 80 | } 81 | 82 | /** 83 | * @param array $classNames 84 | * @param array $object 85 | */ 86 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 87 | { 88 | $lastException = null; 89 | foreach ($classNames as $className) { 90 | try { 91 | // @phpstan-ignore-next-line 92 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 93 | } catch (Exception $exception) { 94 | $lastException = $exception; 95 | continue; 96 | } 97 | } 98 | 99 | throw $lastException; 100 | } 101 | 102 | } -------------------------------------------------------------------------------- /src/DidChangeConfigurationRegistrationOptions.php: -------------------------------------------------------------------------------- 1 | |null 14 | */ 15 | public $section; 16 | 17 | /** 18 | * @param string|array|null $section 19 | */ 20 | public function __construct($section = null) 21 | { 22 | $this->section = $section; 23 | } 24 | 25 | /** 26 | * @param array $array 27 | * @return self 28 | */ 29 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 30 | { 31 | $map = [ 32 | 'section' => ['names' => [], 'iterable' => false], 33 | ]; 34 | 35 | foreach ($array as $key => &$value) { 36 | if (!isset($map[$key])) { 37 | if ($allowUnknownKeys) { 38 | unset($array[$key]); 39 | continue; 40 | } 41 | 42 | throw new RuntimeException(sprintf( 43 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 44 | $key, 45 | self::class, 46 | implode('", "', array_keys($map)) 47 | )); 48 | } 49 | 50 | // from here we only care about arrays that can be transformed into 51 | // objects 52 | if (!is_array($value)) { 53 | continue; 54 | } 55 | 56 | if (empty($map[$key]['names'])) { 57 | continue; 58 | } 59 | 60 | if ($map[$key]['iterable']) { 61 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 62 | if (!is_array($object)) { 63 | return $object; 64 | } 65 | 66 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 67 | }, $value); 68 | continue; 69 | } 70 | 71 | $names = $map[$key]['names']; 72 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 73 | } 74 | 75 | return Invoke::new(self::class, $array); 76 | } 77 | 78 | /** 79 | * @param array $classNames 80 | * @param array $object 81 | */ 82 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 83 | { 84 | $lastException = null; 85 | foreach ($classNames as $className) { 86 | try { 87 | // @phpstan-ignore-next-line 88 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 89 | } catch (Exception $exception) { 90 | $lastException = $exception; 91 | continue; 92 | } 93 | } 94 | 95 | throw $lastException; 96 | } 97 | 98 | } -------------------------------------------------------------------------------- /src/DidChangeTextDocumentNotification.php: -------------------------------------------------------------------------------- 1 | 18 | */ 19 | public $changes; 20 | 21 | /** 22 | * @param array $changes 23 | */ 24 | public function __construct(array $changes) 25 | { 26 | $this->changes = $changes; 27 | } 28 | 29 | /** 30 | * @param array $array 31 | * @return self 32 | */ 33 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 34 | { 35 | $map = [ 36 | 'changes' => ['names' => [FileEvent::class], 'iterable' => true], 37 | ]; 38 | 39 | foreach ($array as $key => &$value) { 40 | if (!isset($map[$key])) { 41 | if ($allowUnknownKeys) { 42 | unset($array[$key]); 43 | continue; 44 | } 45 | 46 | throw new RuntimeException(sprintf( 47 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 48 | $key, 49 | self::class, 50 | implode('", "', array_keys($map)) 51 | )); 52 | } 53 | 54 | // from here we only care about arrays that can be transformed into 55 | // objects 56 | if (!is_array($value)) { 57 | continue; 58 | } 59 | 60 | if (empty($map[$key]['names'])) { 61 | continue; 62 | } 63 | 64 | if ($map[$key]['iterable']) { 65 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 66 | if (!is_array($object)) { 67 | return $object; 68 | } 69 | 70 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 71 | }, $value); 72 | continue; 73 | } 74 | 75 | $names = $map[$key]['names']; 76 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 77 | } 78 | 79 | return Invoke::new(self::class, $array); 80 | } 81 | 82 | /** 83 | * @param array $classNames 84 | * @param array $object 85 | */ 86 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 87 | { 88 | $lastException = null; 89 | foreach ($classNames as $className) { 90 | try { 91 | // @phpstan-ignore-next-line 92 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 93 | } catch (Exception $exception) { 94 | $lastException = $exception; 95 | continue; 96 | } 97 | } 98 | 99 | throw $lastException; 100 | } 101 | 102 | } -------------------------------------------------------------------------------- /src/DidChangeWatchedFilesRegistrationOptions.php: -------------------------------------------------------------------------------- 1 | 18 | */ 19 | public $watchers; 20 | 21 | /** 22 | * @param array $watchers 23 | */ 24 | public function __construct(array $watchers) 25 | { 26 | $this->watchers = $watchers; 27 | } 28 | 29 | /** 30 | * @param array $array 31 | * @return self 32 | */ 33 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 34 | { 35 | $map = [ 36 | 'watchers' => ['names' => [FileSystemWatcher::class], 'iterable' => true], 37 | ]; 38 | 39 | foreach ($array as $key => &$value) { 40 | if (!isset($map[$key])) { 41 | if ($allowUnknownKeys) { 42 | unset($array[$key]); 43 | continue; 44 | } 45 | 46 | throw new RuntimeException(sprintf( 47 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 48 | $key, 49 | self::class, 50 | implode('", "', array_keys($map)) 51 | )); 52 | } 53 | 54 | // from here we only care about arrays that can be transformed into 55 | // objects 56 | if (!is_array($value)) { 57 | continue; 58 | } 59 | 60 | if (empty($map[$key]['names'])) { 61 | continue; 62 | } 63 | 64 | if ($map[$key]['iterable']) { 65 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 66 | if (!is_array($object)) { 67 | return $object; 68 | } 69 | 70 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 71 | }, $value); 72 | continue; 73 | } 74 | 75 | $names = $map[$key]['names']; 76 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 77 | } 78 | 79 | return Invoke::new(self::class, $array); 80 | } 81 | 82 | /** 83 | * @param array $classNames 84 | * @param array $object 85 | */ 86 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 87 | { 88 | $lastException = null; 89 | foreach ($classNames as $className) { 90 | try { 91 | // @phpstan-ignore-next-line 92 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 93 | } catch (Exception $exception) { 94 | $lastException = $exception; 95 | continue; 96 | } 97 | } 98 | 99 | throw $lastException; 100 | } 101 | 102 | } -------------------------------------------------------------------------------- /src/DidChangeWorkspaceFoldersNotification.php: -------------------------------------------------------------------------------- 1 | event = $event; 27 | } 28 | 29 | /** 30 | * @param array $array 31 | * @return self 32 | */ 33 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 34 | { 35 | $map = [ 36 | 'event' => ['names' => [WorkspaceFoldersChangeEvent::class], 'iterable' => false], 37 | ]; 38 | 39 | foreach ($array as $key => &$value) { 40 | if (!isset($map[$key])) { 41 | if ($allowUnknownKeys) { 42 | unset($array[$key]); 43 | continue; 44 | } 45 | 46 | throw new RuntimeException(sprintf( 47 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 48 | $key, 49 | self::class, 50 | implode('", "', array_keys($map)) 51 | )); 52 | } 53 | 54 | // from here we only care about arrays that can be transformed into 55 | // objects 56 | if (!is_array($value)) { 57 | continue; 58 | } 59 | 60 | if (empty($map[$key]['names'])) { 61 | continue; 62 | } 63 | 64 | if ($map[$key]['iterable']) { 65 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 66 | if (!is_array($object)) { 67 | return $object; 68 | } 69 | 70 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 71 | }, $value); 72 | continue; 73 | } 74 | 75 | $names = $map[$key]['names']; 76 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 77 | } 78 | 79 | return Invoke::new(self::class, $array); 80 | } 81 | 82 | /** 83 | * @param array $classNames 84 | * @param array $object 85 | */ 86 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 87 | { 88 | $lastException = null; 89 | foreach ($classNames as $className) { 90 | try { 91 | // @phpstan-ignore-next-line 92 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 93 | } catch (Exception $exception) { 94 | $lastException = $exception; 95 | continue; 96 | } 97 | } 98 | 99 | throw $lastException; 100 | } 101 | 102 | } -------------------------------------------------------------------------------- /src/DidCloseTextDocumentNotification.php: -------------------------------------------------------------------------------- 1 | textDocument = $textDocument; 27 | } 28 | 29 | /** 30 | * @param array $array 31 | * @return self 32 | */ 33 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 34 | { 35 | $map = [ 36 | 'textDocument' => ['names' => [TextDocumentIdentifier::class], 'iterable' => false], 37 | ]; 38 | 39 | foreach ($array as $key => &$value) { 40 | if (!isset($map[$key])) { 41 | if ($allowUnknownKeys) { 42 | unset($array[$key]); 43 | continue; 44 | } 45 | 46 | throw new RuntimeException(sprintf( 47 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 48 | $key, 49 | self::class, 50 | implode('", "', array_keys($map)) 51 | )); 52 | } 53 | 54 | // from here we only care about arrays that can be transformed into 55 | // objects 56 | if (!is_array($value)) { 57 | continue; 58 | } 59 | 60 | if (empty($map[$key]['names'])) { 61 | continue; 62 | } 63 | 64 | if ($map[$key]['iterable']) { 65 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 66 | if (!is_array($object)) { 67 | return $object; 68 | } 69 | 70 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 71 | }, $value); 72 | continue; 73 | } 74 | 75 | $names = $map[$key]['names']; 76 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 77 | } 78 | 79 | return Invoke::new(self::class, $array); 80 | } 81 | 82 | /** 83 | * @param array $classNames 84 | * @param array $object 85 | */ 86 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 87 | { 88 | $lastException = null; 89 | foreach ($classNames as $className) { 90 | try { 91 | // @phpstan-ignore-next-line 92 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 93 | } catch (Exception $exception) { 94 | $lastException = $exception; 95 | continue; 96 | } 97 | } 98 | 99 | throw $lastException; 100 | } 101 | 102 | } -------------------------------------------------------------------------------- /src/DidCreateFilesNotification.php: -------------------------------------------------------------------------------- 1 | textDocument = $textDocument; 27 | } 28 | 29 | /** 30 | * @param array $array 31 | * @return self 32 | */ 33 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 34 | { 35 | $map = [ 36 | 'textDocument' => ['names' => [TextDocumentItem::class], 'iterable' => false], 37 | ]; 38 | 39 | foreach ($array as $key => &$value) { 40 | if (!isset($map[$key])) { 41 | if ($allowUnknownKeys) { 42 | unset($array[$key]); 43 | continue; 44 | } 45 | 46 | throw new RuntimeException(sprintf( 47 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 48 | $key, 49 | self::class, 50 | implode('", "', array_keys($map)) 51 | )); 52 | } 53 | 54 | // from here we only care about arrays that can be transformed into 55 | // objects 56 | if (!is_array($value)) { 57 | continue; 58 | } 59 | 60 | if (empty($map[$key]['names'])) { 61 | continue; 62 | } 63 | 64 | if ($map[$key]['iterable']) { 65 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 66 | if (!is_array($object)) { 67 | return $object; 68 | } 69 | 70 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 71 | }, $value); 72 | continue; 73 | } 74 | 75 | $names = $map[$key]['names']; 76 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 77 | } 78 | 79 | return Invoke::new(self::class, $array); 80 | } 81 | 82 | /** 83 | * @param array $classNames 84 | * @param array $object 85 | */ 86 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 87 | { 88 | $lastException = null; 89 | foreach ($classNames as $className) { 90 | try { 91 | // @phpstan-ignore-next-line 92 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 93 | } catch (Exception $exception) { 94 | $lastException = $exception; 95 | continue; 96 | } 97 | } 98 | 99 | throw $lastException; 100 | } 101 | 102 | } -------------------------------------------------------------------------------- /src/DidRenameFilesNotification.php: -------------------------------------------------------------------------------- 1 | dynamicRegistration = $dynamicRegistration; 26 | } 27 | 28 | /** 29 | * @param array $array 30 | * @return self 31 | */ 32 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 33 | { 34 | $map = [ 35 | 'dynamicRegistration' => ['names' => [], 'iterable' => false], 36 | ]; 37 | 38 | foreach ($array as $key => &$value) { 39 | if (!isset($map[$key])) { 40 | if ($allowUnknownKeys) { 41 | unset($array[$key]); 42 | continue; 43 | } 44 | 45 | throw new RuntimeException(sprintf( 46 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 47 | $key, 48 | self::class, 49 | implode('", "', array_keys($map)) 50 | )); 51 | } 52 | 53 | // from here we only care about arrays that can be transformed into 54 | // objects 55 | if (!is_array($value)) { 56 | continue; 57 | } 58 | 59 | if (empty($map[$key]['names'])) { 60 | continue; 61 | } 62 | 63 | if ($map[$key]['iterable']) { 64 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 65 | if (!is_array($object)) { 66 | return $object; 67 | } 68 | 69 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 70 | }, $value); 71 | continue; 72 | } 73 | 74 | $names = $map[$key]['names']; 75 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 76 | } 77 | 78 | return Invoke::new(self::class, $array); 79 | } 80 | 81 | /** 82 | * @param array $classNames 83 | * @param array $object 84 | */ 85 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 86 | { 87 | $lastException = null; 88 | foreach ($classNames as $className) { 89 | try { 90 | // @phpstan-ignore-next-line 91 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 92 | } catch (Exception $exception) { 93 | $lastException = $exception; 94 | continue; 95 | } 96 | } 97 | 98 | throw $lastException; 99 | } 100 | 101 | } -------------------------------------------------------------------------------- /src/DocumentColorOptions.php: -------------------------------------------------------------------------------- 1 | workDoneProgress = $workDoneProgress; 26 | } 27 | 28 | /** 29 | * @param array $array 30 | * @return self 31 | */ 32 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 33 | { 34 | $map = [ 35 | 'workDoneProgress' => ['names' => [], 'iterable' => false], 36 | ]; 37 | 38 | foreach ($array as $key => &$value) { 39 | if (!isset($map[$key])) { 40 | if ($allowUnknownKeys) { 41 | unset($array[$key]); 42 | continue; 43 | } 44 | 45 | throw new RuntimeException(sprintf( 46 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 47 | $key, 48 | self::class, 49 | implode('", "', array_keys($map)) 50 | )); 51 | } 52 | 53 | // from here we only care about arrays that can be transformed into 54 | // objects 55 | if (!is_array($value)) { 56 | continue; 57 | } 58 | 59 | if (empty($map[$key]['names'])) { 60 | continue; 61 | } 62 | 63 | if ($map[$key]['iterable']) { 64 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 65 | if (!is_array($object)) { 66 | return $object; 67 | } 68 | 69 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 70 | }, $value); 71 | continue; 72 | } 73 | 74 | $names = $map[$key]['names']; 75 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 76 | } 77 | 78 | return Invoke::new(self::class, $array); 79 | } 80 | 81 | /** 82 | * @param array $classNames 83 | * @param array $object 84 | */ 85 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 86 | { 87 | $lastException = null; 88 | foreach ($classNames as $className) { 89 | try { 90 | // @phpstan-ignore-next-line 91 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 92 | } catch (Exception $exception) { 93 | $lastException = $exception; 94 | continue; 95 | } 96 | } 97 | 98 | throw $lastException; 99 | } 100 | 101 | } -------------------------------------------------------------------------------- /src/DocumentColorRequest.php: -------------------------------------------------------------------------------- 1 | dynamicRegistration = $dynamicRegistration; 27 | } 28 | 29 | /** 30 | * @param array $array 31 | * @return self 32 | */ 33 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 34 | { 35 | $map = [ 36 | 'dynamicRegistration' => ['names' => [], 'iterable' => false], 37 | ]; 38 | 39 | foreach ($array as $key => &$value) { 40 | if (!isset($map[$key])) { 41 | if ($allowUnknownKeys) { 42 | unset($array[$key]); 43 | continue; 44 | } 45 | 46 | throw new RuntimeException(sprintf( 47 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 48 | $key, 49 | self::class, 50 | implode('", "', array_keys($map)) 51 | )); 52 | } 53 | 54 | // from here we only care about arrays that can be transformed into 55 | // objects 56 | if (!is_array($value)) { 57 | continue; 58 | } 59 | 60 | if (empty($map[$key]['names'])) { 61 | continue; 62 | } 63 | 64 | if ($map[$key]['iterable']) { 65 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 66 | if (!is_array($object)) { 67 | return $object; 68 | } 69 | 70 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 71 | }, $value); 72 | continue; 73 | } 74 | 75 | $names = $map[$key]['names']; 76 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 77 | } 78 | 79 | return Invoke::new(self::class, $array); 80 | } 81 | 82 | /** 83 | * @param array $classNames 84 | * @param array $object 85 | */ 86 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 87 | { 88 | $lastException = null; 89 | foreach ($classNames as $className) { 90 | try { 91 | // @phpstan-ignore-next-line 92 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 93 | } catch (Exception $exception) { 94 | $lastException = $exception; 95 | continue; 96 | } 97 | } 98 | 99 | throw $lastException; 100 | } 101 | 102 | } -------------------------------------------------------------------------------- /src/DocumentFormattingOptions.php: -------------------------------------------------------------------------------- 1 | workDoneProgress = $workDoneProgress; 28 | } 29 | 30 | /** 31 | * @param array $array 32 | * @return self 33 | */ 34 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 35 | { 36 | $map = [ 37 | 'workDoneProgress' => ['names' => [], 'iterable' => false], 38 | ]; 39 | 40 | foreach ($array as $key => &$value) { 41 | if (!isset($map[$key])) { 42 | if ($allowUnknownKeys) { 43 | unset($array[$key]); 44 | continue; 45 | } 46 | 47 | throw new RuntimeException(sprintf( 48 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 49 | $key, 50 | self::class, 51 | implode('", "', array_keys($map)) 52 | )); 53 | } 54 | 55 | // from here we only care about arrays that can be transformed into 56 | // objects 57 | if (!is_array($value)) { 58 | continue; 59 | } 60 | 61 | if (empty($map[$key]['names'])) { 62 | continue; 63 | } 64 | 65 | if ($map[$key]['iterable']) { 66 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 67 | if (!is_array($object)) { 68 | return $object; 69 | } 70 | 71 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 72 | }, $value); 73 | continue; 74 | } 75 | 76 | $names = $map[$key]['names']; 77 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 78 | } 79 | 80 | return Invoke::new(self::class, $array); 81 | } 82 | 83 | /** 84 | * @param array $classNames 85 | * @param array $object 86 | */ 87 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 88 | { 89 | $lastException = null; 90 | foreach ($classNames as $className) { 91 | try { 92 | // @phpstan-ignore-next-line 93 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 94 | } catch (Exception $exception) { 95 | $lastException = $exception; 96 | continue; 97 | } 98 | } 99 | 100 | throw $lastException; 101 | } 102 | 103 | } -------------------------------------------------------------------------------- /src/DocumentFormattingRequest.php: -------------------------------------------------------------------------------- 1 | dynamicRegistration = $dynamicRegistration; 27 | } 28 | 29 | /** 30 | * @param array $array 31 | * @return self 32 | */ 33 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 34 | { 35 | $map = [ 36 | 'dynamicRegistration' => ['names' => [], 'iterable' => false], 37 | ]; 38 | 39 | foreach ($array as $key => &$value) { 40 | if (!isset($map[$key])) { 41 | if ($allowUnknownKeys) { 42 | unset($array[$key]); 43 | continue; 44 | } 45 | 46 | throw new RuntimeException(sprintf( 47 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 48 | $key, 49 | self::class, 50 | implode('", "', array_keys($map)) 51 | )); 52 | } 53 | 54 | // from here we only care about arrays that can be transformed into 55 | // objects 56 | if (!is_array($value)) { 57 | continue; 58 | } 59 | 60 | if (empty($map[$key]['names'])) { 61 | continue; 62 | } 63 | 64 | if ($map[$key]['iterable']) { 65 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 66 | if (!is_array($object)) { 67 | return $object; 68 | } 69 | 70 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 71 | }, $value); 72 | continue; 73 | } 74 | 75 | $names = $map[$key]['names']; 76 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 77 | } 78 | 79 | return Invoke::new(self::class, $array); 80 | } 81 | 82 | /** 83 | * @param array $classNames 84 | * @param array $object 85 | */ 86 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 87 | { 88 | $lastException = null; 89 | foreach ($classNames as $className) { 90 | try { 91 | // @phpstan-ignore-next-line 92 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 93 | } catch (Exception $exception) { 94 | $lastException = $exception; 95 | continue; 96 | } 97 | } 98 | 99 | throw $lastException; 100 | } 101 | 102 | } -------------------------------------------------------------------------------- /src/DocumentHighlightKind.php: -------------------------------------------------------------------------------- 1 | workDoneProgress = $workDoneProgress; 28 | } 29 | 30 | /** 31 | * @param array $array 32 | * @return self 33 | */ 34 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 35 | { 36 | $map = [ 37 | 'workDoneProgress' => ['names' => [], 'iterable' => false], 38 | ]; 39 | 40 | foreach ($array as $key => &$value) { 41 | if (!isset($map[$key])) { 42 | if ($allowUnknownKeys) { 43 | unset($array[$key]); 44 | continue; 45 | } 46 | 47 | throw new RuntimeException(sprintf( 48 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 49 | $key, 50 | self::class, 51 | implode('", "', array_keys($map)) 52 | )); 53 | } 54 | 55 | // from here we only care about arrays that can be transformed into 56 | // objects 57 | if (!is_array($value)) { 58 | continue; 59 | } 60 | 61 | if (empty($map[$key]['names'])) { 62 | continue; 63 | } 64 | 65 | if ($map[$key]['iterable']) { 66 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 67 | if (!is_array($object)) { 68 | return $object; 69 | } 70 | 71 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 72 | }, $value); 73 | continue; 74 | } 75 | 76 | $names = $map[$key]['names']; 77 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 78 | } 79 | 80 | return Invoke::new(self::class, $array); 81 | } 82 | 83 | /** 84 | * @param array $classNames 85 | * @param array $object 86 | */ 87 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 88 | { 89 | $lastException = null; 90 | foreach ($classNames as $className) { 91 | try { 92 | // @phpstan-ignore-next-line 93 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 94 | } catch (Exception $exception) { 95 | $lastException = $exception; 96 | continue; 97 | } 98 | } 99 | 100 | throw $lastException; 101 | } 102 | 103 | } -------------------------------------------------------------------------------- /src/DocumentHighlightRequest.php: -------------------------------------------------------------------------------- 1 | dynamicRegistration = $dynamicRegistration; 27 | } 28 | 29 | /** 30 | * @param array $array 31 | * @return self 32 | */ 33 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 34 | { 35 | $map = [ 36 | 'dynamicRegistration' => ['names' => [], 'iterable' => false], 37 | ]; 38 | 39 | foreach ($array as $key => &$value) { 40 | if (!isset($map[$key])) { 41 | if ($allowUnknownKeys) { 42 | unset($array[$key]); 43 | continue; 44 | } 45 | 46 | throw new RuntimeException(sprintf( 47 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 48 | $key, 49 | self::class, 50 | implode('", "', array_keys($map)) 51 | )); 52 | } 53 | 54 | // from here we only care about arrays that can be transformed into 55 | // objects 56 | if (!is_array($value)) { 57 | continue; 58 | } 59 | 60 | if (empty($map[$key]['names'])) { 61 | continue; 62 | } 63 | 64 | if ($map[$key]['iterable']) { 65 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 66 | if (!is_array($object)) { 67 | return $object; 68 | } 69 | 70 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 71 | }, $value); 72 | continue; 73 | } 74 | 75 | $names = $map[$key]['names']; 76 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 77 | } 78 | 79 | return Invoke::new(self::class, $array); 80 | } 81 | 82 | /** 83 | * @param array $classNames 84 | * @param array $object 85 | */ 86 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 87 | { 88 | $lastException = null; 89 | foreach ($classNames as $className) { 90 | try { 91 | // @phpstan-ignore-next-line 92 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 93 | } catch (Exception $exception) { 94 | $lastException = $exception; 95 | continue; 96 | } 97 | } 98 | 99 | throw $lastException; 100 | } 101 | 102 | } -------------------------------------------------------------------------------- /src/DocumentOnTypeFormattingRequest.php: -------------------------------------------------------------------------------- 1 | dynamicRegistration = $dynamicRegistration; 27 | } 28 | 29 | /** 30 | * @param array $array 31 | * @return self 32 | */ 33 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 34 | { 35 | $map = [ 36 | 'dynamicRegistration' => ['names' => [], 'iterable' => false], 37 | ]; 38 | 39 | foreach ($array as $key => &$value) { 40 | if (!isset($map[$key])) { 41 | if ($allowUnknownKeys) { 42 | unset($array[$key]); 43 | continue; 44 | } 45 | 46 | throw new RuntimeException(sprintf( 47 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 48 | $key, 49 | self::class, 50 | implode('", "', array_keys($map)) 51 | )); 52 | } 53 | 54 | // from here we only care about arrays that can be transformed into 55 | // objects 56 | if (!is_array($value)) { 57 | continue; 58 | } 59 | 60 | if (empty($map[$key]['names'])) { 61 | continue; 62 | } 63 | 64 | if ($map[$key]['iterable']) { 65 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 66 | if (!is_array($object)) { 67 | return $object; 68 | } 69 | 70 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 71 | }, $value); 72 | continue; 73 | } 74 | 75 | $names = $map[$key]['names']; 76 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 77 | } 78 | 79 | return Invoke::new(self::class, $array); 80 | } 81 | 82 | /** 83 | * @param array $classNames 84 | * @param array $object 85 | */ 86 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 87 | { 88 | $lastException = null; 89 | foreach ($classNames as $className) { 90 | try { 91 | // @phpstan-ignore-next-line 92 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 93 | } catch (Exception $exception) { 94 | $lastException = $exception; 95 | continue; 96 | } 97 | } 98 | 99 | throw $lastException; 100 | } 101 | 102 | } -------------------------------------------------------------------------------- /src/DocumentRangeFormattingOptions.php: -------------------------------------------------------------------------------- 1 | workDoneProgress = $workDoneProgress; 28 | } 29 | 30 | /** 31 | * @param array $array 32 | * @return self 33 | */ 34 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 35 | { 36 | $map = [ 37 | 'workDoneProgress' => ['names' => [], 'iterable' => false], 38 | ]; 39 | 40 | foreach ($array as $key => &$value) { 41 | if (!isset($map[$key])) { 42 | if ($allowUnknownKeys) { 43 | unset($array[$key]); 44 | continue; 45 | } 46 | 47 | throw new RuntimeException(sprintf( 48 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 49 | $key, 50 | self::class, 51 | implode('", "', array_keys($map)) 52 | )); 53 | } 54 | 55 | // from here we only care about arrays that can be transformed into 56 | // objects 57 | if (!is_array($value)) { 58 | continue; 59 | } 60 | 61 | if (empty($map[$key]['names'])) { 62 | continue; 63 | } 64 | 65 | if ($map[$key]['iterable']) { 66 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 67 | if (!is_array($object)) { 68 | return $object; 69 | } 70 | 71 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 72 | }, $value); 73 | continue; 74 | } 75 | 76 | $names = $map[$key]['names']; 77 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 78 | } 79 | 80 | return Invoke::new(self::class, $array); 81 | } 82 | 83 | /** 84 | * @param array $classNames 85 | * @param array $object 86 | */ 87 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 88 | { 89 | $lastException = null; 90 | foreach ($classNames as $className) { 91 | try { 92 | // @phpstan-ignore-next-line 93 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 94 | } catch (Exception $exception) { 95 | $lastException = $exception; 96 | continue; 97 | } 98 | } 99 | 100 | throw $lastException; 101 | } 102 | 103 | } -------------------------------------------------------------------------------- /src/DocumentRangeFormattingRequest.php: -------------------------------------------------------------------------------- 1 | dynamicRegistration = $dynamicRegistration; 27 | } 28 | 29 | /** 30 | * @param array $array 31 | * @return self 32 | */ 33 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 34 | { 35 | $map = [ 36 | 'dynamicRegistration' => ['names' => [], 'iterable' => false], 37 | ]; 38 | 39 | foreach ($array as $key => &$value) { 40 | if (!isset($map[$key])) { 41 | if ($allowUnknownKeys) { 42 | unset($array[$key]); 43 | continue; 44 | } 45 | 46 | throw new RuntimeException(sprintf( 47 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 48 | $key, 49 | self::class, 50 | implode('", "', array_keys($map)) 51 | )); 52 | } 53 | 54 | // from here we only care about arrays that can be transformed into 55 | // objects 56 | if (!is_array($value)) { 57 | continue; 58 | } 59 | 60 | if (empty($map[$key]['names'])) { 61 | continue; 62 | } 63 | 64 | if ($map[$key]['iterable']) { 65 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 66 | if (!is_array($object)) { 67 | return $object; 68 | } 69 | 70 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 71 | }, $value); 72 | continue; 73 | } 74 | 75 | $names = $map[$key]['names']; 76 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 77 | } 78 | 79 | return Invoke::new(self::class, $array); 80 | } 81 | 82 | /** 83 | * @param array $classNames 84 | * @param array $object 85 | */ 86 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 87 | { 88 | $lastException = null; 89 | foreach ($classNames as $className) { 90 | try { 91 | // @phpstan-ignore-next-line 92 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 93 | } catch (Exception $exception) { 94 | $lastException = $exception; 95 | continue; 96 | } 97 | } 98 | 99 | throw $lastException; 100 | } 101 | 102 | } -------------------------------------------------------------------------------- /src/ExecuteCommandRequest.php: -------------------------------------------------------------------------------- 1 | uri = $uri; 27 | } 28 | 29 | /** 30 | * @param array $array 31 | * @return self 32 | */ 33 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 34 | { 35 | $map = [ 36 | 'uri' => ['names' => [], 'iterable' => false], 37 | ]; 38 | 39 | foreach ($array as $key => &$value) { 40 | if (!isset($map[$key])) { 41 | if ($allowUnknownKeys) { 42 | unset($array[$key]); 43 | continue; 44 | } 45 | 46 | throw new RuntimeException(sprintf( 47 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 48 | $key, 49 | self::class, 50 | implode('", "', array_keys($map)) 51 | )); 52 | } 53 | 54 | // from here we only care about arrays that can be transformed into 55 | // objects 56 | if (!is_array($value)) { 57 | continue; 58 | } 59 | 60 | if (empty($map[$key]['names'])) { 61 | continue; 62 | } 63 | 64 | if ($map[$key]['iterable']) { 65 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 66 | if (!is_array($object)) { 67 | return $object; 68 | } 69 | 70 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 71 | }, $value); 72 | continue; 73 | } 74 | 75 | $names = $map[$key]['names']; 76 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 77 | } 78 | 79 | return Invoke::new(self::class, $array); 80 | } 81 | 82 | /** 83 | * @param array $classNames 84 | * @param array $object 85 | */ 86 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 87 | { 88 | $lastException = null; 89 | foreach ($classNames as $className) { 90 | try { 91 | // @phpstan-ignore-next-line 92 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 93 | } catch (Exception $exception) { 94 | $lastException = $exception; 95 | continue; 96 | } 97 | } 98 | 99 | throw $lastException; 100 | } 101 | 102 | } -------------------------------------------------------------------------------- /src/FileDelete.php: -------------------------------------------------------------------------------- 1 | uri = $uri; 27 | } 28 | 29 | /** 30 | * @param array $array 31 | * @return self 32 | */ 33 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 34 | { 35 | $map = [ 36 | 'uri' => ['names' => [], 'iterable' => false], 37 | ]; 38 | 39 | foreach ($array as $key => &$value) { 40 | if (!isset($map[$key])) { 41 | if ($allowUnknownKeys) { 42 | unset($array[$key]); 43 | continue; 44 | } 45 | 46 | throw new RuntimeException(sprintf( 47 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 48 | $key, 49 | self::class, 50 | implode('", "', array_keys($map)) 51 | )); 52 | } 53 | 54 | // from here we only care about arrays that can be transformed into 55 | // objects 56 | if (!is_array($value)) { 57 | continue; 58 | } 59 | 60 | if (empty($map[$key]['names'])) { 61 | continue; 62 | } 63 | 64 | if ($map[$key]['iterable']) { 65 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 66 | if (!is_array($object)) { 67 | return $object; 68 | } 69 | 70 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 71 | }, $value); 72 | continue; 73 | } 74 | 75 | $names = $map[$key]['names']; 76 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 77 | } 78 | 79 | return Invoke::new(self::class, $array); 80 | } 81 | 82 | /** 83 | * @param array $classNames 84 | * @param array $object 85 | */ 86 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 87 | { 88 | $lastException = null; 89 | foreach ($classNames as $className) { 90 | try { 91 | // @phpstan-ignore-next-line 92 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 93 | } catch (Exception $exception) { 94 | $lastException = $exception; 95 | continue; 96 | } 97 | } 98 | 99 | throw $lastException; 100 | } 101 | 102 | } -------------------------------------------------------------------------------- /src/FileOperationPatternKind.php: -------------------------------------------------------------------------------- 1 | ignoreCase = $ignoreCase; 27 | } 28 | 29 | /** 30 | * @param array $array 31 | * @return self 32 | */ 33 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 34 | { 35 | $map = [ 36 | 'ignoreCase' => ['names' => [], 'iterable' => false], 37 | ]; 38 | 39 | foreach ($array as $key => &$value) { 40 | if (!isset($map[$key])) { 41 | if ($allowUnknownKeys) { 42 | unset($array[$key]); 43 | continue; 44 | } 45 | 46 | throw new RuntimeException(sprintf( 47 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 48 | $key, 49 | self::class, 50 | implode('", "', array_keys($map)) 51 | )); 52 | } 53 | 54 | // from here we only care about arrays that can be transformed into 55 | // objects 56 | if (!is_array($value)) { 57 | continue; 58 | } 59 | 60 | if (empty($map[$key]['names'])) { 61 | continue; 62 | } 63 | 64 | if ($map[$key]['iterable']) { 65 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 66 | if (!is_array($object)) { 67 | return $object; 68 | } 69 | 70 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 71 | }, $value); 72 | continue; 73 | } 74 | 75 | $names = $map[$key]['names']; 76 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 77 | } 78 | 79 | return Invoke::new(self::class, $array); 80 | } 81 | 82 | /** 83 | * @param array $classNames 84 | * @param array $object 85 | */ 86 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 87 | { 88 | $lastException = null; 89 | foreach ($classNames as $className) { 90 | try { 91 | // @phpstan-ignore-next-line 92 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 93 | } catch (Exception $exception) { 94 | $lastException = $exception; 95 | continue; 96 | } 97 | } 98 | 99 | throw $lastException; 100 | } 101 | 102 | } -------------------------------------------------------------------------------- /src/FileOperationRegistrationOptions.php: -------------------------------------------------------------------------------- 1 | 18 | */ 19 | public $filters; 20 | 21 | /** 22 | * @param array $filters 23 | */ 24 | public function __construct(array $filters) 25 | { 26 | $this->filters = $filters; 27 | } 28 | 29 | /** 30 | * @param array $array 31 | * @return self 32 | */ 33 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 34 | { 35 | $map = [ 36 | 'filters' => ['names' => [FileOperationFilter::class], 'iterable' => true], 37 | ]; 38 | 39 | foreach ($array as $key => &$value) { 40 | if (!isset($map[$key])) { 41 | if ($allowUnknownKeys) { 42 | unset($array[$key]); 43 | continue; 44 | } 45 | 46 | throw new RuntimeException(sprintf( 47 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 48 | $key, 49 | self::class, 50 | implode('", "', array_keys($map)) 51 | )); 52 | } 53 | 54 | // from here we only care about arrays that can be transformed into 55 | // objects 56 | if (!is_array($value)) { 57 | continue; 58 | } 59 | 60 | if (empty($map[$key]['names'])) { 61 | continue; 62 | } 63 | 64 | if ($map[$key]['iterable']) { 65 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 66 | if (!is_array($object)) { 67 | return $object; 68 | } 69 | 70 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 71 | }, $value); 72 | continue; 73 | } 74 | 75 | $names = $map[$key]['names']; 76 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 77 | } 78 | 79 | return Invoke::new(self::class, $array); 80 | } 81 | 82 | /** 83 | * @param array $classNames 84 | * @param array $object 85 | */ 86 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 87 | { 88 | $lastException = null; 89 | foreach ($classNames as $className) { 90 | try { 91 | // @phpstan-ignore-next-line 92 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 93 | } catch (Exception $exception) { 94 | $lastException = $exception; 95 | continue; 96 | } 97 | } 98 | 99 | throw $lastException; 100 | } 101 | 102 | } -------------------------------------------------------------------------------- /src/FoldingRangeKind.php: -------------------------------------------------------------------------------- 1 | workDoneProgress = $workDoneProgress; 26 | } 27 | 28 | /** 29 | * @param array $array 30 | * @return self 31 | */ 32 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 33 | { 34 | $map = [ 35 | 'workDoneProgress' => ['names' => [], 'iterable' => false], 36 | ]; 37 | 38 | foreach ($array as $key => &$value) { 39 | if (!isset($map[$key])) { 40 | if ($allowUnknownKeys) { 41 | unset($array[$key]); 42 | continue; 43 | } 44 | 45 | throw new RuntimeException(sprintf( 46 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 47 | $key, 48 | self::class, 49 | implode('", "', array_keys($map)) 50 | )); 51 | } 52 | 53 | // from here we only care about arrays that can be transformed into 54 | // objects 55 | if (!is_array($value)) { 56 | continue; 57 | } 58 | 59 | if (empty($map[$key]['names'])) { 60 | continue; 61 | } 62 | 63 | if ($map[$key]['iterable']) { 64 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 65 | if (!is_array($object)) { 66 | return $object; 67 | } 68 | 69 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 70 | }, $value); 71 | continue; 72 | } 73 | 74 | $names = $map[$key]['names']; 75 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 76 | } 77 | 78 | return Invoke::new(self::class, $array); 79 | } 80 | 81 | /** 82 | * @param array $classNames 83 | * @param array $object 84 | */ 85 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 86 | { 87 | $lastException = null; 88 | foreach ($classNames as $className) { 89 | try { 90 | // @phpstan-ignore-next-line 91 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 92 | } catch (Exception $exception) { 93 | $lastException = $exception; 94 | continue; 95 | } 96 | } 97 | 98 | throw $lastException; 99 | } 100 | 101 | } -------------------------------------------------------------------------------- /src/FoldingRangeRequest.php: -------------------------------------------------------------------------------- 1 | workDoneProgress = $workDoneProgress; 28 | } 29 | 30 | /** 31 | * @param array $array 32 | * @return self 33 | */ 34 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 35 | { 36 | $map = [ 37 | 'workDoneProgress' => ['names' => [], 'iterable' => false], 38 | ]; 39 | 40 | foreach ($array as $key => &$value) { 41 | if (!isset($map[$key])) { 42 | if ($allowUnknownKeys) { 43 | unset($array[$key]); 44 | continue; 45 | } 46 | 47 | throw new RuntimeException(sprintf( 48 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 49 | $key, 50 | self::class, 51 | implode('", "', array_keys($map)) 52 | )); 53 | } 54 | 55 | // from here we only care about arrays that can be transformed into 56 | // objects 57 | if (!is_array($value)) { 58 | continue; 59 | } 60 | 61 | if (empty($map[$key]['names'])) { 62 | continue; 63 | } 64 | 65 | if ($map[$key]['iterable']) { 66 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 67 | if (!is_array($object)) { 68 | return $object; 69 | } 70 | 71 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 72 | }, $value); 73 | continue; 74 | } 75 | 76 | $names = $map[$key]['names']; 77 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 78 | } 79 | 80 | return Invoke::new(self::class, $array); 81 | } 82 | 83 | /** 84 | * @param array $classNames 85 | * @param array $object 86 | */ 87 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 88 | { 89 | $lastException = null; 90 | foreach ($classNames as $className) { 91 | try { 92 | // @phpstan-ignore-next-line 93 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 94 | } catch (Exception $exception) { 95 | $lastException = $exception; 96 | continue; 97 | } 98 | } 99 | 100 | throw $lastException; 101 | } 102 | 103 | } -------------------------------------------------------------------------------- /src/HoverRequest.php: -------------------------------------------------------------------------------- 1 | workDoneProgress = $workDoneProgress; 26 | } 27 | 28 | /** 29 | * @param array $array 30 | * @return self 31 | */ 32 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 33 | { 34 | $map = [ 35 | 'workDoneProgress' => ['names' => [], 'iterable' => false], 36 | ]; 37 | 38 | foreach ($array as $key => &$value) { 39 | if (!isset($map[$key])) { 40 | if ($allowUnknownKeys) { 41 | unset($array[$key]); 42 | continue; 43 | } 44 | 45 | throw new RuntimeException(sprintf( 46 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 47 | $key, 48 | self::class, 49 | implode('", "', array_keys($map)) 50 | )); 51 | } 52 | 53 | // from here we only care about arrays that can be transformed into 54 | // objects 55 | if (!is_array($value)) { 56 | continue; 57 | } 58 | 59 | if (empty($map[$key]['names'])) { 60 | continue; 61 | } 62 | 63 | if ($map[$key]['iterable']) { 64 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 65 | if (!is_array($object)) { 66 | return $object; 67 | } 68 | 69 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 70 | }, $value); 71 | continue; 72 | } 73 | 74 | $names = $map[$key]['names']; 75 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 76 | } 77 | 78 | return Invoke::new(self::class, $array); 79 | } 80 | 81 | /** 82 | * @param array $classNames 83 | * @param array $object 84 | */ 85 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 86 | { 87 | $lastException = null; 88 | foreach ($classNames as $className) { 89 | try { 90 | // @phpstan-ignore-next-line 91 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 92 | } catch (Exception $exception) { 93 | $lastException = $exception; 94 | continue; 95 | } 96 | } 97 | 98 | throw $lastException; 99 | } 100 | 101 | } -------------------------------------------------------------------------------- /src/ImplementationRequest.php: -------------------------------------------------------------------------------- 1 | $array 14 | * @return self 15 | */ 16 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 17 | { 18 | 19 | return Invoke::new(self::class, $array); 20 | } 21 | 22 | /** 23 | * @param array $classNames 24 | * @param array $object 25 | */ 26 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 27 | { 28 | $lastException = null; 29 | foreach ($classNames as $className) { 30 | try { 31 | // @phpstan-ignore-next-line 32 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 33 | } catch (Exception $exception) { 34 | $lastException = $exception; 35 | continue; 36 | } 37 | } 38 | 39 | throw $lastException; 40 | } 41 | 42 | } -------------------------------------------------------------------------------- /src/InlayHintKind.php: -------------------------------------------------------------------------------- 1 | range = $range; 32 | $this->text = $text; 33 | } 34 | 35 | /** 36 | * @param array $array 37 | * @return self 38 | */ 39 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 40 | { 41 | $map = [ 42 | 'range' => ['names' => [Range::class], 'iterable' => false], 43 | 'text' => ['names' => [], 'iterable' => false], 44 | ]; 45 | 46 | foreach ($array as $key => &$value) { 47 | if (!isset($map[$key])) { 48 | if ($allowUnknownKeys) { 49 | unset($array[$key]); 50 | continue; 51 | } 52 | 53 | throw new RuntimeException(sprintf( 54 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 55 | $key, 56 | self::class, 57 | implode('", "', array_keys($map)) 58 | )); 59 | } 60 | 61 | // from here we only care about arrays that can be transformed into 62 | // objects 63 | if (!is_array($value)) { 64 | continue; 65 | } 66 | 67 | if (empty($map[$key]['names'])) { 68 | continue; 69 | } 70 | 71 | if ($map[$key]['iterable']) { 72 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 73 | if (!is_array($object)) { 74 | return $object; 75 | } 76 | 77 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 78 | }, $value); 79 | continue; 80 | } 81 | 82 | $names = $map[$key]['names']; 83 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 84 | } 85 | 86 | return Invoke::new(self::class, $array); 87 | } 88 | 89 | /** 90 | * @param array $classNames 91 | * @param array $object 92 | */ 93 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 94 | { 95 | $lastException = null; 96 | foreach ($classNames as $className) { 97 | try { 98 | // @phpstan-ignore-next-line 99 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 100 | } catch (Exception $exception) { 101 | $lastException = $exception; 102 | continue; 103 | } 104 | } 105 | 106 | throw $lastException; 107 | } 108 | 109 | } -------------------------------------------------------------------------------- /src/InsertTextFormat.php: -------------------------------------------------------------------------------- 1 | uri = urldecode($uri); 34 | $this->range = $range; 35 | } 36 | 37 | /** 38 | * @param array $array 39 | * @return self 40 | */ 41 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 42 | { 43 | $map = [ 44 | 'uri' => ['names' => [], 'iterable' => false], 45 | 'range' => ['names' => [Range::class], 'iterable' => false], 46 | ]; 47 | 48 | foreach ($array as $key => &$value) { 49 | if (!isset($map[$key])) { 50 | if ($allowUnknownKeys) { 51 | unset($array[$key]); 52 | continue; 53 | } 54 | 55 | throw new RuntimeException(sprintf( 56 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 57 | $key, 58 | self::class, 59 | implode('", "', array_keys($map)) 60 | )); 61 | } 62 | 63 | // from here we only care about arrays that can be transformed into 64 | // objects 65 | if (!is_array($value)) { 66 | continue; 67 | } 68 | 69 | if (empty($map[$key]['names'])) { 70 | continue; 71 | } 72 | 73 | if ($map[$key]['iterable']) { 74 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 75 | if (!is_array($object)) { 76 | return $object; 77 | } 78 | 79 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 80 | }, $value); 81 | continue; 82 | } 83 | 84 | $names = $map[$key]['names']; 85 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 86 | } 87 | 88 | return Invoke::new(self::class, $array); 89 | } 90 | 91 | /** 92 | * @param array $classNames 93 | * @param array $object 94 | */ 95 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 96 | { 97 | $lastException = null; 98 | foreach ($classNames as $className) { 99 | try { 100 | // @phpstan-ignore-next-line 101 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 102 | } catch (Exception $exception) { 103 | $lastException = $exception; 104 | continue; 105 | } 106 | } 107 | 108 | throw $lastException; 109 | } 110 | 111 | } -------------------------------------------------------------------------------- /src/LogMessageNotification.php: -------------------------------------------------------------------------------- 1 | title = $title; 24 | } 25 | 26 | /** 27 | * @param array $array 28 | * @return self 29 | */ 30 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 31 | { 32 | $map = [ 33 | 'title' => ['names' => [], 'iterable' => false], 34 | ]; 35 | 36 | foreach ($array as $key => &$value) { 37 | if (!isset($map[$key])) { 38 | if ($allowUnknownKeys) { 39 | unset($array[$key]); 40 | continue; 41 | } 42 | 43 | throw new RuntimeException(sprintf( 44 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 45 | $key, 46 | self::class, 47 | implode('", "', array_keys($map)) 48 | )); 49 | } 50 | 51 | // from here we only care about arrays that can be transformed into 52 | // objects 53 | if (!is_array($value)) { 54 | continue; 55 | } 56 | 57 | if (empty($map[$key]['names'])) { 58 | continue; 59 | } 60 | 61 | if ($map[$key]['iterable']) { 62 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 63 | if (!is_array($object)) { 64 | return $object; 65 | } 66 | 67 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 68 | }, $value); 69 | continue; 70 | } 71 | 72 | $names = $map[$key]['names']; 73 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 74 | } 75 | 76 | return Invoke::new(self::class, $array); 77 | } 78 | 79 | /** 80 | * @param array $classNames 81 | * @param array $object 82 | */ 83 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 84 | { 85 | $lastException = null; 86 | foreach ($classNames as $className) { 87 | try { 88 | // @phpstan-ignore-next-line 89 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 90 | } catch (Exception $exception) { 91 | $lastException = $exception; 92 | continue; 93 | } 94 | } 95 | 96 | throw $lastException; 97 | } 98 | 99 | } -------------------------------------------------------------------------------- /src/MessageType.php: -------------------------------------------------------------------------------- 1 | synchronization = $synchronization; 27 | } 28 | 29 | /** 30 | * @param array $array 31 | * @return self 32 | */ 33 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 34 | { 35 | $map = [ 36 | 'synchronization' => ['names' => [], 'iterable' => false], 37 | ]; 38 | 39 | foreach ($array as $key => &$value) { 40 | if (!isset($map[$key])) { 41 | if ($allowUnknownKeys) { 42 | unset($array[$key]); 43 | continue; 44 | } 45 | 46 | throw new RuntimeException(sprintf( 47 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 48 | $key, 49 | self::class, 50 | implode('", "', array_keys($map)) 51 | )); 52 | } 53 | 54 | // from here we only care about arrays that can be transformed into 55 | // objects 56 | if (!is_array($value)) { 57 | continue; 58 | } 59 | 60 | if (empty($map[$key]['names'])) { 61 | continue; 62 | } 63 | 64 | if ($map[$key]['iterable']) { 65 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 66 | if (!is_array($object)) { 67 | return $object; 68 | } 69 | 70 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 71 | }, $value); 72 | continue; 73 | } 74 | 75 | $names = $map[$key]['names']; 76 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 77 | } 78 | 79 | return Invoke::new(self::class, $array); 80 | } 81 | 82 | /** 83 | * @param array $classNames 84 | * @param array $object 85 | */ 86 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 87 | { 88 | $lastException = null; 89 | foreach ($classNames as $className) { 90 | try { 91 | // @phpstan-ignore-next-line 92 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 93 | } catch (Exception $exception) { 94 | $lastException = $exception; 95 | continue; 96 | } 97 | } 98 | 99 | throw $lastException; 100 | } 101 | 102 | } -------------------------------------------------------------------------------- /src/PartialResultParams.php: -------------------------------------------------------------------------------- 1 | partialResultToken = $partialResultToken; 25 | } 26 | 27 | /** 28 | * @param array $array 29 | * @return self 30 | */ 31 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 32 | { 33 | $map = [ 34 | 'partialResultToken' => ['names' => [], 'iterable' => false], 35 | ]; 36 | 37 | foreach ($array as $key => &$value) { 38 | if (!isset($map[$key])) { 39 | if ($allowUnknownKeys) { 40 | unset($array[$key]); 41 | continue; 42 | } 43 | 44 | throw new RuntimeException(sprintf( 45 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 46 | $key, 47 | self::class, 48 | implode('", "', array_keys($map)) 49 | )); 50 | } 51 | 52 | // from here we only care about arrays that can be transformed into 53 | // objects 54 | if (!is_array($value)) { 55 | continue; 56 | } 57 | 58 | if (empty($map[$key]['names'])) { 59 | continue; 60 | } 61 | 62 | if ($map[$key]['iterable']) { 63 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 64 | if (!is_array($object)) { 65 | return $object; 66 | } 67 | 68 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 69 | }, $value); 70 | continue; 71 | } 72 | 73 | $names = $map[$key]['names']; 74 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 75 | } 76 | 77 | return Invoke::new(self::class, $array); 78 | } 79 | 80 | /** 81 | * @param array $classNames 82 | * @param array $object 83 | */ 84 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 85 | { 86 | $lastException = null; 87 | foreach ($classNames as $className) { 88 | try { 89 | // @phpstan-ignore-next-line 90 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 91 | } catch (Exception $exception) { 92 | $lastException = $exception; 93 | continue; 94 | } 95 | } 96 | 97 | throw $lastException; 98 | } 99 | 100 | } -------------------------------------------------------------------------------- /src/PrepareRenameRequest.php: -------------------------------------------------------------------------------- 1 | dynamicRegistration = $dynamicRegistration; 27 | } 28 | 29 | /** 30 | * @param array $array 31 | * @return self 32 | */ 33 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 34 | { 35 | $map = [ 36 | 'dynamicRegistration' => ['names' => [], 'iterable' => false], 37 | ]; 38 | 39 | foreach ($array as $key => &$value) { 40 | if (!isset($map[$key])) { 41 | if ($allowUnknownKeys) { 42 | unset($array[$key]); 43 | continue; 44 | } 45 | 46 | throw new RuntimeException(sprintf( 47 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 48 | $key, 49 | self::class, 50 | implode('", "', array_keys($map)) 51 | )); 52 | } 53 | 54 | // from here we only care about arrays that can be transformed into 55 | // objects 56 | if (!is_array($value)) { 57 | continue; 58 | } 59 | 60 | if (empty($map[$key]['names'])) { 61 | continue; 62 | } 63 | 64 | if ($map[$key]['iterable']) { 65 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 66 | if (!is_array($object)) { 67 | return $object; 68 | } 69 | 70 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 71 | }, $value); 72 | continue; 73 | } 74 | 75 | $names = $map[$key]['names']; 76 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 77 | } 78 | 79 | return Invoke::new(self::class, $array); 80 | } 81 | 82 | /** 83 | * @param array $classNames 84 | * @param array $object 85 | */ 86 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 87 | { 88 | $lastException = null; 89 | foreach ($classNames as $className) { 90 | try { 91 | // @phpstan-ignore-next-line 92 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 93 | } catch (Exception $exception) { 94 | $lastException = $exception; 95 | continue; 96 | } 97 | } 98 | 99 | throw $lastException; 100 | } 101 | 102 | } -------------------------------------------------------------------------------- /src/ReferenceContext.php: -------------------------------------------------------------------------------- 1 | includeDeclaration = $includeDeclaration; 28 | } 29 | 30 | /** 31 | * @param array $array 32 | * @return self 33 | */ 34 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 35 | { 36 | $map = [ 37 | 'includeDeclaration' => ['names' => [], 'iterable' => false], 38 | ]; 39 | 40 | foreach ($array as $key => &$value) { 41 | if (!isset($map[$key])) { 42 | if ($allowUnknownKeys) { 43 | unset($array[$key]); 44 | continue; 45 | } 46 | 47 | throw new RuntimeException(sprintf( 48 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 49 | $key, 50 | self::class, 51 | implode('", "', array_keys($map)) 52 | )); 53 | } 54 | 55 | // from here we only care about arrays that can be transformed into 56 | // objects 57 | if (!is_array($value)) { 58 | continue; 59 | } 60 | 61 | if (empty($map[$key]['names'])) { 62 | continue; 63 | } 64 | 65 | if ($map[$key]['iterable']) { 66 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 67 | if (!is_array($object)) { 68 | return $object; 69 | } 70 | 71 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 72 | }, $value); 73 | continue; 74 | } 75 | 76 | $names = $map[$key]['names']; 77 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 78 | } 79 | 80 | return Invoke::new(self::class, $array); 81 | } 82 | 83 | /** 84 | * @param array $classNames 85 | * @param array $object 86 | */ 87 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 88 | { 89 | $lastException = null; 90 | foreach ($classNames as $className) { 91 | try { 92 | // @phpstan-ignore-next-line 93 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 94 | } catch (Exception $exception) { 95 | $lastException = $exception; 96 | continue; 97 | } 98 | } 99 | 100 | throw $lastException; 101 | } 102 | 103 | } -------------------------------------------------------------------------------- /src/ReferenceOptions.php: -------------------------------------------------------------------------------- 1 | workDoneProgress = $workDoneProgress; 28 | } 29 | 30 | /** 31 | * @param array $array 32 | * @return self 33 | */ 34 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 35 | { 36 | $map = [ 37 | 'workDoneProgress' => ['names' => [], 'iterable' => false], 38 | ]; 39 | 40 | foreach ($array as $key => &$value) { 41 | if (!isset($map[$key])) { 42 | if ($allowUnknownKeys) { 43 | unset($array[$key]); 44 | continue; 45 | } 46 | 47 | throw new RuntimeException(sprintf( 48 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 49 | $key, 50 | self::class, 51 | implode('", "', array_keys($map)) 52 | )); 53 | } 54 | 55 | // from here we only care about arrays that can be transformed into 56 | // objects 57 | if (!is_array($value)) { 58 | continue; 59 | } 60 | 61 | if (empty($map[$key]['names'])) { 62 | continue; 63 | } 64 | 65 | if ($map[$key]['iterable']) { 66 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 67 | if (!is_array($object)) { 68 | return $object; 69 | } 70 | 71 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 72 | }, $value); 73 | continue; 74 | } 75 | 76 | $names = $map[$key]['names']; 77 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 78 | } 79 | 80 | return Invoke::new(self::class, $array); 81 | } 82 | 83 | /** 84 | * @param array $classNames 85 | * @param array $object 86 | */ 87 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 88 | { 89 | $lastException = null; 90 | foreach ($classNames as $className) { 91 | try { 92 | // @phpstan-ignore-next-line 93 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 94 | } catch (Exception $exception) { 95 | $lastException = $exception; 96 | continue; 97 | } 98 | } 99 | 100 | throw $lastException; 101 | } 102 | 103 | } -------------------------------------------------------------------------------- /src/ReferencesRequest.php: -------------------------------------------------------------------------------- 1 | 14 | */ 15 | public $registrations; 16 | 17 | /** 18 | * @param array $registrations 19 | */ 20 | public function __construct(array $registrations) 21 | { 22 | $this->registrations = $registrations; 23 | } 24 | 25 | /** 26 | * @param array $array 27 | * @return self 28 | */ 29 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 30 | { 31 | $map = [ 32 | 'registrations' => ['names' => [Registration::class], 'iterable' => true], 33 | ]; 34 | 35 | foreach ($array as $key => &$value) { 36 | if (!isset($map[$key])) { 37 | if ($allowUnknownKeys) { 38 | unset($array[$key]); 39 | continue; 40 | } 41 | 42 | throw new RuntimeException(sprintf( 43 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 44 | $key, 45 | self::class, 46 | implode('", "', array_keys($map)) 47 | )); 48 | } 49 | 50 | // from here we only care about arrays that can be transformed into 51 | // objects 52 | if (!is_array($value)) { 53 | continue; 54 | } 55 | 56 | if (empty($map[$key]['names'])) { 57 | continue; 58 | } 59 | 60 | if ($map[$key]['iterable']) { 61 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 62 | if (!is_array($object)) { 63 | return $object; 64 | } 65 | 66 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 67 | }, $value); 68 | continue; 69 | } 70 | 71 | $names = $map[$key]['names']; 72 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 73 | } 74 | 75 | return Invoke::new(self::class, $array); 76 | } 77 | 78 | /** 79 | * @param array $classNames 80 | * @param array $object 81 | */ 82 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 83 | { 84 | $lastException = null; 85 | foreach ($classNames as $className) { 86 | try { 87 | // @phpstan-ignore-next-line 88 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 89 | } catch (Exception $exception) { 90 | $lastException = $exception; 91 | continue; 92 | } 93 | } 94 | 95 | throw $lastException; 96 | } 97 | 98 | } -------------------------------------------------------------------------------- /src/RegistrationRequest.php: -------------------------------------------------------------------------------- 1 | 20 | */ 21 | public $files; 22 | 23 | /** 24 | * @param array $files 25 | */ 26 | public function __construct(array $files) 27 | { 28 | $this->files = $files; 29 | } 30 | 31 | /** 32 | * @param array $array 33 | * @return self 34 | */ 35 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 36 | { 37 | $map = [ 38 | 'files' => ['names' => [FileRename::class], 'iterable' => true], 39 | ]; 40 | 41 | foreach ($array as $key => &$value) { 42 | if (!isset($map[$key])) { 43 | if ($allowUnknownKeys) { 44 | unset($array[$key]); 45 | continue; 46 | } 47 | 48 | throw new RuntimeException(sprintf( 49 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 50 | $key, 51 | self::class, 52 | implode('", "', array_keys($map)) 53 | )); 54 | } 55 | 56 | // from here we only care about arrays that can be transformed into 57 | // objects 58 | if (!is_array($value)) { 59 | continue; 60 | } 61 | 62 | if (empty($map[$key]['names'])) { 63 | continue; 64 | } 65 | 66 | if ($map[$key]['iterable']) { 67 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 68 | if (!is_array($object)) { 69 | return $object; 70 | } 71 | 72 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 73 | }, $value); 74 | continue; 75 | } 76 | 77 | $names = $map[$key]['names']; 78 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 79 | } 80 | 81 | return Invoke::new(self::class, $array); 82 | } 83 | 84 | /** 85 | * @param array $classNames 86 | * @param array $object 87 | */ 88 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 89 | { 90 | $lastException = null; 91 | foreach ($classNames as $className) { 92 | try { 93 | // @phpstan-ignore-next-line 94 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 95 | } catch (Exception $exception) { 96 | $lastException = $exception; 97 | continue; 98 | } 99 | } 100 | 101 | throw $lastException; 102 | } 103 | 104 | } -------------------------------------------------------------------------------- /src/RenameRequest.php: -------------------------------------------------------------------------------- 1 | includeText = $includeText; 27 | } 28 | 29 | /** 30 | * @param array $array 31 | * @return self 32 | */ 33 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 34 | { 35 | $map = [ 36 | 'includeText' => ['names' => [], 'iterable' => false], 37 | ]; 38 | 39 | foreach ($array as $key => &$value) { 40 | if (!isset($map[$key])) { 41 | if ($allowUnknownKeys) { 42 | unset($array[$key]); 43 | continue; 44 | } 45 | 46 | throw new RuntimeException(sprintf( 47 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 48 | $key, 49 | self::class, 50 | implode('", "', array_keys($map)) 51 | )); 52 | } 53 | 54 | // from here we only care about arrays that can be transformed into 55 | // objects 56 | if (!is_array($value)) { 57 | continue; 58 | } 59 | 60 | if (empty($map[$key]['names'])) { 61 | continue; 62 | } 63 | 64 | if ($map[$key]['iterable']) { 65 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 66 | if (!is_array($object)) { 67 | return $object; 68 | } 69 | 70 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 71 | }, $value); 72 | continue; 73 | } 74 | 75 | $names = $map[$key]['names']; 76 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 77 | } 78 | 79 | return Invoke::new(self::class, $array); 80 | } 81 | 82 | /** 83 | * @param array $classNames 84 | * @param array $object 85 | */ 86 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 87 | { 88 | $lastException = null; 89 | foreach ($classNames as $className) { 90 | try { 91 | // @phpstan-ignore-next-line 92 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 93 | } catch (Exception $exception) { 94 | $lastException = $exception; 95 | continue; 96 | } 97 | } 98 | 99 | throw $lastException; 100 | } 101 | 102 | } -------------------------------------------------------------------------------- /src/SelectionRangeOptions.php: -------------------------------------------------------------------------------- 1 | workDoneProgress = $workDoneProgress; 26 | } 27 | 28 | /** 29 | * @param array $array 30 | * @return self 31 | */ 32 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 33 | { 34 | $map = [ 35 | 'workDoneProgress' => ['names' => [], 'iterable' => false], 36 | ]; 37 | 38 | foreach ($array as $key => &$value) { 39 | if (!isset($map[$key])) { 40 | if ($allowUnknownKeys) { 41 | unset($array[$key]); 42 | continue; 43 | } 44 | 45 | throw new RuntimeException(sprintf( 46 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 47 | $key, 48 | self::class, 49 | implode('", "', array_keys($map)) 50 | )); 51 | } 52 | 53 | // from here we only care about arrays that can be transformed into 54 | // objects 55 | if (!is_array($value)) { 56 | continue; 57 | } 58 | 59 | if (empty($map[$key]['names'])) { 60 | continue; 61 | } 62 | 63 | if ($map[$key]['iterable']) { 64 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 65 | if (!is_array($object)) { 66 | return $object; 67 | } 68 | 69 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 70 | }, $value); 71 | continue; 72 | } 73 | 74 | $names = $map[$key]['names']; 75 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 76 | } 77 | 78 | return Invoke::new(self::class, $array); 79 | } 80 | 81 | /** 82 | * @param array $classNames 83 | * @param array $object 84 | */ 85 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 86 | { 87 | $lastException = null; 88 | foreach ($classNames as $className) { 89 | try { 90 | // @phpstan-ignore-next-line 91 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 92 | } catch (Exception $exception) { 93 | $lastException = $exception; 94 | continue; 95 | } 96 | } 97 | 98 | throw $lastException; 99 | } 100 | 101 | } -------------------------------------------------------------------------------- /src/SelectionRangeRequest.php: -------------------------------------------------------------------------------- 1 | messageActionItem = $messageActionItem; 27 | } 28 | 29 | /** 30 | * @param array $array 31 | * @return self 32 | */ 33 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 34 | { 35 | $map = [ 36 | 'messageActionItem' => ['names' => [], 'iterable' => false], 37 | ]; 38 | 39 | foreach ($array as $key => &$value) { 40 | if (!isset($map[$key])) { 41 | if ($allowUnknownKeys) { 42 | unset($array[$key]); 43 | continue; 44 | } 45 | 46 | throw new RuntimeException(sprintf( 47 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 48 | $key, 49 | self::class, 50 | implode('", "', array_keys($map)) 51 | )); 52 | } 53 | 54 | // from here we only care about arrays that can be transformed into 55 | // objects 56 | if (!is_array($value)) { 57 | continue; 58 | } 59 | 60 | if (empty($map[$key]['names'])) { 61 | continue; 62 | } 63 | 64 | if ($map[$key]['iterable']) { 65 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 66 | if (!is_array($object)) { 67 | return $object; 68 | } 69 | 70 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 71 | }, $value); 72 | continue; 73 | } 74 | 75 | $names = $map[$key]['names']; 76 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 77 | } 78 | 79 | return Invoke::new(self::class, $array); 80 | } 81 | 82 | /** 83 | * @param array $classNames 84 | * @param array $object 85 | */ 86 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 87 | { 88 | $lastException = null; 89 | foreach ($classNames as $className) { 90 | try { 91 | // @phpstan-ignore-next-line 92 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 93 | } catch (Exception $exception) { 94 | $lastException = $exception; 95 | continue; 96 | } 97 | } 98 | 99 | throw $lastException; 100 | } 101 | 102 | } -------------------------------------------------------------------------------- /src/ShutdownRequest.php: -------------------------------------------------------------------------------- 1 | id = $id; 29 | } 30 | 31 | /** 32 | * @param array $array 33 | * @return self 34 | */ 35 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 36 | { 37 | $map = [ 38 | 'id' => ['names' => [], 'iterable' => false], 39 | ]; 40 | 41 | foreach ($array as $key => &$value) { 42 | if (!isset($map[$key])) { 43 | if ($allowUnknownKeys) { 44 | unset($array[$key]); 45 | continue; 46 | } 47 | 48 | throw new RuntimeException(sprintf( 49 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 50 | $key, 51 | self::class, 52 | implode('", "', array_keys($map)) 53 | )); 54 | } 55 | 56 | // from here we only care about arrays that can be transformed into 57 | // objects 58 | if (!is_array($value)) { 59 | continue; 60 | } 61 | 62 | if (empty($map[$key]['names'])) { 63 | continue; 64 | } 65 | 66 | if ($map[$key]['iterable']) { 67 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 68 | if (!is_array($object)) { 69 | return $object; 70 | } 71 | 72 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 73 | }, $value); 74 | continue; 75 | } 76 | 77 | $names = $map[$key]['names']; 78 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 79 | } 80 | 81 | return Invoke::new(self::class, $array); 82 | } 83 | 84 | /** 85 | * @param array $classNames 86 | * @param array $object 87 | */ 88 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 89 | { 90 | $lastException = null; 91 | foreach ($classNames as $className) { 92 | try { 93 | // @phpstan-ignore-next-line 94 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 95 | } catch (Exception $exception) { 96 | $lastException = $exception; 97 | continue; 98 | } 99 | } 100 | 101 | throw $lastException; 102 | } 103 | 104 | } -------------------------------------------------------------------------------- /src/SymbolKind.php: -------------------------------------------------------------------------------- 1 | uri = urldecode($uri); 27 | } 28 | 29 | /** 30 | * @param array $array 31 | * @return self 32 | */ 33 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 34 | { 35 | $map = [ 36 | 'uri' => ['names' => [], 'iterable' => false], 37 | ]; 38 | 39 | foreach ($array as $key => &$value) { 40 | if (!isset($map[$key])) { 41 | if ($allowUnknownKeys) { 42 | unset($array[$key]); 43 | continue; 44 | } 45 | 46 | throw new RuntimeException(sprintf( 47 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 48 | $key, 49 | self::class, 50 | implode('", "', array_keys($map)) 51 | )); 52 | } 53 | 54 | // from here we only care about arrays that can be transformed into 55 | // objects 56 | if (!is_array($value)) { 57 | continue; 58 | } 59 | 60 | if (empty($map[$key]['names'])) { 61 | continue; 62 | } 63 | 64 | if ($map[$key]['iterable']) { 65 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 66 | if (!is_array($object)) { 67 | return $object; 68 | } 69 | 70 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 71 | }, $value); 72 | continue; 73 | } 74 | 75 | $names = $map[$key]['names']; 76 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 77 | } 78 | 79 | return Invoke::new(self::class, $array); 80 | } 81 | 82 | /** 83 | * @param array $classNames 84 | * @param array $object 85 | */ 86 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 87 | { 88 | $lastException = null; 89 | foreach ($classNames as $className) { 90 | try { 91 | // @phpstan-ignore-next-line 92 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 93 | } catch (Exception $exception) { 94 | $lastException = $exception; 95 | continue; 96 | } 97 | } 98 | 99 | throw $lastException; 100 | } 101 | 102 | } -------------------------------------------------------------------------------- /src/TextDocumentSaveReason.php: -------------------------------------------------------------------------------- 1 | $array 17 | * @return self 18 | */ 19 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 20 | { 21 | 22 | return Invoke::new(self::class, $array); 23 | } 24 | 25 | /** 26 | * @param array $classNames 27 | * @param array $object 28 | */ 29 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 30 | { 31 | $lastException = null; 32 | foreach ($classNames as $className) { 33 | try { 34 | // @phpstan-ignore-next-line 35 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 36 | } catch (Exception $exception) { 37 | $lastException = $exception; 38 | continue; 39 | } 40 | } 41 | 42 | throw $lastException; 43 | } 44 | 45 | } -------------------------------------------------------------------------------- /src/TypeDefinitionOptions.php: -------------------------------------------------------------------------------- 1 | workDoneProgress = $workDoneProgress; 26 | } 27 | 28 | /** 29 | * @param array $array 30 | * @return self 31 | */ 32 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 33 | { 34 | $map = [ 35 | 'workDoneProgress' => ['names' => [], 'iterable' => false], 36 | ]; 37 | 38 | foreach ($array as $key => &$value) { 39 | if (!isset($map[$key])) { 40 | if ($allowUnknownKeys) { 41 | unset($array[$key]); 42 | continue; 43 | } 44 | 45 | throw new RuntimeException(sprintf( 46 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 47 | $key, 48 | self::class, 49 | implode('", "', array_keys($map)) 50 | )); 51 | } 52 | 53 | // from here we only care about arrays that can be transformed into 54 | // objects 55 | if (!is_array($value)) { 56 | continue; 57 | } 58 | 59 | if (empty($map[$key]['names'])) { 60 | continue; 61 | } 62 | 63 | if ($map[$key]['iterable']) { 64 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 65 | if (!is_array($object)) { 66 | return $object; 67 | } 68 | 69 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 70 | }, $value); 71 | continue; 72 | } 73 | 74 | $names = $map[$key]['names']; 75 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 76 | } 77 | 78 | return Invoke::new(self::class, $array); 79 | } 80 | 81 | /** 82 | * @param array $classNames 83 | * @param array $object 84 | */ 85 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 86 | { 87 | $lastException = null; 88 | foreach ($classNames as $className) { 89 | try { 90 | // @phpstan-ignore-next-line 91 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 92 | } catch (Exception $exception) { 93 | $lastException = $exception; 94 | continue; 95 | } 96 | } 97 | 98 | throw $lastException; 99 | } 100 | 101 | } -------------------------------------------------------------------------------- /src/TypeDefinitionRequest.php: -------------------------------------------------------------------------------- 1 | 14 | */ 15 | public $unregisterations; 16 | 17 | /** 18 | * @param array $unregisterations 19 | */ 20 | public function __construct(array $unregisterations) 21 | { 22 | $this->unregisterations = $unregisterations; 23 | } 24 | 25 | /** 26 | * @param array $array 27 | * @return self 28 | */ 29 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 30 | { 31 | $map = [ 32 | 'unregisterations' => ['names' => [Unregistration::class], 'iterable' => true], 33 | ]; 34 | 35 | foreach ($array as $key => &$value) { 36 | if (!isset($map[$key])) { 37 | if ($allowUnknownKeys) { 38 | unset($array[$key]); 39 | continue; 40 | } 41 | 42 | throw new RuntimeException(sprintf( 43 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 44 | $key, 45 | self::class, 46 | implode('", "', array_keys($map)) 47 | )); 48 | } 49 | 50 | // from here we only care about arrays that can be transformed into 51 | // objects 52 | if (!is_array($value)) { 53 | continue; 54 | } 55 | 56 | if (empty($map[$key]['names'])) { 57 | continue; 58 | } 59 | 60 | if ($map[$key]['iterable']) { 61 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 62 | if (!is_array($object)) { 63 | return $object; 64 | } 65 | 66 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 67 | }, $value); 68 | continue; 69 | } 70 | 71 | $names = $map[$key]['names']; 72 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 73 | } 74 | 75 | return Invoke::new(self::class, $array); 76 | } 77 | 78 | /** 79 | * @param array $classNames 80 | * @param array $object 81 | */ 82 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 83 | { 84 | $lastException = null; 85 | foreach ($classNames as $className) { 86 | try { 87 | // @phpstan-ignore-next-line 88 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 89 | } catch (Exception $exception) { 90 | $lastException = $exception; 91 | continue; 92 | } 93 | } 94 | 95 | throw $lastException; 96 | } 97 | 98 | } -------------------------------------------------------------------------------- /src/UnregistrationRequest.php: -------------------------------------------------------------------------------- 1 | token = $token; 24 | } 25 | 26 | /** 27 | * @param array $array 28 | * @return self 29 | */ 30 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 31 | { 32 | $map = [ 33 | 'token' => ['names' => [], 'iterable' => false], 34 | ]; 35 | 36 | foreach ($array as $key => &$value) { 37 | if (!isset($map[$key])) { 38 | if ($allowUnknownKeys) { 39 | unset($array[$key]); 40 | continue; 41 | } 42 | 43 | throw new RuntimeException(sprintf( 44 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 45 | $key, 46 | self::class, 47 | implode('", "', array_keys($map)) 48 | )); 49 | } 50 | 51 | // from here we only care about arrays that can be transformed into 52 | // objects 53 | if (!is_array($value)) { 54 | continue; 55 | } 56 | 57 | if (empty($map[$key]['names'])) { 58 | continue; 59 | } 60 | 61 | if ($map[$key]['iterable']) { 62 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 63 | if (!is_array($object)) { 64 | return $object; 65 | } 66 | 67 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 68 | }, $value); 69 | continue; 70 | } 71 | 72 | $names = $map[$key]['names']; 73 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 74 | } 75 | 76 | return Invoke::new(self::class, $array); 77 | } 78 | 79 | /** 80 | * @param array $classNames 81 | * @param array $object 82 | */ 83 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 84 | { 85 | $lastException = null; 86 | foreach ($classNames as $className) { 87 | try { 88 | // @phpstan-ignore-next-line 89 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 90 | } catch (Exception $exception) { 91 | $lastException = $exception; 92 | continue; 93 | } 94 | } 95 | 96 | throw $lastException; 97 | } 98 | 99 | } -------------------------------------------------------------------------------- /src/WorkDoneProgressCreateParams.php: -------------------------------------------------------------------------------- 1 | token = $token; 24 | } 25 | 26 | /** 27 | * @param array $array 28 | * @return self 29 | */ 30 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 31 | { 32 | $map = [ 33 | 'token' => ['names' => [], 'iterable' => false], 34 | ]; 35 | 36 | foreach ($array as $key => &$value) { 37 | if (!isset($map[$key])) { 38 | if ($allowUnknownKeys) { 39 | unset($array[$key]); 40 | continue; 41 | } 42 | 43 | throw new RuntimeException(sprintf( 44 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 45 | $key, 46 | self::class, 47 | implode('", "', array_keys($map)) 48 | )); 49 | } 50 | 51 | // from here we only care about arrays that can be transformed into 52 | // objects 53 | if (!is_array($value)) { 54 | continue; 55 | } 56 | 57 | if (empty($map[$key]['names'])) { 58 | continue; 59 | } 60 | 61 | if ($map[$key]['iterable']) { 62 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 63 | if (!is_array($object)) { 64 | return $object; 65 | } 66 | 67 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 68 | }, $value); 69 | continue; 70 | } 71 | 72 | $names = $map[$key]['names']; 73 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 74 | } 75 | 76 | return Invoke::new(self::class, $array); 77 | } 78 | 79 | /** 80 | * @param array $classNames 81 | * @param array $object 82 | */ 83 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 84 | { 85 | $lastException = null; 86 | foreach ($classNames as $className) { 87 | try { 88 | // @phpstan-ignore-next-line 89 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 90 | } catch (Exception $exception) { 91 | $lastException = $exception; 92 | continue; 93 | } 94 | } 95 | 96 | throw $lastException; 97 | } 98 | 99 | } -------------------------------------------------------------------------------- /src/WorkDoneProgressCreateRequest.php: -------------------------------------------------------------------------------- 1 | workDoneProgress = $workDoneProgress; 23 | } 24 | 25 | /** 26 | * @param array $array 27 | * @return self 28 | */ 29 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 30 | { 31 | $map = [ 32 | 'workDoneProgress' => ['names' => [], 'iterable' => false], 33 | ]; 34 | 35 | foreach ($array as $key => &$value) { 36 | if (!isset($map[$key])) { 37 | if ($allowUnknownKeys) { 38 | unset($array[$key]); 39 | continue; 40 | } 41 | 42 | throw new RuntimeException(sprintf( 43 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 44 | $key, 45 | self::class, 46 | implode('", "', array_keys($map)) 47 | )); 48 | } 49 | 50 | // from here we only care about arrays that can be transformed into 51 | // objects 52 | if (!is_array($value)) { 53 | continue; 54 | } 55 | 56 | if (empty($map[$key]['names'])) { 57 | continue; 58 | } 59 | 60 | if ($map[$key]['iterable']) { 61 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 62 | if (!is_array($object)) { 63 | return $object; 64 | } 65 | 66 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 67 | }, $value); 68 | continue; 69 | } 70 | 71 | $names = $map[$key]['names']; 72 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 73 | } 74 | 75 | return Invoke::new(self::class, $array); 76 | } 77 | 78 | /** 79 | * @param array $classNames 80 | * @param array $object 81 | */ 82 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 83 | { 84 | $lastException = null; 85 | foreach ($classNames as $className) { 86 | try { 87 | // @phpstan-ignore-next-line 88 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 89 | } catch (Exception $exception) { 90 | $lastException = $exception; 91 | continue; 92 | } 93 | } 94 | 95 | throw $lastException; 96 | } 97 | 98 | } -------------------------------------------------------------------------------- /src/WorkDoneProgressParams.php: -------------------------------------------------------------------------------- 1 | workDoneToken = $workDoneToken; 24 | } 25 | 26 | /** 27 | * @param array $array 28 | * @return self 29 | */ 30 | public static function fromArray(array $array, bool $allowUnknownKeys = false) 31 | { 32 | $map = [ 33 | 'workDoneToken' => ['names' => [], 'iterable' => false], 34 | ]; 35 | 36 | foreach ($array as $key => &$value) { 37 | if (!isset($map[$key])) { 38 | if ($allowUnknownKeys) { 39 | unset($array[$key]); 40 | continue; 41 | } 42 | 43 | throw new RuntimeException(sprintf( 44 | 'Parameter "%s" on class "%s" not known, known parameters: "%s"', 45 | $key, 46 | self::class, 47 | implode('", "', array_keys($map)) 48 | )); 49 | } 50 | 51 | // from here we only care about arrays that can be transformed into 52 | // objects 53 | if (!is_array($value)) { 54 | continue; 55 | } 56 | 57 | if (empty($map[$key]['names'])) { 58 | continue; 59 | } 60 | 61 | if ($map[$key]['iterable']) { 62 | $value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) { 63 | if (!is_array($object)) { 64 | return $object; 65 | } 66 | 67 | return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object; 68 | }, $value); 69 | continue; 70 | } 71 | 72 | $names = $map[$key]['names']; 73 | $value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value; 74 | } 75 | 76 | return Invoke::new(self::class, $array); 77 | } 78 | 79 | /** 80 | * @param array $classNames 81 | * @param array $object 82 | */ 83 | private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object 84 | { 85 | $lastException = null; 86 | foreach ($classNames as $className) { 87 | try { 88 | // @phpstan-ignore-next-line 89 | return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]); 90 | } catch (Exception $exception) { 91 | $lastException = $exception; 92 | continue; 93 | } 94 | } 95 | 96 | throw $lastException; 97 | } 98 | 99 | } -------------------------------------------------------------------------------- /src/WorkspaceFoldersRequest.php: -------------------------------------------------------------------------------- 1 |