Take the following example:
class A implements Serializable {
serialize() {}
}
class B extends A {
serialize() {}
}
Class A is a persistant but minimal class used on every page. class B is temporary admin only (used on a settings screen) class which populates members by reading files.
I need to serialize the object and store in the database twice, once for regular pages, and the second (with a limited life) for the admin page.
$instance = new B(); // and populate
$data = serialize( $instance );
This will always call the over-ridden method. Is there any way I could cast $instance
to type A
so that I can call on class A
's serialize method?