CascadiaPHP 2024

The __PHP_Incomplete_Class class

(No version information available, might only be in Git)


Created by unserialize() when trying to unserialize an undefined class or a class that is not listed in the allowed_classes of unserialize()'s options array.

Prior to PHP 7.2.0, using is_object() on the __PHP_Incomplete_Class class would return false. As of PHP 7.2.0, true will be returned.

Class synopsis

class __PHP_Incomplete_Class {

This class has no default properties or methods. When created by unserialize(), in addition to all unserialized properties and values the object will have a __PHP_Incomplete_Class_Name property which will contain the name of the unserialized class.


Example #1 Created by unserialize()


class MyClass
string $property = "myValue";

$myObject = new MyClass;

$foo = serialize($myObject);

// unserializes all objects into __PHP_Incomplete_Class objects
$disallowed = unserialize($foo, ["allowed_classes" => false]);


// unserializes all objects into __PHP_Incomplete_Class objects except those of MyClass2 and MyClass3
$disallowed2 = unserialize($foo, ["allowed_classes" => ["MyClass2", "MyClass3"]]);


// unserializes undefined class into __PHP_Incomplete_Class object
$undefinedClass = unserialize('O:16:"MyUndefinedClass":0:{}');


The above example will output:

object(__PHP_Incomplete_Class)#2 (2) {
  string(7) "MyClass"
  string(7) "myValue"
object(__PHP_Incomplete_Class)#3 (2) {
  string(7) "MyClass"
  string(7) "myValue"
object(__PHP_Incomplete_Class)#4 (1) {
  string(16) "MyUndefinedClass"

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top