hypertube-binaries 3.0.2 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Binaries/Clr/Hypertube.Clr.Utils.dll +0 -0
- package/Binaries/Clr/HypertubeClrRuntime.dll +0 -0
- package/Binaries/Jvm/HypertubeJvmRuntime.jar +0 -0
- package/Binaries/Native/Linux/ARM64/NetVersionLatest.runtimeconfig.json +2 -2
- package/Binaries/Native/Linux/{X64/_HypertubeNativeErrorLogger_2026-04-17.txt → ARM64/_HypertubeNativeErrorLogger_2026-05-05.txt} +1 -1
- package/Binaries/Native/Linux/ARM64/libHypertubeActivationService.so +0 -0
- package/Binaries/Native/Linux/ARM64/libHypertubeNetcoreRuntimeNative.so +0 -0
- package/Binaries/Native/Linux/ARM64/libUtils.so +0 -0
- package/Binaries/Native/Linux/ARM64/version.txt +1 -1
- package/Binaries/Native/Linux/X64/NetVersionLatest.runtimeconfig.json +2 -2
- package/Binaries/Native/Linux/{ARM64/_HypertubeNativeErrorLogger_2026-04-17.txt → X64/_HypertubeNativeErrorLogger_2026-05-05.txt} +1 -1
- package/Binaries/Native/Linux/X64/libHypertubeActivationService.so +0 -0
- package/Binaries/Native/Linux/X64/libHypertubeNetcoreRuntimeNative.so +0 -0
- package/Binaries/Native/Linux/X64/libHypertubeNodejs2218RuntimeNative.so +0 -0
- package/Binaries/Native/Linux/X64/libUtils.so +0 -0
- package/Binaries/Native/Linux/X64/version.txt +1 -1
- package/Binaries/Native/MacOs/ARM64/NetVersionLatest.runtimeconfig.json +2 -2
- package/Binaries/Native/MacOs/ARM64/_HypertubeNativeErrorLogger_2026-05-05.txt +2 -0
- package/Binaries/Native/MacOs/ARM64/libHypertubeActivationService.dylib +0 -0
- package/Binaries/Native/MacOs/ARM64/libHypertubeNetcoreRuntimeNative.dylib +0 -0
- package/Binaries/Native/MacOs/ARM64/libHypertubeNodejs2218RuntimeNative.dylib +0 -0
- package/Binaries/Native/MacOs/ARM64/libUtils.dylib +0 -0
- package/Binaries/Native/MacOs/ARM64/version.txt +1 -1
- package/Binaries/Native/MacOs/X64/NetVersionLatest.runtimeconfig.json +2 -2
- package/Binaries/Native/MacOs/X64/{_HypertubeNativeErrorLogger_2026-04-17.txt → _HypertubeNativeErrorLogger_2026-05-05.txt} +1 -1
- package/Binaries/Native/MacOs/X64/libHypertubeActivationService.dylib +0 -0
- package/Binaries/Native/MacOs/X64/libHypertubeNetcoreRuntimeNative.dylib +0 -0
- package/Binaries/Native/MacOs/X64/libHypertubeNodejs2218RuntimeNative.dylib +0 -0
- package/Binaries/Native/MacOs/X64/libUtils.dylib +0 -0
- package/Binaries/Native/MacOs/X64/version.txt +1 -1
- package/Binaries/Native/Windows/ARM64/Configs.dll +0 -0
- package/Binaries/Native/Windows/ARM64/HypertubeActivationService.dll +0 -0
- package/Binaries/Native/Windows/ARM64/HypertubeCppRuntimeNative.dll +0 -0
- package/Binaries/Native/Windows/ARM64/HypertubeGoRuntimeNative.dll +0 -0
- package/Binaries/Native/Windows/ARM64/HypertubeJvmRuntimeNative.dll +0 -0
- package/Binaries/Native/Windows/ARM64/HypertubeNetcoreRuntimeNative.dll +0 -0
- package/Binaries/Native/Windows/ARM64/HypertubePhpRuntimeNative.dll +0 -0
- package/Binaries/Native/Windows/ARM64/HypertubePythonRuntimeNative.dll +0 -0
- package/Binaries/Native/Windows/ARM64/HypertubeRubyRuntimeNative.dll +0 -0
- package/Binaries/Native/Windows/ARM64/HypertubeTcpClient.dll +0 -0
- package/Binaries/Native/Windows/ARM64/HypertubeTcpTlsClient.dll +0 -0
- package/Binaries/Native/Windows/ARM64/NetVersionLatest.runtimeconfig.json +2 -2
- package/Binaries/Native/Windows/ARM64/Utils.dll +0 -0
- package/Binaries/Native/Windows/ARM64/_HypertubeNativeErrorLogger_2026-05-05.txt +2 -0
- package/Binaries/Native/Windows/ARM64/version.txt +0 -0
- package/Binaries/Native/Windows/X64/Configs.dll +0 -0
- package/Binaries/Native/Windows/X64/HypertubeActivationService.dll +0 -0
- package/Binaries/Native/Windows/X64/HypertubeClrRuntimeNative.dll +0 -0
- package/Binaries/Native/Windows/X64/HypertubeCppRuntimeNative.dll +0 -0
- package/Binaries/Native/Windows/X64/HypertubeGoRuntimeNative.dll +0 -0
- package/Binaries/Native/Windows/X64/HypertubeJvmRuntimeNative.dll +0 -0
- package/Binaries/Native/Windows/X64/HypertubeNetcoreRuntimeNative.dll +0 -0
- package/Binaries/Native/Windows/X64/HypertubeNodejs2218RuntimeNative.dll +0 -0
- package/Binaries/Native/Windows/X64/HypertubeNodejsRuntimeNative.dll +0 -0
- package/Binaries/Native/Windows/X64/HypertubePhp848RuntimeNative.dll +0 -0
- package/Binaries/Native/Windows/X64/HypertubePhpRuntimeNative.dll +0 -0
- package/Binaries/Native/Windows/X64/HypertubePythonRuntimeNative.dll +0 -0
- package/Binaries/Native/Windows/X64/HypertubeRubyRuntimeNative.dll +0 -0
- package/Binaries/Native/Windows/X64/HypertubeTcpClient.dll +0 -0
- package/Binaries/Native/Windows/X64/HypertubeTcpTlsClient.dll +0 -0
- package/Binaries/Native/Windows/X64/NetVersionLatest.runtimeconfig.json +2 -2
- package/Binaries/Native/Windows/X64/Utils.dll +0 -0
- package/Binaries/Native/Windows/X64/_HypertubeNativeErrorLogger_2026-05-05.txt +2 -0
- package/Binaries/Native/Windows/X64/version.txt +1 -1
- package/Binaries/Netcore/Hypertube.Netcore.Core.dll +0 -0
- package/Binaries/Netcore/Hypertube.Netcore.Plugins.dll +0 -0
- package/Binaries/Netcore/Hypertube.Netcore.Utils.dll +0 -0
- package/Binaries/Php/hypertube/core/delegatecache/DelegatesCache.php +62 -62
- package/Binaries/Php/hypertube/core/handler/AbstractHandler.php +61 -61
- package/Binaries/Php/hypertube/core/handler/AddEventListenerHandler.php +16 -16
- package/Binaries/Php/hypertube/core/handler/ArrayGetItemHandler.php +57 -57
- package/Binaries/Php/hypertube/core/handler/ArrayGetRankHandler.php +50 -50
- package/Binaries/Php/hypertube/core/handler/ArrayGetSizeHandler.php +59 -59
- package/Binaries/Php/hypertube/core/handler/ArrayHandler.php +26 -26
- package/Binaries/Php/hypertube/core/handler/ArrayReferenceHandler.php +16 -16
- package/Binaries/Php/hypertube/core/handler/ArraySetItemHandler.php +87 -87
- package/Binaries/Php/hypertube/core/handler/AsDtoHandler.php +18 -18
- package/Binaries/Php/hypertube/core/handler/AsKwargsHandler.php +19 -19
- package/Binaries/Php/hypertube/core/handler/AsOutHandler.php +19 -19
- package/Binaries/Php/hypertube/core/handler/AsRefHandler.php +20 -20
- package/Binaries/Php/hypertube/core/handler/CastHandler.php +93 -93
- package/Binaries/Php/hypertube/core/handler/ContextMetadataHandler.php +20 -0
- package/Binaries/Php/hypertube/core/handler/ConvertTypeHandler.php +20 -20
- package/Binaries/Php/hypertube/core/handler/CreateInstanceHandler.php +98 -98
- package/Binaries/Php/hypertube/core/handler/CreateNullHandler.php +16 -16
- package/Binaries/Php/hypertube/core/handler/DestructReferenceHandler.php +29 -29
- package/Binaries/Php/hypertube/core/handler/DtoPropertyHandler.php +18 -18
- package/Binaries/Php/hypertube/core/handler/EnableNamespaceHandler.php +36 -36
- package/Binaries/Php/hypertube/core/handler/EnableTypeHandler.php +33 -33
- package/Binaries/Php/hypertube/core/handler/ExceptionHandler.php +16 -16
- package/Binaries/Php/hypertube/core/handler/GenerateLibHandler.php +16 -16
- package/Binaries/Php/hypertube/core/handler/GetAsyncOperationResultHandler.php +16 -16
- package/Binaries/Php/hypertube/core/handler/GetEnumItemHandler.php +16 -16
- package/Binaries/Php/hypertube/core/handler/GetEnumNameHandler.php +16 -16
- package/Binaries/Php/hypertube/core/handler/GetEnumValueHandler.php +16 -16
- package/Binaries/Php/hypertube/core/handler/GetGlobalFieldHandler.php +16 -16
- package/Binaries/Php/hypertube/core/handler/GetInstanceFieldHandler.php +55 -55
- package/Binaries/Php/hypertube/core/handler/GetInstanceMethodAsDelegateHandler.php +52 -52
- package/Binaries/Php/hypertube/core/handler/GetModuleHandler.php +15 -15
- package/Binaries/Php/hypertube/core/handler/GetRefValueHandler.php +16 -16
- package/Binaries/Php/hypertube/core/handler/GetResultTypeHandler.php +16 -16
- package/Binaries/Php/hypertube/core/handler/GetStaticFieldHandler.php +81 -81
- package/Binaries/Php/hypertube/core/handler/GetStaticMethodAsDelegateHandler.php +109 -109
- package/Binaries/Php/hypertube/core/handler/GetTypeHandler.php +146 -146
- package/Binaries/Php/hypertube/core/handler/Handler.php +176 -175
- package/Binaries/Php/hypertube/core/handler/HeartBeatHandler.php +20 -20
- package/Binaries/Php/hypertube/core/handler/InvokeDelegateHandler.php +27 -27
- package/Binaries/Php/hypertube/core/handler/InvokeGenericMethodHandler.php +47 -47
- package/Binaries/Php/hypertube/core/handler/InvokeGenericStaticMethodHandler.php +111 -111
- package/Binaries/Php/hypertube/core/handler/InvokeGlobalFunctionHandler.php +48 -48
- package/Binaries/Php/hypertube/core/handler/InvokeInstanceMethodHandler.php +78 -78
- package/Binaries/Php/hypertube/core/handler/InvokeStaticMethodHandler.php +95 -95
- package/Binaries/Php/hypertube/core/handler/LoadLibraryHandler.php +360 -360
- package/Binaries/Php/hypertube/core/handler/OptimizeHandler.php +16 -16
- package/Binaries/Php/hypertube/core/handler/PassByValueHandler.php +103 -103
- package/Binaries/Php/hypertube/core/handler/PassDelegateHandler.php +58 -58
- package/Binaries/Php/hypertube/core/handler/PluginWrapperHandler.php +15 -15
- package/Binaries/Php/hypertube/core/handler/ProjectResultAsDtoHandler.php +68 -68
- package/Binaries/Php/hypertube/core/handler/RegisterForUpdateHandler.php +65 -65
- package/Binaries/Php/hypertube/core/handler/ResolveInstanceHandler.php +27 -27
- package/Binaries/Php/hypertube/core/handler/RetrieveArrayHandler.php +48 -48
- package/Binaries/Php/hypertube/core/handler/SetInstanceFieldHandler.php +54 -54
- package/Binaries/Php/hypertube/core/handler/SetStaticFieldHandler.php +56 -56
- package/Binaries/Php/hypertube/core/handler/ValueForUpdateHandler.php +20 -20
- package/Binaries/Php/hypertube/core/handler/ValueHandler.php +18 -18
- package/Binaries/Php/hypertube/core/handler/loadLibrary/ClasspathScanner.php +66 -66
- package/Binaries/Php/hypertube/core/http2Client/Http2Client.php +50 -0
- package/Binaries/Php/hypertube/core/interpreter/Interpreter.php +126 -123
- package/Binaries/Php/hypertube/core/namespacescache/NamespacesCache.php +88 -88
- package/Binaries/Php/hypertube/core/protocol/CommandDeserializer.php +337 -337
- package/Binaries/Php/hypertube/core/protocol/CommandSerializer.php +112 -112
- package/Binaries/Php/hypertube/core/protocol/TypeDeserializer.php +102 -102
- package/Binaries/Php/hypertube/core/protocol/TypeSerializer.php +188 -188
- package/Binaries/Php/hypertube/core/receiver/Receiver.php +45 -45
- package/Binaries/Php/hypertube/core/referencecache/ReferencesCache.php +68 -68
- package/Binaries/Php/hypertube/core/transmitter/Transmitter.php +47 -47
- package/Binaries/Php/hypertube/core/transmitter/TransmitterWrapper.php +181 -181
- package/Binaries/Php/hypertube/core/typescache/TypesCache.php +60 -60
- package/Binaries/Php/hypertube/core/webSocketClient/WebSocketClient.php +626 -620
- package/Binaries/Php/hypertube/utils/ArrayWrapper.php +122 -122
- package/Binaries/Php/hypertube/utils/Command.php +265 -265
- package/Binaries/Php/hypertube/utils/CommandInterface.php +23 -23
- package/Binaries/Php/hypertube/utils/DynamicMethodFactory.php +93 -93
- package/Binaries/Php/hypertube/utils/Enum.php +87 -87
- package/Binaries/Php/hypertube/utils/ExceptionSerializer.php +81 -81
- package/Binaries/Php/hypertube/utils/RuntimeLogger.php +44 -44
- package/Binaries/Php/hypertube/utils/RuntimeName.php +21 -21
- package/Binaries/Php/hypertube/utils/RuntimeNameHandler.php +72 -72
- package/Binaries/Php/hypertube/utils/StringEncodingMode.php +12 -12
- package/Binaries/Php/hypertube/utils/TypesHandler.php +47 -47
- package/Binaries/Php/hypertube/utils/Uri.php +138 -138
- package/Binaries/Php/hypertube/utils/UtilsArray.php +16 -16
- package/Binaries/Php/hypertube/utils/UtilsConst.php +75 -75
- package/Binaries/Php/hypertube/utils/UtilsSimpleType.php +48 -48
- package/Binaries/Php/hypertube/utils/Uuid.php +47 -47
- package/Binaries/Php/hypertube/utils/connectiondata/ConnectionData.php +84 -0
- package/Binaries/Php/hypertube/utils/connectiondata/Http2ConnectionData.php +43 -0
- package/Binaries/Php/hypertube/utils/connectiondata/IConnectionData.php +19 -15
- package/Binaries/Php/hypertube/utils/connectiondata/InMemoryConnectionData.php +25 -35
- package/Binaries/Php/hypertube/utils/connectiondata/TcpConnectionData.php +68 -77
- package/Binaries/Php/hypertube/utils/connectiondata/WsConnectionData.php +43 -43
- package/Binaries/Php/hypertube/utils/error/UnsupportedPayloadItemTypeError.php +19 -19
- package/Binaries/Php/hypertube/utils/exception/BadMethodCallException.php +14 -14
- package/Binaries/Php/hypertube/utils/exception/DelegateNotFoundException.php +14 -14
- package/Binaries/Php/hypertube/utils/exception/ExceptionThrower.php +121 -121
- package/Binaries/Php/hypertube/utils/exception/FieldNotFoundInClassException.php +41 -41
- package/Binaries/Php/hypertube/utils/exception/HypertubeArgumentsMismatchException.php +17 -17
- package/Binaries/Php/hypertube/utils/exception/InvalidUriException.php +14 -14
- package/Binaries/Php/hypertube/utils/exception/SingletonUnserializeException.php +15 -15
- package/Binaries/Php/hypertube/utils/exception/TypeByteNotSupportedException.php +14 -14
- package/Binaries/Php/hypertube/utils/exception/TypeNotSupportedException.php +16 -16
- package/Binaries/Php/hypertube/utils/exception/TypeSerializationNotSupportedException.php +18 -18
- package/Binaries/Php/hypertube/utils/exception/UnsupportedOperationException.php +10 -10
- package/Binaries/Php/hypertube/utils/exception/enum/EnumNameNotFoundException.php +15 -15
- package/Binaries/Php/hypertube/utils/exception/enum/InvalidEnumValueException.php +15 -15
- package/Binaries/Php/hypertube/utils/messagehelper/MessageHelper.php +102 -102
- package/Binaries/Php/hypertube/utils/type/CommandType.php +67 -66
- package/Binaries/Php/hypertube/utils/type/ConnectionType.php +15 -14
- package/Binaries/Php/hypertube/utils/type/ExceptionType.php +45 -45
- package/Binaries/Php/hypertube/utils/type/JType.php +24 -24
- package/Binaries/Php/hypertube/utils/type/SizeType.php +22 -22
- package/Binaries/Python/hypertube/core/handler/ContextMetadataHandler.py +7 -0
- package/Binaries/Python/hypertube/core/handler/Handler.py +2 -0
- package/Binaries/Python/hypertube/core/http2Client/Http2Client.py +332 -0
- package/Binaries/Python/hypertube/core/interpreter/Interpreter.py +4 -1
- package/Binaries/Python/hypertube/core/webSocketClient/WebSocketClient.py +81 -25
- package/Binaries/Python/hypertube/utils/CommandType.py +2 -1
- package/Binaries/Python/hypertube/utils/ConnectionType.py +1 -0
- package/Binaries/Python/hypertube/utils/connectionData/Http2ConnectionData.py +36 -0
- package/Binaries/Python/hypertube/utils/connectionData/IConnectionData.py +38 -0
- package/Binaries/Python/hypertube/utils/connectionData/InMemoryConnectionData.py +4 -12
- package/Binaries/Python/hypertube/utils/connectionData/TcpConnectionData.py +4 -15
- package/Binaries/Python/hypertube/utils/connectionData/WsConnectionData.py +14 -12
- package/Binaries/Python/hypertube/utils/messageHelper/MessageHelper.py +20 -15
- package/Binaries/Ruby/core/handler/context_metadata_handler.rb +11 -0
- package/Binaries/Ruby/core/handler/handler.rb +3 -0
- package/Binaries/Ruby/core/http2_client/http2_client.rb +69 -0
- package/Binaries/Ruby/core/interpreter/interpreter.rb +7 -4
- package/Binaries/Ruby/core/web_socket_client/web_socket_client.rb +41 -25
- package/Binaries/Ruby/utils/command_type.rb +3 -0
- package/Binaries/Ruby/utils/connection_type.rb +1 -0
- package/Binaries/Ruby/utils/http2_connection_data.rb +59 -0
- package/Binaries/Ruby/utils/tcp_connection_data.rb +38 -6
- package/Binaries/Ruby/utils/ws_connection_data.rb +40 -6
- package/Binaries/version.txt +1 -1
- package/package.json +1 -1
- package/prebuilds/prebuilds-darwin-arm64/HypertubeNodejsRuntimeAddon.node +0 -0
- package/prebuilds/prebuilds-darwin-x64/HypertubeNodejsRuntimeAddon.node +0 -0
- package/prebuilds/prebuilds-win32-arm64/HypertubeNodejsRuntimeAddon.node +0 -0
- package/prebuilds/prebuilds-win32-x64/HypertubeNodejsRuntimeAddon.node +0 -0
- package/Binaries/Native/Linux/ARM64/NetVersion31LatestPatch.runtimeconfig.json +0 -10
- package/Binaries/Native/Linux/ARM64/NetVersion60LatestPatch.runtimeconfig.json +0 -10
- package/Binaries/Native/Linux/ARM64/NetVersion70LatestPatch.runtimeconfig.json +0 -10
- package/Binaries/Native/Linux/X64/NetVersion31LatestPatch.runtimeconfig.json +0 -10
- package/Binaries/Native/Linux/X64/NetVersion60LatestPatch.runtimeconfig.json +0 -10
- package/Binaries/Native/Linux/X64/NetVersion70LatestPatch.runtimeconfig.json +0 -10
- package/Binaries/Native/MacOs/ARM64/NetVersion31LatestPatch.runtimeconfig.json +0 -10
- package/Binaries/Native/MacOs/ARM64/NetVersion60LatestPatch.runtimeconfig.json +0 -10
- package/Binaries/Native/MacOs/ARM64/NetVersion70LatestPatch.runtimeconfig.json +0 -10
- package/Binaries/Native/MacOs/ARM64/_HypertubeNativeErrorLogger_2026-04-17.txt +0 -2
- package/Binaries/Native/MacOs/X64/NetVersion31LatestPatch.runtimeconfig.json +0 -10
- package/Binaries/Native/MacOs/X64/NetVersion60LatestPatch.runtimeconfig.json +0 -10
- package/Binaries/Native/MacOs/X64/NetVersion70LatestPatch.runtimeconfig.json +0 -10
- package/Binaries/Native/Windows/ARM64/NetVersion31LatestPatch.runtimeconfig.json +0 -10
- package/Binaries/Native/Windows/ARM64/NetVersion60LatestPatch.runtimeconfig.json +0 -10
- package/Binaries/Native/Windows/ARM64/NetVersion70LatestPatch.runtimeconfig.json +0 -10
- package/Binaries/Native/Windows/ARM64/_HypertubeNativeErrorLogger_2026-04-17.txt +0 -2
- package/Binaries/Native/Windows/X64/NetVersion31LatestPatch.runtimeconfig.json +0 -10
- package/Binaries/Native/Windows/X64/NetVersion60LatestPatch.runtimeconfig.json +0 -10
- package/Binaries/Native/Windows/X64/NetVersion70LatestPatch.runtimeconfig.json +0 -10
- package/Binaries/Native/Windows/X64/_HypertubeNativeErrorLogger_2026-04-17.txt +0 -2
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
|
|
3
|
-
declare(strict_types=1);
|
|
4
|
-
|
|
5
|
-
namespace core\handler;
|
|
6
|
-
|
|
7
|
-
use Exception;
|
|
8
|
-
use utils\CommandInterface;
|
|
9
|
-
|
|
10
|
-
final class HeartBeatHandler extends AbstractHandler
|
|
11
|
-
{
|
|
12
|
-
/**
|
|
13
|
-
* @throws Exception
|
|
14
|
-
*/
|
|
15
|
-
public function process(CommandInterface $command)
|
|
16
|
-
{
|
|
17
|
-
throw new Exception(__CLASS__ . ' is not implemented in PHP');
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
declare(strict_types=1);
|
|
4
|
+
|
|
5
|
+
namespace core\handler;
|
|
6
|
+
|
|
7
|
+
use Exception;
|
|
8
|
+
use utils\CommandInterface;
|
|
9
|
+
|
|
10
|
+
final class HeartBeatHandler extends AbstractHandler
|
|
11
|
+
{
|
|
12
|
+
/**
|
|
13
|
+
* @throws Exception
|
|
14
|
+
*/
|
|
15
|
+
public function process(CommandInterface $command)
|
|
16
|
+
{
|
|
17
|
+
throw new Exception(__CLASS__ . ' is not implemented in PHP');
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
|
|
3
|
-
declare(strict_types=1);
|
|
4
|
-
|
|
5
|
-
namespace core\handler;
|
|
6
|
-
|
|
7
|
-
use core\delegatecache\DelegatesCache;
|
|
8
|
-
use utils\CommandInterface;
|
|
9
|
-
|
|
10
|
-
final class InvokeDelegateHandler extends AbstractHandler
|
|
11
|
-
{
|
|
12
|
-
private const REQUIRED_ARGUMENTS_COUNT = 1;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @return mixed
|
|
16
|
-
*/
|
|
17
|
-
public function process(CommandInterface $command)
|
|
18
|
-
{
|
|
19
|
-
$this->validate($command, self::REQUIRED_ARGUMENTS_COUNT, self::class);
|
|
20
|
-
|
|
21
|
-
$guid = (string) $command->getPayload()[0];
|
|
22
|
-
$delegate = DelegatesCache::getInstance()->getDelegate($guid);
|
|
23
|
-
$parameters = array_slice($command->getPayload(), 1);
|
|
24
|
-
|
|
25
|
-
return $delegate->invokeArgs(null, $parameters);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
declare(strict_types=1);
|
|
4
|
+
|
|
5
|
+
namespace core\handler;
|
|
6
|
+
|
|
7
|
+
use core\delegatecache\DelegatesCache;
|
|
8
|
+
use utils\CommandInterface;
|
|
9
|
+
|
|
10
|
+
final class InvokeDelegateHandler extends AbstractHandler
|
|
11
|
+
{
|
|
12
|
+
private const REQUIRED_ARGUMENTS_COUNT = 1;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @return mixed
|
|
16
|
+
*/
|
|
17
|
+
public function process(CommandInterface $command)
|
|
18
|
+
{
|
|
19
|
+
$this->validate($command, self::REQUIRED_ARGUMENTS_COUNT, self::class);
|
|
20
|
+
|
|
21
|
+
$guid = (string) $command->getPayload()[0];
|
|
22
|
+
$delegate = DelegatesCache::getInstance()->getDelegate($guid);
|
|
23
|
+
$parameters = array_slice($command->getPayload(), 1);
|
|
24
|
+
|
|
25
|
+
return $delegate->invokeArgs(null, $parameters);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
|
|
3
|
-
declare(strict_types=1);
|
|
4
|
-
|
|
5
|
-
namespace core\handler;
|
|
6
|
-
|
|
7
|
-
use utils\CommandInterface;
|
|
8
|
-
use ReflectionClass;
|
|
9
|
-
use ReflectionException;
|
|
10
|
-
|
|
11
|
-
final class InvokeGenericMethodHandler extends AbstractHandler
|
|
12
|
-
{
|
|
13
|
-
private const REQUIRED_ARGUMENTS_COUNT = 2;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @return mixed
|
|
17
|
-
*/
|
|
18
|
-
public function process(CommandInterface $command)
|
|
19
|
-
{
|
|
20
|
-
$this->validate($command, self::REQUIRED_ARGUMENTS_COUNT, self::class);
|
|
21
|
-
|
|
22
|
-
$objectOrClass = $command->getPayload()[0];
|
|
23
|
-
$methodToInvoke = $command->getPayload()[1];
|
|
24
|
-
$arguments = array_slice($command->getPayload(), 2);
|
|
25
|
-
|
|
26
|
-
try {
|
|
27
|
-
$reflectionClass = new ReflectionClass($objectOrClass);
|
|
28
|
-
$method = $reflectionClass->getMethod($methodToInvoke);
|
|
29
|
-
|
|
30
|
-
return $method->invokeArgs(is_object($objectOrClass) ? $objectOrClass : null, $arguments);
|
|
31
|
-
} catch (ReflectionException $e) {
|
|
32
|
-
$reflectionClass = new ReflectionClass($objectOrClass);
|
|
33
|
-
$methods = $reflectionClass->getMethods();
|
|
34
|
-
$className = is_object($objectOrClass) ? get_class($objectOrClass) : (string) $objectOrClass;
|
|
35
|
-
$message = sprintf('Method %s not found in class %s. Available methods:' . PHP_EOL, (string) $methodToInvoke, $className);
|
|
36
|
-
foreach ($methods as $method) {
|
|
37
|
-
$params = [];
|
|
38
|
-
foreach ($method->getParameters() as $param) {
|
|
39
|
-
$paramType = $param->getType();
|
|
40
|
-
$params[] = ($paramType ? $paramType . ' ' : '') . '$' . $param->getName();
|
|
41
|
-
}
|
|
42
|
-
$message .= $method->getName() . '(' . implode(', ', $params) . ')' . PHP_EOL;
|
|
43
|
-
}
|
|
44
|
-
throw new ReflectionException($message);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
declare(strict_types=1);
|
|
4
|
+
|
|
5
|
+
namespace core\handler;
|
|
6
|
+
|
|
7
|
+
use utils\CommandInterface;
|
|
8
|
+
use ReflectionClass;
|
|
9
|
+
use ReflectionException;
|
|
10
|
+
|
|
11
|
+
final class InvokeGenericMethodHandler extends AbstractHandler
|
|
12
|
+
{
|
|
13
|
+
private const REQUIRED_ARGUMENTS_COUNT = 2;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @return mixed
|
|
17
|
+
*/
|
|
18
|
+
public function process(CommandInterface $command)
|
|
19
|
+
{
|
|
20
|
+
$this->validate($command, self::REQUIRED_ARGUMENTS_COUNT, self::class);
|
|
21
|
+
|
|
22
|
+
$objectOrClass = $command->getPayload()[0];
|
|
23
|
+
$methodToInvoke = $command->getPayload()[1];
|
|
24
|
+
$arguments = array_slice($command->getPayload(), 2);
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
$reflectionClass = new ReflectionClass($objectOrClass);
|
|
28
|
+
$method = $reflectionClass->getMethod($methodToInvoke);
|
|
29
|
+
|
|
30
|
+
return $method->invokeArgs(is_object($objectOrClass) ? $objectOrClass : null, $arguments);
|
|
31
|
+
} catch (ReflectionException $e) {
|
|
32
|
+
$reflectionClass = new ReflectionClass($objectOrClass);
|
|
33
|
+
$methods = $reflectionClass->getMethods();
|
|
34
|
+
$className = is_object($objectOrClass) ? get_class($objectOrClass) : (string) $objectOrClass;
|
|
35
|
+
$message = sprintf('Method %s not found in class %s. Available methods:' . PHP_EOL, (string) $methodToInvoke, $className);
|
|
36
|
+
foreach ($methods as $method) {
|
|
37
|
+
$params = [];
|
|
38
|
+
foreach ($method->getParameters() as $param) {
|
|
39
|
+
$paramType = $param->getType();
|
|
40
|
+
$params[] = ($paramType ? $paramType . ' ' : '') . '$' . $param->getName();
|
|
41
|
+
}
|
|
42
|
+
$message .= $method->getName() . '(' . implode(', ', $params) . ')' . PHP_EOL;
|
|
43
|
+
}
|
|
44
|
+
throw new ReflectionException($message);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -1,111 +1,111 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
|
|
3
|
-
declare(strict_types=1);
|
|
4
|
-
|
|
5
|
-
namespace core\handler;
|
|
6
|
-
|
|
7
|
-
use ReflectionClass;
|
|
8
|
-
use ReflectionMethod;
|
|
9
|
-
use ReflectionException;
|
|
10
|
-
use ReflectionType;
|
|
11
|
-
use utils\CommandInterface;
|
|
12
|
-
|
|
13
|
-
final class InvokeGenericStaticMethodHandler extends AbstractHandler
|
|
14
|
-
{
|
|
15
|
-
private const REQUIRED_ARGUMENTS_COUNT = 2;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @return mixed
|
|
19
|
-
*/
|
|
20
|
-
public function process(CommandInterface $command)
|
|
21
|
-
{
|
|
22
|
-
$this->validate($command, self::REQUIRED_ARGUMENTS_COUNT, self::class);
|
|
23
|
-
|
|
24
|
-
$payload = $command->getPayload();
|
|
25
|
-
$className = $payload[0];
|
|
26
|
-
$methodToInvoke = (string) $payload[1];
|
|
27
|
-
$arguments = array_slice($payload, 2);
|
|
28
|
-
|
|
29
|
-
try {
|
|
30
|
-
[$reflectionClass, $className] = $this->getReflectionClassAndName($className);
|
|
31
|
-
if (!$reflectionClass->hasMethod($methodToInvoke)) {
|
|
32
|
-
$this->throwMethodNotFoundError($reflectionClass, $methodToInvoke, $arguments);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
$method = $reflectionClass->getMethod($methodToInvoke);
|
|
36
|
-
if (!$method->isStatic()) {
|
|
37
|
-
throw new ReflectionException(sprintf(
|
|
38
|
-
'Method %s in class %s is not static',
|
|
39
|
-
$methodToInvoke,
|
|
40
|
-
$className
|
|
41
|
-
)
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return $method->invokeArgs(null, $arguments);
|
|
46
|
-
|
|
47
|
-
} catch (ReflectionException $e) {
|
|
48
|
-
if (strpos($e->getMessage(), 'Class') === 0) {
|
|
49
|
-
throw new ReflectionException(sprintf('Class: %s not found', $this->getReflectionClassName($className)));
|
|
50
|
-
}
|
|
51
|
-
throw $e;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
private function throwMethodNotFoundError(
|
|
56
|
-
ReflectionClass $reflectionClass,
|
|
57
|
-
string $methodToInvoke,
|
|
58
|
-
array $arguments
|
|
59
|
-
): void {
|
|
60
|
-
$className = $reflectionClass->getName();
|
|
61
|
-
$argumentTypes = array_map('gettype', $arguments);
|
|
62
|
-
|
|
63
|
-
$message = sprintf('Generic static method %s with arguments ['
|
|
64
|
-
. implode(', ', $argumentTypes)
|
|
65
|
-
. '] not found in class %s. Available methods:' . PHP_EOL, $methodToInvoke, $className);
|
|
66
|
-
|
|
67
|
-
$methods = $reflectionClass->getMethods(ReflectionMethod::IS_STATIC | ReflectionMethod::IS_PUBLIC);
|
|
68
|
-
|
|
69
|
-
foreach ($methods as $method) {
|
|
70
|
-
$parameterTypes = array_map(function($param) {
|
|
71
|
-
return $this->getParamTypeName($param->getType());
|
|
72
|
-
}, $method->getParameters());
|
|
73
|
-
$message .= $method->getName() . ' with arguments ['. implode(', ', $parameterTypes) . "]\n";
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
throw new ReflectionException($message);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* @param mixed $payload
|
|
81
|
-
*/
|
|
82
|
-
private function getReflectionClassAndName($classToLoad): array
|
|
83
|
-
{
|
|
84
|
-
if ($classToLoad instanceof ReflectionClass) {
|
|
85
|
-
return [$classToLoad, $classToLoad->getName()];
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return [new ReflectionClass($classToLoad), (string) $classToLoad];
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* @param mixed $payload
|
|
93
|
-
*/
|
|
94
|
-
private function getReflectionClassName($classToLoad): string
|
|
95
|
-
{
|
|
96
|
-
if ($classToLoad instanceof ReflectionClass) {
|
|
97
|
-
return $classToLoad->getName();
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return (string) $classToLoad;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
private function getParamTypeName(?ReflectionType $paramType): string
|
|
104
|
-
{
|
|
105
|
-
if ($paramType) {
|
|
106
|
-
return $paramType->getName();
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return 'mixed';
|
|
110
|
-
}
|
|
111
|
-
}
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
declare(strict_types=1);
|
|
4
|
+
|
|
5
|
+
namespace core\handler;
|
|
6
|
+
|
|
7
|
+
use ReflectionClass;
|
|
8
|
+
use ReflectionMethod;
|
|
9
|
+
use ReflectionException;
|
|
10
|
+
use ReflectionType;
|
|
11
|
+
use utils\CommandInterface;
|
|
12
|
+
|
|
13
|
+
final class InvokeGenericStaticMethodHandler extends AbstractHandler
|
|
14
|
+
{
|
|
15
|
+
private const REQUIRED_ARGUMENTS_COUNT = 2;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @return mixed
|
|
19
|
+
*/
|
|
20
|
+
public function process(CommandInterface $command)
|
|
21
|
+
{
|
|
22
|
+
$this->validate($command, self::REQUIRED_ARGUMENTS_COUNT, self::class);
|
|
23
|
+
|
|
24
|
+
$payload = $command->getPayload();
|
|
25
|
+
$className = $payload[0];
|
|
26
|
+
$methodToInvoke = (string) $payload[1];
|
|
27
|
+
$arguments = array_slice($payload, 2);
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
[$reflectionClass, $className] = $this->getReflectionClassAndName($className);
|
|
31
|
+
if (!$reflectionClass->hasMethod($methodToInvoke)) {
|
|
32
|
+
$this->throwMethodNotFoundError($reflectionClass, $methodToInvoke, $arguments);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
$method = $reflectionClass->getMethod($methodToInvoke);
|
|
36
|
+
if (!$method->isStatic()) {
|
|
37
|
+
throw new ReflectionException(sprintf(
|
|
38
|
+
'Method %s in class %s is not static',
|
|
39
|
+
$methodToInvoke,
|
|
40
|
+
$className
|
|
41
|
+
)
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return $method->invokeArgs(null, $arguments);
|
|
46
|
+
|
|
47
|
+
} catch (ReflectionException $e) {
|
|
48
|
+
if (strpos($e->getMessage(), 'Class') === 0) {
|
|
49
|
+
throw new ReflectionException(sprintf('Class: %s not found', $this->getReflectionClassName($className)));
|
|
50
|
+
}
|
|
51
|
+
throw $e;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
private function throwMethodNotFoundError(
|
|
56
|
+
ReflectionClass $reflectionClass,
|
|
57
|
+
string $methodToInvoke,
|
|
58
|
+
array $arguments
|
|
59
|
+
): void {
|
|
60
|
+
$className = $reflectionClass->getName();
|
|
61
|
+
$argumentTypes = array_map('gettype', $arguments);
|
|
62
|
+
|
|
63
|
+
$message = sprintf('Generic static method %s with arguments ['
|
|
64
|
+
. implode(', ', $argumentTypes)
|
|
65
|
+
. '] not found in class %s. Available methods:' . PHP_EOL, $methodToInvoke, $className);
|
|
66
|
+
|
|
67
|
+
$methods = $reflectionClass->getMethods(ReflectionMethod::IS_STATIC | ReflectionMethod::IS_PUBLIC);
|
|
68
|
+
|
|
69
|
+
foreach ($methods as $method) {
|
|
70
|
+
$parameterTypes = array_map(function($param) {
|
|
71
|
+
return $this->getParamTypeName($param->getType());
|
|
72
|
+
}, $method->getParameters());
|
|
73
|
+
$message .= $method->getName() . ' with arguments ['. implode(', ', $parameterTypes) . "]\n";
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
throw new ReflectionException($message);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @param mixed $payload
|
|
81
|
+
*/
|
|
82
|
+
private function getReflectionClassAndName($classToLoad): array
|
|
83
|
+
{
|
|
84
|
+
if ($classToLoad instanceof ReflectionClass) {
|
|
85
|
+
return [$classToLoad, $classToLoad->getName()];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return [new ReflectionClass($classToLoad), (string) $classToLoad];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @param mixed $payload
|
|
93
|
+
*/
|
|
94
|
+
private function getReflectionClassName($classToLoad): string
|
|
95
|
+
{
|
|
96
|
+
if ($classToLoad instanceof ReflectionClass) {
|
|
97
|
+
return $classToLoad->getName();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return (string) $classToLoad;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
private function getParamTypeName(?ReflectionType $paramType): string
|
|
104
|
+
{
|
|
105
|
+
if ($paramType) {
|
|
106
|
+
return $paramType->getName();
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return 'mixed';
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
|
|
3
|
-
declare(strict_types=1);
|
|
4
|
-
|
|
5
|
-
namespace core\handler;
|
|
6
|
-
|
|
7
|
-
use Exception;
|
|
8
|
-
use utils\CommandInterface;
|
|
9
|
-
|
|
10
|
-
final class InvokeGlobalFunctionHandler extends AbstractHandler
|
|
11
|
-
{
|
|
12
|
-
private const REQUIRED_ARGUMENTS_COUNT = 1;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @return mixed
|
|
16
|
-
*/
|
|
17
|
-
public function process(CommandInterface $command)
|
|
18
|
-
{
|
|
19
|
-
$this->validate($command, self::REQUIRED_ARGUMENTS_COUNT, self::class);
|
|
20
|
-
|
|
21
|
-
$functionName = $command->getPayload()[0];
|
|
22
|
-
$args = array_slice($command->getPayload(), 1);
|
|
23
|
-
|
|
24
|
-
if (function_exists($functionName)) {
|
|
25
|
-
return call_user_func_array($functionName, $args);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (strpos($functionName, '\\') !== false) {
|
|
29
|
-
if (function_exists($functionName)) {
|
|
30
|
-
return call_user_func_array($functionName, $args);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (strpos($functionName, '::') !== false) {
|
|
35
|
-
[$className, $methodName] = explode('::', $functionName, 2);
|
|
36
|
-
if (class_exists($className) && method_exists($className, $methodName)) {
|
|
37
|
-
return call_user_func_array([$className, $methodName], $args);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
$availableFunctions = get_defined_functions()['internal'];
|
|
42
|
-
throw new Exception(sprintf(
|
|
43
|
-
'Function %s not found. Available built-in internal functions: %s',
|
|
44
|
-
$functionName,
|
|
45
|
-
implode(', ', array_slice($availableFunctions, 0, 100)) . '...'
|
|
46
|
-
));
|
|
47
|
-
}
|
|
48
|
-
}
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
declare(strict_types=1);
|
|
4
|
+
|
|
5
|
+
namespace core\handler;
|
|
6
|
+
|
|
7
|
+
use Exception;
|
|
8
|
+
use utils\CommandInterface;
|
|
9
|
+
|
|
10
|
+
final class InvokeGlobalFunctionHandler extends AbstractHandler
|
|
11
|
+
{
|
|
12
|
+
private const REQUIRED_ARGUMENTS_COUNT = 1;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @return mixed
|
|
16
|
+
*/
|
|
17
|
+
public function process(CommandInterface $command)
|
|
18
|
+
{
|
|
19
|
+
$this->validate($command, self::REQUIRED_ARGUMENTS_COUNT, self::class);
|
|
20
|
+
|
|
21
|
+
$functionName = $command->getPayload()[0];
|
|
22
|
+
$args = array_slice($command->getPayload(), 1);
|
|
23
|
+
|
|
24
|
+
if (function_exists($functionName)) {
|
|
25
|
+
return call_user_func_array($functionName, $args);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (strpos($functionName, '\\') !== false) {
|
|
29
|
+
if (function_exists($functionName)) {
|
|
30
|
+
return call_user_func_array($functionName, $args);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (strpos($functionName, '::') !== false) {
|
|
35
|
+
[$className, $methodName] = explode('::', $functionName, 2);
|
|
36
|
+
if (class_exists($className) && method_exists($className, $methodName)) {
|
|
37
|
+
return call_user_func_array([$className, $methodName], $args);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
$availableFunctions = get_defined_functions()['internal'];
|
|
42
|
+
throw new Exception(sprintf(
|
|
43
|
+
'Function %s not found. Available built-in internal functions: %s',
|
|
44
|
+
$functionName,
|
|
45
|
+
implode(', ', array_slice($availableFunctions, 0, 100)) . '...'
|
|
46
|
+
));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
|
|
3
|
-
declare(strict_types=1);
|
|
4
|
-
|
|
5
|
-
namespace core\handler;
|
|
6
|
-
|
|
7
|
-
use BadMethodCallException;
|
|
8
|
-
use ReflectionClass;
|
|
9
|
-
use ReflectionMethod;
|
|
10
|
-
use ReflectionException;
|
|
11
|
-
use RuntimeException;
|
|
12
|
-
use utils\ArrayWrapper;
|
|
13
|
-
use utils\CommandInterface;
|
|
14
|
-
|
|
15
|
-
final class InvokeInstanceMethodHandler extends AbstractHandler
|
|
16
|
-
{
|
|
17
|
-
private const REQUIRED_ARGUMENTS_COUNT = 2;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @return mixed
|
|
21
|
-
*/
|
|
22
|
-
public function process(CommandInterface $command)
|
|
23
|
-
{
|
|
24
|
-
$this->validate($command, self::REQUIRED_ARGUMENTS_COUNT, self::class);
|
|
25
|
-
|
|
26
|
-
$payload = $command->getPayload();
|
|
27
|
-
$objectInstance = $payload[0];
|
|
28
|
-
$methodToInvoke = (string) $payload[1];
|
|
29
|
-
$arguments = array_slice($payload, 2);
|
|
30
|
-
|
|
31
|
-
foreach ($arguments as $i => $arg) {
|
|
32
|
-
if ($arg instanceof ArrayWrapper) {
|
|
33
|
-
$arguments[$i] = $arg->getData();
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
try {
|
|
38
|
-
$reflectionClass = new ReflectionClass($objectInstance);
|
|
39
|
-
|
|
40
|
-
if (!$reflectionClass->hasMethod($methodToInvoke)) {
|
|
41
|
-
$this->throwMethodNotFoundException($objectInstance, $methodToInvoke, $arguments, $reflectionClass);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
$method = $reflectionClass->getMethod($methodToInvoke);
|
|
45
|
-
if ($method->isStatic()) {
|
|
46
|
-
throw new BadMethodCallException(sprintf('Method %s is static and cannot be called on instance', $methodToInvoke));
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return $method->invokeArgs($objectInstance, $arguments);
|
|
50
|
-
} catch (ReflectionException $e) {
|
|
51
|
-
throw new RuntimeException(sprintf('Cannot access the object: %s, error: %s', get_class($objectInstance), $e->getMessage()));
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
private function throwMethodNotFoundException($objectInstance, string $methodName, array $arguments, ReflectionClass $reflectionClass): void
|
|
56
|
-
{
|
|
57
|
-
$methods = $reflectionClass->getMethods(ReflectionMethod::IS_PUBLIC & ~ReflectionMethod::IS_STATIC);
|
|
58
|
-
$message = sprintf('Instance method %s with arguments %s was not found in class %s.
|
|
59
|
-
Available instance methods:' . PHP_EOL, $methodName, json_encode($arguments), get_class($objectInstance)
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
foreach ($methods as $method) {
|
|
63
|
-
$params = [];
|
|
64
|
-
foreach ($method->getParameters() as $param) {
|
|
65
|
-
$paramStr = $param->getType() ? $param->getType()->getName() : 'mixed';
|
|
66
|
-
$paramStr .= ' $' . $param->getName();
|
|
67
|
-
if ($param->isOptional()) {
|
|
68
|
-
$paramStr .= ' = ' . ($param->isDefaultValueAvailable() ?
|
|
69
|
-
var_export($param->getDefaultValue(), true) : 'null');
|
|
70
|
-
}
|
|
71
|
-
$params[] = $paramStr;
|
|
72
|
-
}
|
|
73
|
-
$message .= $method->getName() . '(' . implode(', ', $params) . ")\n";
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
throw new BadMethodCallException($message);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
declare(strict_types=1);
|
|
4
|
+
|
|
5
|
+
namespace core\handler;
|
|
6
|
+
|
|
7
|
+
use BadMethodCallException;
|
|
8
|
+
use ReflectionClass;
|
|
9
|
+
use ReflectionMethod;
|
|
10
|
+
use ReflectionException;
|
|
11
|
+
use RuntimeException;
|
|
12
|
+
use utils\ArrayWrapper;
|
|
13
|
+
use utils\CommandInterface;
|
|
14
|
+
|
|
15
|
+
final class InvokeInstanceMethodHandler extends AbstractHandler
|
|
16
|
+
{
|
|
17
|
+
private const REQUIRED_ARGUMENTS_COUNT = 2;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @return mixed
|
|
21
|
+
*/
|
|
22
|
+
public function process(CommandInterface $command)
|
|
23
|
+
{
|
|
24
|
+
$this->validate($command, self::REQUIRED_ARGUMENTS_COUNT, self::class);
|
|
25
|
+
|
|
26
|
+
$payload = $command->getPayload();
|
|
27
|
+
$objectInstance = $payload[0];
|
|
28
|
+
$methodToInvoke = (string) $payload[1];
|
|
29
|
+
$arguments = array_slice($payload, 2);
|
|
30
|
+
|
|
31
|
+
foreach ($arguments as $i => $arg) {
|
|
32
|
+
if ($arg instanceof ArrayWrapper) {
|
|
33
|
+
$arguments[$i] = $arg->getData();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
$reflectionClass = new ReflectionClass($objectInstance);
|
|
39
|
+
|
|
40
|
+
if (!$reflectionClass->hasMethod($methodToInvoke)) {
|
|
41
|
+
$this->throwMethodNotFoundException($objectInstance, $methodToInvoke, $arguments, $reflectionClass);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
$method = $reflectionClass->getMethod($methodToInvoke);
|
|
45
|
+
if ($method->isStatic()) {
|
|
46
|
+
throw new BadMethodCallException(sprintf('Method %s is static and cannot be called on instance', $methodToInvoke));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return $method->invokeArgs($objectInstance, $arguments);
|
|
50
|
+
} catch (ReflectionException $e) {
|
|
51
|
+
throw new RuntimeException(sprintf('Cannot access the object: %s, error: %s', get_class($objectInstance), $e->getMessage()));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
private function throwMethodNotFoundException($objectInstance, string $methodName, array $arguments, ReflectionClass $reflectionClass): void
|
|
56
|
+
{
|
|
57
|
+
$methods = $reflectionClass->getMethods(ReflectionMethod::IS_PUBLIC & ~ReflectionMethod::IS_STATIC);
|
|
58
|
+
$message = sprintf('Instance method %s with arguments %s was not found in class %s.
|
|
59
|
+
Available instance methods:' . PHP_EOL, $methodName, json_encode($arguments), get_class($objectInstance)
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
foreach ($methods as $method) {
|
|
63
|
+
$params = [];
|
|
64
|
+
foreach ($method->getParameters() as $param) {
|
|
65
|
+
$paramStr = $param->getType() ? $param->getType()->getName() : 'mixed';
|
|
66
|
+
$paramStr .= ' $' . $param->getName();
|
|
67
|
+
if ($param->isOptional()) {
|
|
68
|
+
$paramStr .= ' = ' . ($param->isDefaultValueAvailable() ?
|
|
69
|
+
var_export($param->getDefaultValue(), true) : 'null');
|
|
70
|
+
}
|
|
71
|
+
$params[] = $paramStr;
|
|
72
|
+
}
|
|
73
|
+
$message .= $method->getName() . '(' . implode(', ', $params) . ")\n";
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
throw new BadMethodCallException($message);
|
|
77
|
+
}
|
|
78
|
+
}
|