On Tue, Sep 30, 2025 at 4:56 PM Kamil Tekiela <[email protected]> wrote:

> I find this proposal to be a backwards step in the age when we are
> moving away from resources and their explicit closure. We have
> disabled this in PHP 8.0 for curl_close(), imagedestroy(),
> openssl_pkey_free(), shmop_close() and xml_parser_free(). Sure,
> mysqli_close() still works, but the whole extension is mostly a
> historical artefact and a bunch of bad design choices due to what that
> extension is (quick replacement of mysql_* API). PDO was designed much
> better and it deliberately avoided the foot gun that is explicit
> connection closure. I really wish we would not introduce bad design
> choices into the language, and because of this, I wish this proposal
> were unsuccessful.
>

All of the foot gun examples you listed are such because that historic
design pattern *required* explicit resource frees, and they are foot guns
because it is easy to forget doing that.
Also, mysqli_close() is the only one that handles a stateful network
connection and not a local resource, which is a good reason why it still
works.

There are legitimate use cases where you may want to explicitly and
immediately close a network connection, even if PHP would do it eventually.

Cheers,
Andrey.

Reply via email to