Skip to content

Instantly share code, notes, and snippets.

@orukusaki
Created August 3, 2016 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save orukusaki/b3d4dd5566f697dcea3c9c5b845d7bbd to your computer and use it in GitHub Desktop.
Save orukusaki/b3d4dd5566f697dcea3c9c5b845d7bbd to your computer and use it in GitHub Desktop.
<?php
function loader($class) {
if (strpos($class, 'List') !== false) {
eval("class $class extends TypedList {}");
}
}
spl_autoload_register('loader');
abstract class TypedList extends ArrayObject
{
public function __construct()
{
$type = str_replace('List', '', get_class($this));
echo 'I am only going to accept ' . $type;
}
}
$a = new BlahList;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment