Hi, I agree they are bad APIs. Framework/library developer should provide better API
On Mon, May 9, 2016 at 1:08 AM, Fleshgrinder <p...@fleshgrinder.com> wrote: > $request = getGlobals() > |> parseRequest($$) > |> buildPsr7Request($$); should be require('some.lib'); $request = getRequest(); /* where getRequest() is function getRequest() { return getGlobals() |> parseRequest($$) |> buildPsr7Request($$); } */ > > $response = loadConfig() > |> buildDic($$) > |> getApp($$) > |> getRouter($$) > |> getDispatcher($$, $request) > |> dispatchBusinessLogic($$, $request, new Response()) > |> renderResponse($$) > |> buildPsr7Response($$) > |> emit($$); should be require('some.lib'); $request = getRequest(); $response = getResponse($request); /* where getResponse() is function getRequest($request) { return loadConfig() |> buildDic($$) |> getApp($$) |> getRouter($$) |> getDispatcher($$, $request) |> dispatchBusinessLogic($$, $request, new Response()) |> renderResponse($$) |> buildPsr7Response($$) |> emit($$); } */ > Suddenly I magically need to know how all of that procedural stuff goes > together just to be able to keep it short while calling all of it?!? > > I hope you understand now why I am still asking for real world examples > that are not based on endlessly bad code. "|>" is just a building block for simpler coding. It could be used badly, but it helps a lot. Procedural code could be much simpler and readable with "|>". function getRequest() { $config = loadConfig(); $dic = buildDic($config); $app = getApp($dic); $route = getRouter($app); $dispatcher = getDispatcher($route, $request); $businessLogic = dispatchBusinessLogic($dispatcher, $request, new Response()); $resp = renderResponse($businessLogic); $response = buildPsr7Response($resp); return emit($response); } "|>" version is much easier to read and write. I suppose most users will use it for easier coding, not for opposite. Regards, -- Yasuo Ohgaki yohg...@ohgaki.net -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php