Mixed

A special type that represents any available type. It is equivalent to not explicitly setting the type, though it is now explicitly done.

A mixed type may be also represented by a union of all possible types.

mixed is useful when literally any type should be supported, such as with a cache system. Yet, it is usually recommended to consider reducing the number of possible types by using a common interface or a union type.

<?php

    function cache(string $name, mixed $value) : bool {
        static $cache = [];

        $cache[$name] = $value;

        return true;
    }

?>

Documentation

See also Mixed Type PHP 8 and A mixed type PHPStan journey.

Related : Type System, Pseudo-type, Special Types, Type Inference, Wildcard

Added in PHP 8.0+