string = $string; } public function __toString () { return $this -> string; } } class ProofOfConcept { public function __construct () { $reflection = new ReflectionClass ( 'ProofOfConcept' ); foreach ( $reflection -> getMethods () AS $method ) { $constructParametersCount = func_num_args (); if ( $constructParametersCount === count ( $method -> getNumberOfParameters () ) && substr ( $method -> getName (), 0, 11 ) === 'constructor' ) { $i = 0; $candidate = true; foreach ( $method -> getParameters () AS $parameter ) { $name = $parameter -> getName (); $datatypeClass = ( is_null ( $parameter -> getClass () ) === false ) ? $parameter -> getClass () : false; $datatype = ( $datatypeClass !== false ) ? $datatypeClass -> getName () : false; if ( $datatype !== false ) { if ( ( func_get_arg ( $i ) instanceof $datatype ) == false ) { $candidate = false; } } } if ( $candidate === true ) { // de eerste kandidaat. Doen we het voor ;) $methodName = $method -> getName (); $arguments = func_get_args (); $args = implode ( ', ', $arguments ); $this -> $methodName ( $args ); } } } } public function constructor1 ( String $test ) { echo 'haha'; } } $proofOfConcept = new ProofOfConcept ( new String ( 'test' ) ); ?>