<commit_before><?php
namespace Mokka;

class ClassBuilder 
{
    /**
     * @var FunctionBuilder
     */
    private $_functionBuilder;

    /**
     * @param FunctionBuilder $functionBuilder
     */
    public function __construct(FunctionBuilder $functionBuilder)
    {
        $this->_functionBuilder = $functionBuilder;
    }

    /**
     * @param string $mockClassname
     * @param string $classname
     * @return mixed|string
     */
    public function build($mockClassname, $classname)
    {
        $reflection = new \ReflectionClass($classname);
        if ($reflection->isInterface()) {
            $classDefinition = file_get_contents(__DIR__ . '/template/Interface.php.template');
        } else {
            $classDefinition = file_get_contents(__DIR__ . '/template/Class.php.template');
        }
        $classDefinition = str_replace('%className%', $mockClassname, $classDefinition);
        $classDefinition = str_replace('%mockedClass%', $classname, $classDefinition);

        $functions = array();
        foreach ($reflection->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
            // TODO eval can't handle methods with the names echo and eval
            if ($method->getName() == 'echo' || $method->getName() == 'eval') {
                continue;
            }
            $functions[] = $this->_functionBuilder->build($method);
        }
        $classDefinition = str_replace('%functions%', implode("\n", $functions), $classDefinition);
        return $classDefinition;
    }

} 
<commit_msg>Do not try to mock final or static methods<commit_after><?php
namespace Mokka;

class ClassBuilder 
{
    /**
     * @var FunctionBuilder
     */
    private $_functionBuilder;

    /**
     * @param FunctionBuilder $functionBuilder
     */
    public function __construct(FunctionBuilder $functionBuilder)
    {
        $this->_functionBuilder = $functionBuilder;
    }

    /**
     * @param string $mockClassname
     * @param string $classname
     * @return mixed|string
     */
    public function build($mockClassname, $classname)
    {
        $reflection = new \ReflectionClass($classname);
        if ($reflection->isInterface()) {
            $classDefinition = file_get_contents(__DIR__ . '/template/Interface.php.template');
        } else {
            $classDefinition = file_get_contents(__DIR__ . '/template/Class.php.template');
        }
        $classDefinition = str_replace('%className%', $mockClassname, $classDefinition);
        $classDefinition = str_replace('%mockedClass%', $classname, $classDefinition);

        $functions = array();
        foreach ($reflection->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
            // TODO eval can't handle methods with the names echo and eval
            if ($method->getName() == 'echo' || $method->getName() == 'eval') {
                continue;
            }
            if ($method->isFinal() || $method->isStatic()) {
                continue;
            }
            $functions[] = $this->_functionBuilder->build($method);
        }
        $classDefinition = str_replace('%functions%', implode("\n", $functions), $classDefinition);
        return $classDefinition;
    }

} 

{'fraction_non_alphanumeric': 0.13335415365396627, 'fraction_numerical': 0.0, 'mean_word_length': 2.5588888888888888, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7472254', 'n_tokens_mistral': 852, 'n_tokens_neox': 839, 'n_words': 176}