Skip to content

Commit b2bfbd8

Browse files
author
Eugene Fureev
committed
fix
1 parent a847cd1 commit b2bfbd8

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/Global/base.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,29 @@ function remoteStaticCallOrTrow(object|string|null $class, string $method, mixed
307307
}
308308
}
309309

310+
if (!function_exists('remoteCall')) {
311+
/**
312+
* Returns result of an object's method if it exists in the object.
313+
*
314+
* @param object|null $class
315+
* @param string $method
316+
* @param mixed ...$params
317+
*
318+
* @return mixed
319+
*/
320+
function remoteCall(?object $class, string $method, mixed ...$params): mixed
321+
{
322+
if (!$class) {
323+
return null;
324+
}
325+
if (method_exists($class, $method)) {
326+
return $class->$method(...$params);
327+
}
328+
329+
return null;
330+
}
331+
}
332+
310333
if (!function_exists('attributeToGetterMethod')) {
311334
/**
312335
* Returns getter-method's name or null by an attribute

0 commit comments

Comments
 (0)