-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Labels
enhancementNew feature or requestNew feature or request
Description
After some discussion in discord, I think the best approach would be to generate PHP interfaces that have the appropriate docblocks for each service method.
Example:
<?php
namespace Rpc/Types;
interface MathService
{
/**
* My awesome method description
*
* @param int|float $a is a really cool number
* @param int|float $a another cool number
* @return int|float the result of $a + $b
*/
public function addition($a, $b);
}Namespace & output path should be configurable ideally (didn't dig much into this repo yet to see the CLI params).
Some users may want their interfaces strongly typed with param/return types, but the easiest thing for the time being is to skip that part and just do docblocks at first. Could have some config to allow for enabling strong types, for example, using PHP 8.0 union types:
<?php
namespace Rpc/Types;
interface MathService
{
/**
* My awesome method description
*
* @param int|float $a is a really cool number
* @param int|float $a another cool number
* @return int|float the result of $a + $b
*/
public function addition(int|float $a, int|float $b) : int|float;
}P.S. My preferred JSON-RPC server lib in PHP is https://github.com/datto/php-json-rpc, also includes a client which is useful for testing etc.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request