Passed
Pull Request — master (#1323)
by Michael
05:03
created

XoopsForm::getObjectID()   A

Complexity

Conditions 6
Paths 24

Size

Total Lines 36
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 6
eloc 15
c 1
b 0
f 0
nc 24
nop 2
dl 0
loc 36
rs 9.2222
1
<?php
2
/**
3
 * XOOPS Form Class
4
 *
5
 * You may not change or alter any portion of this comment or credits
6
 * of supporting developers from this source code or any supporting source code
7
 * which is considered copyrighted (c) material of the original comment or credit authors.
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 *
12
 * @copyright       (c) 2000-2016 XOOPS Project (www.xoops.org)
13
 * @license             GNU GPL 2 (https://www.gnu.org/licenses/gpl-2.0.html)
14
 * @package             kernel
15
 * @subpackage          form
16
 * @since               2.0.0
17
 * @author              Kazumi Ono (AKA onokazu) http://www.myweb.ne.jp/, http://jp.xoops.org/
18
 * @author              Taiwen Jiang <[email protected]>
19
 */
20
defined('XOOPS_ROOT_PATH') || exit('Restricted access');
21
22
/**
23
 * Abstract base class for forms
24
 *
25
 * @author         Kazumi Ono <[email protected]>
26
 * @author         Taiwen Jiang <[email protected]>
27
 * @package        kernel
28
 * @subpackage     form
29
 * @access         public
30
 */
31
class XoopsForm
32
{
33
    /**
34
     * *#@+
35
     *
36
     * @access private
37
     */
38
    /**
39
     * "action" attribute for the html form
40
     *
41
     * @var string
42
     */
43
    public $_action;
44
45
    /**
46
     * "method" attribute for the form.
47
     *
48
     * @var string
49
     */
50
    public $_method;
51
52
    /**
53
     * "name" attribute of the form
54
     *
55
     * @var string
56
     */
57
    public $_name;
58
59
    /**
60
     * title for the form
61
     *
62
     * @var string
63
     */
64
    public $_title;
65
66
    /**
67
     * summary for the form (WGAC2 Requirement)
68
     *
69
     * @var string
70
     */
71
    public $_summary = '';
72
73
    /**
74
     * array of {@link XoopsFormElement} objects
75
     *
76
     * @var array
77
     */
78
    public $_elements = array();
79
80
    /**
81
     * HTML classes for the <form> tag
82
     *
83
     * @var array
84
     */
85
    public $_class = array();
86
    
87
    /**
88
     * extra information for the <form> tag
89
     *
90
     * @var array
91
     */
92
    public $_extra = array();
93
94
    /**
95
     * required elements
96
     *
97
     * @var array
98
     */
99
    public $_required = array();
100
101
    /**
102
     * additional serialized object checksum (ERM Analysis - Requirement)
103
     * @deprecated
104
     * @access private
105
     */
106
    public $_objid = 'da39a3ee5e6b4b0d3255bfef95601890afd80709';
107
108
    /**
109
     * *#@-
110
     */
111
112
    /**
113
     * constructor
114
     *
115
     * @param string $title    title of the form
116
     * @param string $name     "name" attribute for the <form> tag
117
     * @param string $action   "action" attribute for the <form> tag
118
     * @param string $method   "method" attribute for the <form> tag
119
     * @param bool   $addtoken whether to add a security token to the form
120
     * @param string $summary
121
     */
122
    public function __construct($title, $name, $action, $method = 'post', $addtoken = false, $summary = '')
123
    {
124
        $this->_title   = $title;
125
        $this->_name    = $name;
126
        $this->_action  = $action;
127
        $this->_method  = $method;
128
        $this->_summary = $summary;
129
        if (false != $addtoken) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison !== instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
130
            $this->addElement(new XoopsFormHiddenToken());
131
        }
132
    }
133
    /**
134
     * PHP 4 style constructor compatibility shim
135
     * @deprecated all callers should be using parent::__construct()
136
     */
137
    public function XoopsForm()
138
    {
139
        $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1);
140
        trigger_error("Should call parent::__construct in {$trace[0]['file']} line {$trace[0]['line']},");
141
        self::__construct();
0 ignored issues
show
Bug Best Practice introduced by
The method XoopsForm::__construct() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

141
        self::/** @scrutinizer ignore-call */ 
142
              __construct();
Loading history...
Bug introduced by
The call to XoopsForm::__construct() has too few arguments starting with title. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

141
        self::/** @scrutinizer ignore-call */ 
142
              __construct();

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
142
    }
