Mixed And Untyped Are Not Compatible Types

<?php

class x {
    protected $p;
    protected mixed $p2;
}

class x2 extends x {
    protected mixed $p;
    // type of x2:$p must not be defined (as in class x)

    protected $p2;
    // Type of $x2:$p2 must be mixed
}

A property typed mixed cannot be redefined later as untyped.

A property untyped cannot be redefined later as mixed.

Although, both syntax represent the same reality: any type goes.

Same for return type, in method compatibility situations. Although, it happens only when the parent is mixed, and the child untyped.

With return type, PHP does check if anything is returned with a type of mixed, and not if it is untyped.

See Also

PHP Features

Last updated: 14 July 2026