PHP Serializable interface

Code
<?php

class Foo implements Serializable
{
    private 
$foo;
    
    private 
$bar;
    
    private 
$isCreatedBySerialization false;
    
    public function 
__construct(int $fooint $bar)
    {
        
$this->foo $foo;
        
$this->bar $bar;
    }
    
    public function 
serialize()
    {
        return 
serialize([
            
'foo' => $this->foo,
            
'bar' => $this->bar,
        ]);
    }
    
    public function 
unserialize($serialized)
    {
        
$unserialized unserialize($serialized);
        
$this->foo $unserialized['foo'];
        
$this->bar $unserialized['bar'];
        
$this->isCreatedBySerialization true;
    }
}

$foo = new Foo(36);
dump($foo);

dump($serializedFoo serialize($foo));
dump(unserialize($serializedFoo));
Result
^ Foo {#1390
-foo: 3
-bar: 6
-isCreatedBySerialization: false
}

^ "C:3:"Foo":34:{a:2:{s:3:"foo";i:3;s:3:"bar";i:6;}}"

^ Foo {#1400
-foo: 3
-bar: 6
-isCreatedBySerialization: true
}
Used Versions
PHP 8.0, Laminas MVC 3.2, Symfony 5.2, Laravel 8.28, PHPUnit 9.5, Doctrine ORM 2.8