143
    /**
144
     * *#@+
145
     * retrieves object serialization/identification id (sha1 used)
146
     *
147
     * each object has serialization<br>
148
     * - legal requirement of enterprise relational management (ERM)
149
     *
150
     * @deprecated
151
     * @access public
152
     * @param mixed  $object   The object or value to serialize
153
     * @param string $hashinfo Hashing algorithm to use (default 'sha1')
154
     * @return string         The serialization ID
155
     */
156
    public function getObjectID($object, $hashinfo = 'sha1')
157
    {
158
        // Initialize $var
159
        $var = array(
160
            'name' => '',
161
            'value' => '',
162
            'func' => ''
163
        );
164
165
        // Check if $object is an object; if not, use $this
166
        if (!is_object($object)) {
167
            $object = $this;
168
        }
169
170
        // Switch hash method based on $hashinfo
171
        $hashMethod = ('md5' === $hashinfo) ? 'md5' : 'sha1';
172
173
        // Hash the class name
174
        $var['name'] = $hashMethod(get_class($object));
175
176
        // Hash the object variables
177
        foreach (get_object_vars($object) as $key => $value) {
178
            if ($key !== '_objid') {
179
                $var['value'] = $this->getArrayID($value, $key, $var['value'], $hashinfo);
180
            }
181
        }
182
183
        // Hash the class methods
184
        foreach (get_class_methods($object) as $key => $value) {
185
            $var['func'] = $this->getArrayID($value, $key, $var['func'], $hashinfo);
186
        }
187
188
        // Generate the final hash
189
        $this->_objid = $hashMethod(implode(':', $var));
0 ignored issues
show
Deprecated Code introduced by
The property XoopsForm::$_objid has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

189
        /** @scrutinizer ignore-deprecated */ $this->_objid = $hashMethod(implode(':', $var));
Loading history...
190
191
        return $this->_objid;
0 ignored issues
show
Deprecated Code introduced by
The property XoopsForm::$_objid has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

191
        return /** @scrutinizer ignore-deprecated */ $this->_objid;
Loading history...
192
    }
193
194
195
    /**
196
     * @param        $value
197
     * @param        $key
198
     * @param        $ret
199
     * @param string $hashinfo
200
     *
201
     * @return string
202
     */
203
    public function getArrayID($value, $key, $ret, $hashinfo = 'sha1')
204
    {
205
        switch ($hashinfo) {
206
            case 'md5':
207
                if (!isset($ret)) {
208
                    $ret = '';
209
                }
210
                if (is_array($value)) {
211
                    foreach ($value as $keyb => $valueb) {
212
                        $ret = md5($ret . ':' . $this->getArrayID($valueb, $keyb, $ret, $hashinfo));
213
                    }
214
                } else {
215
                    $ret = md5($ret . ':' . $key . ':' . $value);
216
                }
217
218
                return $ret;
219
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
220
            default:
221
                if (!isset($ret)) {
222
                    $ret = '';
223
                }
224
                if (is_array($value)) {
225
                    foreach ($value as $keyb => $valueb) {
226
                        $ret = sha1($ret . ':' . $this->getArrayID($valueb, $keyb, $ret, $hashinfo));
227
                    }
228
                } else {
229
                    $ret = sha1($ret . ':' . $key . ':' . $value);
230
                }
231
232
                return $ret;
233
                break;
234
        }
235
    }
