Home » HTML » HTML_QuickForm » Bug #338
Unsupported Operands syntax error in class QuickForm
Details
| Submitted | 2003-12-02 19:15 UTC |
|---|---|
| From | mfriedman at symcor dot com |
| Status | Bogus |
| Package | HTML_QuickForm |
| PHP Version | Irrelevant |
| OS | Linux |
| Roadmaps | (Not assigned) |
Comments
[2003-12-02 19:15 UTC] mfriedman at symcor dot com
Description:
------------
There was another error report about this but I do not believe the issue has been properly dealt with. The problem exists because the operator being used does not relate correctly to the var type. The class declares $this->_errors as an array and so at least for consistency it should be treated as such in a consistent way. Thus the operator used to append to the $this->_errors array should be [] and not +=. Doing otherwise is also confusing because it breaks the way the other validation methods are written - it doesn't seem consistent to me.
Here is my report:
On line 1290 of QuickForm.php there is an error which causes an unsupported operands error in php.
line 1290: $this->_errors += $res;
The += operator is incorrectly used here - it is a string operator. $this->_errors is an array so the line should read instead:
line 1290: $this->_errors[$elementName] = $res;
This is part of the validate() method.
Reproduce code:
---------------
// process the global rules now
foreach ($this->_formRules as $rule) {
if (true !== ($res = call_user_func($rule, $this->_submitValues, $this->_submitFiles))) {
$this->_errors += $res;
}
}
Expected result:
----------------
There should be no error generated by php.
Actual result:
--------------
Fatal error: Unsupported operand types in /home/client/php/PEAR/HTML/QuickForm.php on line 1290