Hacker News new | ask | show | jobs
by francislavoie 2064 days ago
> I'd be willing to bet good money that you don't write PHP without typehints and/or Psalm/PHPstan.

Yeah, think of it like Typescript. Same idea.

> Also, I believe Swoole is process based, not thread or (true) async.

It's a coroutine model, like Go. Very fast. But I don't use it because it's primarily a chinese community, lots of the docs are in broken english. But it's an impressive thing anyways.

IMO, you don't need threading in PHP, there's not really that many situations where it would help during a request-response flow. People generally delegate slow tasks to job queues, which often use https://www.php.net/manual/en/function.pcntl-fork.php to fork off workers. Works great.

> That's not what I meant. My wording was poor. I meant specifically `callable`. You can't typehint the inputs and outputs of `callable` parameters. So passing around lambdas, etc, is not robust/safe.

You can though. `fn(SomeClass $foo) => $foo->doThing()`

> and knowing that the inputs/outputs line up with whatever you're doing

Fair enough, but you can use reflection to look at the callable if you care enough. It rarely matters.