236
237
    /**
238
     * return the summary of the form
239
     *
240
     * @param  bool $encode To sanitizer the text?
241
     * @return string
242
     */
243
    public function getSummary($encode = false)
244
    {
245
        return $encode ? htmlspecialchars($this->_summary, ENT_QUOTES) : $this->_summary;
246
    }
247
248
    /**
249
     * return the title of the form
250
     *
251
     * @param  bool $encode To sanitizer the text?
252
     * @return string
253
     */
254
    public function getTitle($encode = false)
255
    {
256
        return $encode ? htmlspecialchars($this->_title, ENT_QUOTES) : $this->_title;
257
    }
258
259
    /**
260
     * get the "name" attribute for the <form> tag
261
     *
262
     * Deprecated, to be refactored
263
     *
264
     * @param  bool $encode To sanitizer the text?
265
     * @return string
266
     */
267
    public function getName($encode = true)
268
    {
269
        return $encode ? htmlspecialchars($this->_name, ENT_QUOTES) : $this->_name;
270
    }
271
272
    /**
273
     * get the "action" attribute for the <form> tag
274
     *
275
     * @param  bool $encode To sanitizer the text?
276
     * @return string
277
     */
278
    public function getAction($encode = true)
279
    {
280
        // Convert &amp; to & for backward compatibility
281
        return $encode ? htmlspecialchars(str_replace('&amp;', '&', $this->_action), ENT_QUOTES) : $this->_action;
282
    }
283
284
    /**
285
     * get the "method" attribute for the <form> tag
286
     *
287
     * @return string
288
     */
289
    public function getMethod()
290
    {
291
        return (strtolower($this->_method) === 'get') ? 'get' : 'post';
292
    }
293
294
    /**
295
     * Add an element to the form
296
     *
297
     * @param string|XoopsFormElement $formElement reference to a {@link XoopsFormElement}
298
     * @param bool             $required    is this a "required" element?
299
     *
300
     */
301
    public function addElement($formElement, $required = false)
302
    {
303
        if (is_string($formElement)) {
304
            $this->_elements[] = $formElement;
305
        } elseif (is_subclass_of($formElement, 'XoopsFormElement')) {
306
            $this->_elements[] = &$formElement;
307
            if (!$formElement->isContainer()) {
308
                if ($required) {
309
                    $formElement->_required = true;
310
                    $this->_required[]      = &$formElement;
311
                }
312
            } else {
313
                $required_elements = &$formElement->getRequired();
0 ignored issues
show
Bug introduced by
The method getRequired() does not exist on XoopsFormElement. It seems like you code against a sub-type of XoopsFormElement such as XoopsFormElementTray. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

313
                $required_elements = &$formElement->/** @scrutinizer ignore-call */ getRequired();
Loading history...
314
                $count             = count($required_elements);
315
                for ($i = 0; $i < $count; ++$i) {
316
                    $this->_required[] = &$required_elements[$i];
317
                }
318
            }
319
        }
320
    }
321
322
    /**
323
     * get an array of forms elements
324
     *
325
     * @param bool $recurse get elements recursively?
326
     *
327
     * @return XoopsFormElement[] array of {@link XoopsFormElement}s
328
     */
329
    public function &getElements($recurse = false)
330
    {
331
        if (!$recurse) {
332
            return $this->_elements;
333
        } else {
334
            $ret   = array();
335
            $count = count($this->_elements);
336
            for ($i = 0; $i < $count; ++$i) {
337
                if (is_object($this->_elements[$i])) {
338
                    if (!$this->_elements[$i]->isContainer()) {
339
                        $ret[] = &$this->_elements[$i];
340
                    } else {
341
                        $elements = &$this->_elements[$i]->getElements(true);
342
                        $count2   = count($elements);
343
                        for ($j = 0; $j < $count2; ++$j) {
344
                            $ret[] = &$elements[$j];
345
                        }
346
                        unset($elements);
347
                    }
348
                }
349
            }
350
351
            return $ret;
352
        }
353
    }
