Hywan / atoum-instrumentation

The atoum\instrumentation library. Instrumentation for PHP (moles, code coverage…)
7 stars 2 forks source link

Instrumentation of namespaced classes #6

Closed jubianchi closed 10 years ago

jubianchi commented 10 years ago

Using Hywan/atoum-instrumentation@25829d0

Given the following source code:

<?php

namespace hey;

class foo
{
    public function bar($a, $b)
    {
        $a += 12;
        $b = $b ?: rand(0, 10);

        return $a + $b;
    }

    public function baz($a, $b)
    {
        return $a . $b;
    }

    public function boo($a, $b)
    {
        return function () {
            return md5(uniqid()));
        };
    }
}

I get the following instrumented output:

<?php

namespace hey;

class foo
{
    public function bar($a, $b)
    { if(\atoum\instrumentation\mole::exists('foo::bar')) return \atoum\instrumentation\mole::call('foo::bar', $this, func_get_args());
        $a += 12;mark_line(__LINE__);
        $b = $b ?: rand(0, 10);mark_line(__LINE__);

        mark_line(__LINE__);return $a + $b;
    }

    public function baz($a, $b)
    { if(\atoum\instrumentation\mole::exists('foo::baz')) return \atoum\instrumentation\mole::call('foo::baz', $this, func_get_args());
        mark_line(__LINE__);return $a . $b;
    }

    public function boo($a, $b)
    { if(\atoum\instrumentation\mole::exists('foo::boo')) return \atoum\instrumentation\mole::call('foo::boo', $this, func_get_args());
        mark_line(__LINE__);return function () {
            return md5(uniqid()));
        };
    }
}

The namespace is missing in \atoum\instrumentation\mole::exists and \atoum\instrumentation\mole::call calls

Hywan commented 10 years ago

Hello,

Fixed by 83868cf5cf524c2c4c7205002abe85b35653280c. Thanks!