How do I keep compatibility of all the old behavior functions when upgrading/editing it?

I am trying to update Firebase and P2P (Issue #7258) but I have to leave compatibility for older events.
My changes (These are the wrong implementation):
Firebase
P2P

I was thinking if it is possible(or even allowed) to duplicate these functions and append ‘2’ at the end, hide the outdated ones and make the new ones use the latest variable system. Maybe there is even another alternative.