354
355
    /**
356
     * get an array of "name" attributes of form elements
357
     *
358
     * @return array array of form element names
359
     */
360
    public function getElementNames()
361
    {
362
        $ret      = array();
363
        $elements = &$this->getElements(true);
364
        $count    = count($elements);
365
        for ($i = 0; $i < $count; ++$i) {
366
            $ret[] = $elements[$i]->getName();
367
        }
368
369
        return $ret;
370
    }
371
372
    /**
373
     * get a reference to a {@link XoopsFormElement} object by its "name"
374
     *
375
     * @param  string $name "name" attribute assigned to a {@link XoopsFormElement}
376
     * @return object reference to a {@link XoopsFormElement}, false if not found
377
     */
378
    public function &getElementByName($name)
379
    {
380
        $elements =& $this->getElements(true);
381
        $count    = count($elements);
382
        for ($i = 0; $i < $count; ++$i) {
383
            if ($name == $elements[$i]->getName(false)) {
384
                return $elements[$i];
385
            }
386
        }
387
        $elt = null;
388
389
        return $elt;
390
    }
391
392
    /**
393
     * Sets the "value" attribute of a form element
394
     *
395
     * @param string $name  the "name" attribute of a form element
396
     * @param string $value the "value" attribute of a form element
397
     */
398
    public function setElementValue($name, $value)
399
    {
400
        $ele = &$this->getElementByName($name);
401
        if (is_object($ele) && method_exists($ele, 'setValue')) {
402
            $ele->setValue($value);
403
        }
404
    }
405
406
    /**
407
     * Sets the "value" attribute of form elements in a batch
408
     *
409
     * @param array $values array of name/value pairs to be assigned to form elements
410
     */
411
    public function setElementValues($values)
412
    {
413
        if (!empty($values) && \is_array($values)) {
414
            // will not use getElementByName() for performance..
415
            $elements = &$this->getElements(true);
416
            $count    = count($elements);
417
            for ($i = 0; $i < $count; ++$i) {
418
                $name = $elements[$i]->getName(false);
419
                if ($name && isset($values[$name]) && method_exists($elements[$i], 'setValue')) {
420
                    $elements[$i]->setValue($values[$name]);
0 ignored issues
show
Bug introduced by
The method setValue() does not exist on XoopsFormElement. It seems like you code against a sub-type of said class. However, the method does not exist in XoopsFormFile or XoopsFormLabel or XoopsFormElementTray or XoopsFormCaptcha or XoopsFormSelectEditor or XoopsFormDateTime or XoopsFormSelectUser. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

420
                    $elements[$i]->/** @scrutinizer ignore-call */ 
421
                                   setValue($values[$name]);
Loading history...
421
                }
422
            }
423
        }
424
    }
425
426
    /**
427
     * Gets the "value" attribute of a form element
428
     *
429
     * @param  string $name   the "name" attribute of a form element
430
     * @param  bool   $encode To sanitizer the text?
431
     * @return string the "value" attribute assigned to a form element, null if not set
432
     */
433
    public function getElementValue($name, $encode = false)
434
    {
435
        $ele = &$this->getElementByName($name);
436
        if (is_object($ele) && method_exists($ele, 'getValue')) {
437
            return $ele->getValue($encode);
438
        }
439
440
        return null;
441
    }
442
443
    /**
444
     * gets the "value" attribute of all form elements
445
     *
446
     * @param  bool $encode To sanitizer the text?
447
     * @return array array of name/value pairs assigned to form elements
448
     */
449
    public function getElementValues($encode = false)
