Skip to content

Error while rewriting a function with args passed by reference #33

Description

@tampe125

Let's say you have the following function:

public function test_reference($a, &$b, &$c)
{
    $foo = 'bar';
}

AspectMock will inject the following string:

 if (($__am_res = __amock_before(\$this, __CLASS__, __FUNCTION__, array($a, $b, $c), false)) !== __AM_CONTINUE__) return $__am_res; 

As you can see in the mocked function arguments are not passed by reference; this leads to PHP errors while trying to mock this function with a Closure, since your anon function will have arguments passed by reference, but in the mock they aren't defined as such.

However I found a fix for this, a Pull Request will be issued shortly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions