Skip to content

Instantly share code, notes, and snippets.

@beerendlauwers
Last active August 29, 2015 14:13
Show Gist options
  • Select an option

  • Save beerendlauwers/c28585ce4868ab42d2f9 to your computer and use it in GitHub Desktop.

Select an option

Save beerendlauwers/c28585ce4868ab42d2f9 to your computer and use it in GitHub Desktop.

Revisions

  1. beerendlauwers revised this gist Jan 9, 2015. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion PHP 5.5 crash
    Original file line number Diff line number Diff line change
    @@ -27,4 +27,6 @@ class Test {
    $t = new Test();
    $t->addFunction( function($x){ return $x; } );
    $t->addFunction( function($x){ return $x; } );
    $t->apply("test");
    $t->apply(TRUE);

    ?>
  2. beerendlauwers created this gist Jan 9, 2015.
    30 changes: 30 additions & 0 deletions PHP 5.5 crash
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    <?php

    class Test {

    private $f = NULL;

    public function addFunction( callable $f ) {
    if ($this->f === NULL) {
    $this->f = $f;
    }
    else {
    $this->f = function() use ($f){
    $args = func_get_args();
    return call_user_func_array( $this->f, $args ) &&
    call_user_func_array( $f, $args );
    };
    }
    }

    public function apply() {
    $args = func_get_args();
    call_user_func_array( $this->f, $args );
    }

    }

    $t = new Test();
    $t->addFunction( function($x){ return $x; } );
    $t->addFunction( function($x){ return $x; } );
    $t->apply("test");