Should static properties be included in the serialization process in PHP, or is it considered a design flaw?

Static properties should generally not be included in the serialization process in PHP as they are not part of the instance state and can lead to unexpected behavior when unserialized. To exclude static properties from serialization, you can implement the __sleep magic method in your class and return an array of instance properties that should be serialized.

class MyClass {
    public $instanceProperty;
    public static $staticProperty;

    public function __sleep() {
        return ['instanceProperty'];
    }
}