-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix issue #49. Add tests. #58
base: develop
Are you sure you want to change the base?
Conversation
@@ -71,22 +71,25 @@ class Server | |||
|
|||
/** | |||
* Construct a Server object | |||
* @param object $host An object whose methods will be provided for invokation | |||
* @param MethodWrapper|array $host An object whose methods will be provided for invocation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Originally the idea was that the server should be able to provide the methods of any object (e,g, it would be able to infer the parameter order via reflection etc.), MethodWrapper is just a utility to get things going quickly. Perhaps we should remove it entirely, instead of making it the only choice, because in the end, I think Classes are a better way to write an RPC API than arrays.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is, to make the host an array? Format:
class Foo()
{
public function bar() {}
}
$foo = new Foo();
$methods = array(
'method1' => function() {}, // anonymous function
'method2' => array($foo, 'bar'), // Method of class
)
new Server($methods);
Declaration:
public function __construct(array $host)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or I misunderstood? 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I think it would be better to stop supporting passing hosted methods as an array:
class Foo()
{
public function bar() {}
}
$foo = new Foo();
-$methods = array(
- 'method1' => function() {}, // anonymous function
- 'method2' => array($foo, 'bar'), // Method of class
-)
-new Server($methods);
+new Server($foo)
@marcelklehr Your variant for solving the problem #49 the wrong. Example: