The PHP Function Finfo_Open
PHP has a built-in function finfo_open that creates a new info instance and returns it on success, or false if the call fails. The finfo_open function is useful for obtaining information about files from a file system.
Several internal functions in PHP don’t check the type of parameters. For example, the compact function doesn’t perform strict-type checking. Adding the declare(strict_types=1) declaration to a function will trigger it to perform strict-type checking. The function will also show a warning if it receives non-string and non-array parameters or if it receives a null value for a parameter that doesn’t accept null values.
Another change is that the fsync() and fdatasync() functions can flush operating system write buffers to physical storage. This is an important feature to ensure data consistency when you are working with large datasets.
The finfo extension has gone through the Resource to Object Migration. The procedural API in the finfo extension now returns and accepts class objects instead of resources of type file_info. This will make it easier to interchange these functions in the future when PHP 8.1 replaces tentative return types with standard return types.
The knp-snappy-bundle is a Symfony bundle that makes it easy to run the PHP finfo_open() function in your application. It is available on GitHub and has a one-click installation. It supports a wide range of platforms including Windows, Linux, and macOS. It also includes a command-line interface that provides an interactive shell.