I'm working on a library to connect to the Eventbrite API. I've made it generic enough that a lot of the second level business objects are empty classes. Having said that, when I instantiate those objects, I would still like them to register as different classes. I thought class_alias
would be the way to go, but it seems that the original class is what is returned when doing a var_dump
.
Current:
<?php
namespace Project;
class_alias(
'\\Project\\Classes\\Aliaser',
'\\Project\\Classes\\Attendee',
true
);
use Project\Classes\Aliaser;
use Project\Classes\Attendee;
$attendee = new Attendee();
var_dump($attendee)
// Aliaser {}
What I'm shooting for:
$attendee = new Attendee();
var_dump($attendee);
// Attendee {}
I would really like to delete the empty classes in favor of the generic one while also having the new dynamically generated class be registered.
Is that possible without a serious performance hit?
Note: Prefer PHP 5.4 or greater, but PHP 7 is also good.