Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Callable gets executed too often #51

Open
janwalther opened this issue Sep 8, 2015 · 1 comment
Open

Callable gets executed too often #51

janwalther opened this issue Sep 8, 2015 · 1 comment
Assignees
Labels
Milestone

Comments

@janwalther
Copy link

I have the following code:

// index.php
use limetec\Test;

require __DIR__.'/../vendor/autoload.php';

\StrictPhp\StrictPhpKernel::bootstrap([
                                          'debug' => true,
                                          // change this if you use this tool on multiple projects:
                                          'cacheDir' => sys_get_temp_dir(),
                                          'includePaths' => [
                                              __DIR__,
                                          ],
                                      ]);


echo "Start";
$obj = new Test();

$obj->test(function () {
    echo "Hello";
});

// in separate file named Test.php
<?php
namespace limetec;

class Test {
    public function test (callable $callable) {
        $callable();
    }
}

When I execute index.php I get the following output:

StartHelloHelloHelloHello

That means the callable gets executed 4 times. Without StrictPHP I only get "StartHello" (the callable gets only executed once - as expected).

@Ocramius
Copy link
Member

Ocramius commented Sep 8, 2015

Nice catch!

@Ocramius Ocramius self-assigned this Sep 8, 2015
@Ocramius Ocramius added the bug label Sep 8, 2015
@Ocramius Ocramius added this to the 0.1.0 milestone Sep 8, 2015
malukenho pushed a commit that referenced this issue Nov 27, 2015
malukenho pushed a commit to malukenho/StrictPhp that referenced this issue Dec 22, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants