|
4134 - in trunk/Template/src: . parsers/source_to_tst/implementations [eZCo: msg#00307web.ezcomponents.cvs
Author: Raymond Bosman Date: 2006-11-29 18:20:39 +0100 (Wed, 29 Nov 2006) New Revision: 4134 Log: - Fixed a problem that the {4 = 5} assignment was allowed. Modified: trunk/Template/src/error_messages.php trunk/Template/src/parsers/source_to_tst/implementations/expression.php Modified: trunk/Template/src/error_messages.php =================================================================== --- trunk/Template/src/error_messages.php 2006-11-29 15:32:10 UTC (rev 4133) +++ trunk/Template/src/error_messages.php 2006-11-29 17:20:39 UTC (rev 4134) @@ -66,6 +66,7 @@ // Other const MSG_TYPEHINT_FAILURE = "The types (array or value) are not correctly used with this operator."; + const MSG_UNEXPECTED_ASSIGNMENT = "Unexpected assignment '='. The left hand side must be variable."; const MSG_EXPECT_ARRAY = "Expecting an array."; const MSG_EXPECT_VALUE_NOT_ARRAY = "Expecting a value and not an array."; Modified: trunk/Template/src/parsers/source_to_tst/implementations/expression.php =================================================================== --- trunk/Template/src/parsers/source_to_tst/implementations/expression.php 2006-11-29 15:32:10 UTC (rev 4133) +++ trunk/Template/src/parsers/source_to_tst/implementations/expression.php 2006-11-29 17:20:39 UTC (rev 4134) @@ -555,6 +555,8 @@ return $operatorName; } + $this->checkForValidOperator( $this->currentOperator, $operator, $operatorStartCursor ); + $this->currentOperator = $this->parser->handleOperatorPrecedence( $this->currentOperator, $operator ); $this->parser->reportElementCursor( $operator->startCursor, $operator->endCursor, $operator ); @@ -571,6 +573,28 @@ return false; } + + /** + * Check whether the given operand can be the left hand side of the $operator. + * For example: 4 = 5; is not allowed. But $a = 5 , and $a[0][0]->bla is. + */ + private function checkForValidOperator( $lhs, $op, $cursor ) + { + if( $op instanceof ezcTemplateAssignmentOperatorTstNode ) + { + if( !( $lhs instanceof ezcTemplateVariableTstNode || + $lhs instanceof ezcTemplateArrayFetchOperatorTstNode || + $lhs instanceof ezcTemplateArrayAppendOperatorTstNode || + $lhs instanceof ezcTemplatePropertyFetchOperatorTstNode ) ) + { + throw new ezcTemplateParserException( $this->parser->source, $cursor, $cursor, + ezcTemplateSourceToTstErrorMessages::MSG_UNEXPECTED_ASSIGNMENT ); + } + + } + + return true; + } } ?> |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | 4133 - trunk/Template/tests [eZComponents: Trunk]: 00307, Raymond Bosman |
|---|---|
| Next by Date: | 4135 - trunk/Template/tests [eZComponents: Trunk]: 00307, Raymond Bosman |
| Previous by Thread: | 4133 - trunk/Template/tests [eZComponents: Trunk]i: 00307, Raymond Bosman |
| Next by Thread: | 4135 - trunk/Template/tests [eZComponents: Trunk]: 00307, Raymond Bosman |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |