<commit_before><?php
/**
 * This file is part of the Everon framework.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Everon\Helper;

trait RunPhp
{
    /**
     * @param $php
     * @param array $scope
     * @param \Everon\Interfaces\FileSystem $FileSystem
     * @return string
     */
    protected function runPhp($php, array $scope, \Everon\Interfaces\FileSystem $FileSystem)
    {
        $handleError = function($errno, $errstr, $errfile, $errline, array $errcontext) {
            // error was suppressed with the @-operator
            if (0 === error_reporting()) {
                return false;
            }

            throw new \Everon\Exception\TemplateEvaluationError($errstr, 0, $errno, $errfile, $errline);
        };

        $old_error_handler = set_error_handler($handleError);

        $TmpPhpFile = $FileSystem->createTmpFile();
        $content = '';
        try {
            $TmpPhpFile->write($php);
            $php_file = $TmpPhpFile->getFilename(); 

            ob_start();
            extract($scope);
            
            $View = $Tpl->View;

            unset($Tpl->View);
            
            include $php_file;
            $content = ob_get_contents();
            
        }
        catch (\Exception $e) {
            $this->getLogger()->e_error($e."\n".$php);
            $content = $e->getMessage().' on line '.$e->getLine();
        }
        finally {
            ob_end_clean();
            $TmpPhpFile->close();
            restore_error_handler($old_error_handler);<commit_msg>view cleanups<commit_after><?php
/**
 * This file is part of the Everon framework.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Everon\Helper;

trait RunPhp
{
    /**
     * @param $php
     * @param array $scope
     * @param \Everon\Interfaces\FileSystem $FileSystem
     * @return string
     */
    protected function runPhp($php, array $scope, \Everon\Interfaces\FileSystem $FileSystem)
    {
        $handleError = function($errno, $errstr, $errfile, $errline, array $errcontext) {
            // error was suppressed with the @-operator
            if (0 === error_reporting()) {
                return false;
            }

            throw new \Everon\Exception\TemplateEvaluationError($errstr, 0, $errno, $errfile, $errline);
        };

        $old_error_handler = set_error_handler($handleError);

        $TmpPhpFile = $FileSystem->createTmpFile();
        $content = '';
        try {
            $TmpPhpFile->write($php);
            $php_file = $TmpPhpFile->getFilename();
            
            // $Context = new TemplateContext($View, $Template, $scope);

            ob_start();
            extract($scope);
            
            //meh
            $View = $Tpl->View;
            unset($Tpl->View);
            
            include $php_file;
            $content = ob_get_contents();
            
        }
        catch (\Exception $e) {
            $this->getLogger()->e_error($e."\n".$php);
            $content = $e->getMessage().' on line '.$e->getLine();
        }
        finally {
            ob_end_clean();
            $TmpPhpFile->close();
            restore_error_handler($old_error_handler);
{'fraction_non_alphanumeric': 0.1329818394844757, 'fraction_numerical': 0.0011716461628588166, 'mean_word_length': 1.8818565400843883, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 29, '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': '3282072', 'n_tokens_mistral': 996, 'n_tokens_neox': 979, 'n_words': 222}