Completed
Branch master (6a6544)
by Pierre-Henry
33:43
created

Smarty/sysplugins/smarty_internal_compile_call.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * Smarty Internal Plugin Compile Function_Call
4
 * Compiles the calls of user defined tags defined by {function}
5
 *
6
 * @package    Smarty
7
 * @subpackage Compiler
8
 * @author     Uwe Tews
9
 */
10
11
/**
12
 * Smarty Internal Plugin Compile Function_Call Class
13
 *
14
 * @package    Smarty
15
 * @subpackage Compiler
16
 */
17
class Smarty_Internal_Compile_Call extends Smarty_Internal_CompileBase
18
{
19
    /**
20
     * Attribute definition: Overwrites base class.
21
     *
22
     * @var array
23
     * @see Smarty_Internal_CompileBase
24
     */
25
    public $required_attributes = array('name');
26
27
    /**
28
     * Attribute definition: Overwrites base class.
29
     *
30
     * @var array
31
     * @see Smarty_Internal_CompileBase
32
     */
33
    public $shorttag_order = array('name');
34
35
    /**
36
     * Attribute definition: Overwrites base class.
37
     *
38
     * @var array
39
     * @see Smarty_Internal_CompileBase
40
     */
41
    public $optional_attributes = array('_any');
42
43
    /**
44
     * Compiles the calls of user defined tags defined by {function}
45
     *
46
     * @param  array  $args     array with attributes from parser
47
     * @param  object $compiler compiler object
48
     *
49
     * @return string compiled code
50
     */
51
    public function compile($args, $compiler)
52
    {
53
        // check and get attributes
54
        $_attr = $this->getAttributes($compiler, $args);
55
        // save possible attributes
56
        if (isset($_attr['assign'])) {
57
            // output will be stored in a smarty variable instead of being displayed
58
            $_assign = $_attr['assign'];
59
        }
60
        //$_name = trim($_attr['name'], "'\"");
61
        $_name = $_attr['name'];
62
        unset($_attr['name'], $_attr['assign'], $_attr['nocache']);
63
        // set flag (compiled code of {function} must be included in cache file
64
        if (!$compiler->template->caching || $compiler->nocache || $compiler->tag_nocache) {
65
            $_nocache = 'true';
66
        } else {
67
            $_nocache = 'false';
68
        }
69
        $_paramsArray = array();
70
        foreach ($_attr as $_key => $_value) {
71
            if (is_int($_key)) {
72
                $_paramsArray[] = "$_key=>$_value";
73
            } else {
74
                $_paramsArray[] = "'$_key'=>$_value";
75
            }
76
        }
77
        $_params = 'array(' . implode(",", $_paramsArray) . ')';
78
        //$compiler->suppressNocacheProcessing = true;
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
79
        // was there an assign attribute
80
        if (isset($_assign)) {
81
            $_output =
82
                "<?php ob_start();\n\$_smarty_tpl->smarty->ext->_tplFunction->callTemplateFunction(\$_smarty_tpl, {$_name}, {$_params}, {$_nocache});\n\$_smarty_tpl->assign({$_assign}, ob_get_clean());?>\n";
83
        } else {
84
            $_output =
85
                "<?php \$_smarty_tpl->smarty->ext->_tplFunction->callTemplateFunction(\$_smarty_tpl, {$_name}, {$_params}, {$_nocache});?>\n";
86
        }
87
        return $_output;
88
    }
89
}
90