All pastes #459289 Raw Edit

berry__

public php v1 · immutable
#459289 ·published 2007-04-26 11:33 UTC
rendered paste body
<?phpclass String{  public function __construct ( $string )  {    $this -> 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' ) );?>