450
    {
451
        // will not use getElementByName() for performance..
452
        $elements = &$this->getElements(true);
453
        $count    = count($elements);
454
        $values   = array();
455
        for ($i = 0; $i < $count; ++$i) {
456
            $name = $elements[$i]->getName(false);
457
            if ($name && method_exists($elements[$i], 'getValue')) {
458
                $values[$name] = &$elements[$i]->getValue($encode);
0 ignored issues
show
Bug introduced by
The method getValue() does not exist on XoopsFormElement. It seems like you code against a sub-type of said class. However, the method does not exist in XoopsFormFile or XoopsFormElementTray or XoopsFormCaptcha or XoopsGroupFormCheckBox or XoopsFormSelectEditor or XoopsFormDateTime or XoopsFormSelectUser. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

458
                $values[$name] = &$elements[$i]->/** @scrutinizer ignore-call */ getValue($encode);
Loading history...
459
            }
460
        }
461
462
        return $values;
463
    }
464
465
    /**
466
     * set the "class" attribute for the <form> tag
467
     *
468
     * @param string $class
469
     */
470
    public function setClass($class)
471
    {
472
        $class = trim($class);
473
        if (!empty($class)) {
474
            $this->_class[] = $class;
475
        }
476
    }
477
    
478
    /**
479
     * set the extra attributes for the <form> tag
480
     *
481
     * @param string $extra extra attributes for the <form> tag
482
     */
483
    public function setExtra($extra)
484
    {
485
        if (!empty($extra)) {
486
            $this->_extra[] = $extra;
487
        }
488
    }
489
490
    /**
491
     * set the summary tag for the <form> tag
492
     *
493
     * @param string $summary
494
     */
495
    public function setSummary($summary)
496
    {
497
        if (!empty($summary)) {
498
            $this->summary = strip_tags($summary);
0 ignored issues
show
Bug Best Practice introduced by
The property summary does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
499
        }
500
    }
501
502
    /**
503
     * get the "class" attribute for the <form> tag
504
     *
505
     * @return string "class" attribute value
506
     */
507
    public function &getClass()
508
    {
509
        if (empty($this->_class)) {
510
            return false;
0 ignored issues
show
Bug Best Practice introduced by
The expression return false returns the type false which is incompatible with the documented return type string.
Loading history...
511
        }
512
        $classes = array();
513
        foreach ($this->_class as $class) {
514
            $classes[] = htmlspecialchars($class, ENT_QUOTES);
515
        }
516
517
        return implode(' ', $classes);
518
    }
519
    
520
    /**
521
     * get the extra attributes for the <form> tag
522
     *
523
     * @return string
524
     */
525
    public function &getExtra()
526
    {
527
        $extra = empty($this->_extra) ? '' : ' ' . implode(' ', $this->_extra);
528
529
        return $extra;
530
    }
531
532
    /**
533
     * make an element "required"
534
     *
535
     * @param XoopsFormElement $formElement reference to a {@link XoopsFormElement}
536
     */
537
    public function setRequired(XoopsFormElement $formElement)
538
    {
539
        $this->_required[] = &$formElement;
540
    }
541
542
    /**
543
     * get an array of "required" form elements
544
     *
545
     * @return array array of {@link XoopsFormElement}s
546
     */
547
    public function &getRequired()
548
    {
549
        return $this->_required;
550
    }
551
552
    /**
553
     * insert a break in the form
554
     *
555
     * This method is abstract. It must be overwritten in the child classes.
556
     *
557
     * @param string $extra extra information for the break
558
     * @abstract
559
     */
560
    public function insertBreak($extra = null)
561
    {
562
    }
563
564
    /**
565
     * returns renderered form
566
     *
567
     * This method is abstract. It must be overwritten in the child classes.
568
     *
569
     * @abstract
570
     */
571
    public function render()
572
    {
573
    }
574
575
    /**
576
     * displays rendered form
577
     */
578
    public function display()
