Created
August 3, 2016 09:01
-
-
Save orukusaki/b3d4dd5566f697dcea3c9c5b845d7bbd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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