Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions src/CallHierarchyClientCapabilities.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?php // Auto-generated from vscode-languageserver-protocol (typescript)

namespace Phpactor\LanguageServerProtocol;

use DTL\Invoke\Invoke;
use Exception;
use RuntimeException;

/**
*/
class CallHierarchyClientCapabilities
{
/**
* Whether implementation supports dynamic registration. If this is set to `true`
* the client supports the new `(TextDocumentRegistrationOptions & StaticRegistrationOptions)`
* return value for the corresponding server capability as well.
*
* @var bool|null
*/
public $dynamicRegistration;

/**
* @param bool|null $dynamicRegistration
*/
public function __construct(?bool $dynamicRegistration = null)
{
$this->dynamicRegistration = $dynamicRegistration;
}

/**
* @param array<string,mixed> $array
* @return self
*/
public static function fromArray(array $array, bool $allowUnknownKeys = false)
{
$map = [
'dynamicRegistration' => ['names' => [], 'iterable' => false],
];

foreach ($array as $key => &$value) {
if (!isset($map[$key])) {
if ($allowUnknownKeys) {
unset($array[$key]);
continue;
}

throw new RuntimeException(sprintf(
'Parameter "%s" on class "%s" not known, known parameters: "%s"',
$key,
self::class,
implode('", "', array_keys($map))
));
}

// from here we only care about arrays that can be transformed into
// objects
if (!is_array($value)) {
continue;
}

if (empty($map[$key]['names'])) {
continue;
}

if ($map[$key]['iterable']) {
$value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) {
if (!is_array($object)) {
return $object;
}

return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object;
}, $value);
continue;
}

$names = $map[$key]['names'];
$value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value;
}

return Invoke::new(self::class, $array);
}

/**
* @param array<string> $classNames
* @param array<string,mixed> $object
*/
private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object
{
$lastException = null;
foreach ($classNames as $className) {
try {
// @phpstan-ignore-next-line
return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]);
} catch (Exception $exception) {
$lastException = $exception;
continue;
}
}

throw $lastException;
}

}
124 changes: 124 additions & 0 deletions src/CallHierarchyIncomingCallsParams.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<?php // Auto-generated from vscode-languageserver-protocol (typescript)

namespace Phpactor\LanguageServerProtocol;

use DTL\Invoke\Invoke;
use Exception;
use RuntimeException;

/**
* The parameter of a `callHierarchy/incomingCalls` request.
*
* Mixins (implemented TS interfaces): WorkDoneProgressParams, PartialResultParams
*/
class CallHierarchyIncomingCallsParams extends WorkDoneProgressParams
{
/**
*
* @var CallHierarchyItem
*/
public $item;

/**
* An optional token that a server can use to report work done progress.
*
* @var int|string|null
*/
public $workDoneToken;

/**
* An optional token that a server can use to report partial results (e.g. streaming) to
* the client.
*
* @var int|string|null
*/
public $partialResultToken;

/**
* @param CallHierarchyItem $item
* @param int|string|null $workDoneToken
* @param int|string|null $partialResultToken
*/
public function __construct(CallHierarchyItem $item, $workDoneToken = null, $partialResultToken = null)
{
$this->item = $item;
$this->workDoneToken = $workDoneToken;
$this->partialResultToken = $partialResultToken;
}

/**
* @param array<string,mixed> $array
* @return self
*/
public static function fromArray(array $array, bool $allowUnknownKeys = false)
{
$map = [
'item' => ['names' => [CallHierarchyItem::class], 'iterable' => false],
'workDoneToken' => ['names' => [], 'iterable' => false],
'partialResultToken' => ['names' => [], 'iterable' => false],
];

foreach ($array as $key => &$value) {
if (!isset($map[$key])) {
if ($allowUnknownKeys) {
unset($array[$key]);
continue;
}

throw new RuntimeException(sprintf(
'Parameter "%s" on class "%s" not known, known parameters: "%s"',
$key,
self::class,
implode('", "', array_keys($map))
));
}

// from here we only care about arrays that can be transformed into
// objects
if (!is_array($value)) {
continue;
}

if (empty($map[$key]['names'])) {
continue;
}

if ($map[$key]['iterable']) {
$value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) {
if (!is_array($object)) {
return $object;
}

return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object;
}, $value);
continue;
}

$names = $map[$key]['names'];
$value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value;
}

return Invoke::new(self::class, $array);
}

/**
* @param array<string> $classNames
* @param array<string,mixed> $object
*/
private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object
{
$lastException = null;
foreach ($classNames as $className) {
try {
// @phpstan-ignore-next-line
return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]);
} catch (Exception $exception) {
$lastException = $exception;
continue;
}
}

throw $lastException;
}

}
8 changes: 8 additions & 0 deletions src/CallHierarchyIncomingCallsRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php // Auto-generated from vscode-languageserver-protocol (typescript)

namespace Phpactor\LanguageServerProtocol;

interface CallHierarchyIncomingCallsRequest
{
public const METHOD = 'callHierarchy/incomingCalls';
}
103 changes: 103 additions & 0 deletions src/CallHierarchyOptions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?php // Auto-generated from vscode-languageserver-protocol (typescript)

namespace Phpactor\LanguageServerProtocol;

use DTL\Invoke\Invoke;
use Exception;
use RuntimeException;

/**
* Call hierarchy options used during static registration.
*
* Mixins (implemented TS interfaces): WorkDoneProgressOptions
*/
class CallHierarchyOptions extends WorkDoneProgressOptions
{
/**
*
* @var bool|null
*/
public $workDoneProgress;

/**
* @param bool|null $workDoneProgress
*/
public function __construct(?bool $workDoneProgress = null)
{
$this->workDoneProgress = $workDoneProgress;
}

/**
* @param array<string,mixed> $array
* @return self
*/
public static function fromArray(array $array, bool $allowUnknownKeys = false)
{
$map = [
'workDoneProgress' => ['names' => [], 'iterable' => false],
];

foreach ($array as $key => &$value) {
if (!isset($map[$key])) {
if ($allowUnknownKeys) {
unset($array[$key]);
continue;
}

throw new RuntimeException(sprintf(
'Parameter "%s" on class "%s" not known, known parameters: "%s"',
$key,
self::class,
implode('", "', array_keys($map))
));
}

// from here we only care about arrays that can be transformed into
// objects
if (!is_array($value)) {
continue;
}

if (empty($map[$key]['names'])) {
continue;
}

if ($map[$key]['iterable']) {
$value = array_map(function ($object) use ($map, $key, $allowUnknownKeys) {
if (!is_array($object)) {
return $object;
}

return self::invokeFromNames($map[$key]['names'], $object, $allowUnknownKeys) ?: $object;
}, $value);
continue;
}

$names = $map[$key]['names'];
$value = self::invokeFromNames($names, $value, $allowUnknownKeys) ?: $value;
}

return Invoke::new(self::class, $array);
}

/**
* @param array<string> $classNames
* @param array<string,mixed> $object
*/
private static function invokeFromNames(array $classNames, array $object, bool $allowUnknownKeys): ?object
{
$lastException = null;
foreach ($classNames as $className) {
try {
// @phpstan-ignore-next-line
return call_user_func_array($className . '::fromArray', [$object, $allowUnknownKeys]);
} catch (Exception $exception) {
$lastException = $exception;
continue;
}
}

throw $lastException;
}

}
Loading
Loading