579
    {
580
        echo $this->render();
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->render() targeting XoopsForm::render() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
581
    }
582
583
    /**
584
     * Renders the Javascript function needed for client-side for validation
585
     *
586
     * Form elements that have been declared "required" and not set will prevent the form from being
587
     * submitted. Additionally, each element class may provide its own "renderValidationJS" method
588
     * that is supposed to return custom validation code for the element.
589
     *
590
     * The element validation code can assume that the JS "myform" variable points to the form, and must
591
     * execute <i>return false</i> if validation fails.
592
     *
593
     * A basic element validation method may contain something like this:
594
     * <code>
595
     * function renderValidationJS() {
596
     *            $name = $this->getName();
597
     *            return "if (myform.{$name}.value != 'valid') { " .
598
     *              "myform.{$name}.focus(); window.alert( '$name is invalid' ); return false;" .
599
     *              " }";
600
     * }
601
     * </code>
602
     *
603
     * @param boolean $withtags Include the < javascript > tags in the returned string
604
     *
605
     * @return string
606
     */
607
    public function renderValidationJS($withtags = true)
608
    {
609
        $js = '';
610
        if ($withtags) {
611
            $js .= "\n<!-- Start Form Validation JavaScript //-->\n<script type='text/javascript'>\n<!--//\n";
612
        }
613
        $formname = $this->getName();
614
        $js .= "function xoopsFormValidate_{$formname}() { var myform = window.document.{$formname}; ";
615
        $elements =& $this->getElements(true);
616
        foreach ($elements as $elt) {
617
            if (method_exists($elt, 'renderValidationJS')) {
618
                $js .= $elt->renderValidationJS();
619
            }
620
        }
621
        $js .= "return true;\n}\n";
622
        if ($withtags) {
623
            $js .= "//--></script>\n<!-- End Form Validation JavaScript //-->\n";
624
        }
625
626
        return $js;
627
    }
628
629
    /**
630
     * assign to smarty form template instead of displaying directly
631
     *
632
     * @param XoopsTpl $tpl reference to a {@link Smarty} object object
633
     * @see      Smarty
634
     */
635
    public function assign(XoopsTpl $tpl)
636
    {
637
        $i        = -1;
638
        $elements = array();
639
        if (count($this->getRequired()) > 0) {
640
            $this->_elements[] = "<tr class='foot'><td colspan='2'>* = " . _REQUIRED . '</td></tr>';
641
        }
642
        foreach ($this->getElements() as $ele) {
643
            ++$i;
644
            if (is_string($ele)) {
645
                $elements[$i]['body'] = $ele;
646
                continue;
647
            }
648
            $ele_name                 = $ele->getName();
649
            $ele_description          = $ele->getDescription();
650
            $n                        = $ele_name ?: $i;
651
            $elements[$n]['name']     = $ele_name;
652
            $elements[$n]['caption']  = $ele->getCaption();
653
            $elements[$n]['body']     = $ele->render();
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $elements[$n]['body'] is correct as $ele->render() targeting XoopsFormElement::render() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
654
            $elements[$n]['hidden']   = $ele->isHidden();
655
            $elements[$n]['required'] = $ele->isRequired();
656
            if ($ele_description != '') {
657
                $elements[$n]['description'] = $ele_description;
658
            }
659
        }
660
        $js = $this->renderValidationJS();
661
        $tpl->assign($this->getName(), array(
662
            'title'      => $this->getTitle(),
663
            'name'       => $this->getName(),
664
            'action'     => $this->getAction(),
665
            'method'     => $this->getMethod(),
666
            'extra'      => 'onsubmit="return xoopsFormValidate_' . $this->getName() . '();"' . $this->getExtra(),
667
            'javascript' => $js,
668
            'elements'   => $elements,
669
            'rendered'   => $this->render(),
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->render() targeting XoopsForm::render() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
670
        ));
671
    }
672
}
673