PHP openssl free key deprecated

In php the function

openssl_free_key

is deprecated and not includde in php 8. Can somebody give an alternative for it?

Answer

Solution:

This function is now deprecated as it doesn't have an effect anymore.

https://www.php.net/manual/en/function.openssl-free-key.php

PHP 8 deprecates openssl_free_key (actually openssl_pkey_free which it aliases) and automatically destroys the key instance when it goes out of scope.

https://www.php.net/manual/en/function.openssl-pkey-free.php#125655

So really you replace it with nothing, as the resource is now cleaned up properly the same as anything else.

If you want to feel like you're going that extra mile you can call unset() on it, but that's not a thing I would consider necessary.

Source