コード例 #1
0
 /**
  * (non-PHPdoc)
  * 
  * @see library/POData/QueryProcessor/ExpressionParser/Expressions.AbstractExpression::free()
  * 
  * @return void
  */
 public function free()
 {
     $this->left->free();
     $this->right->free();
     unset($this->left);
     unset($this->right);
 }
コード例 #2
0
ファイル: Min.php プロジェクト: datto/cinnabari
 public function __construct(AbstractExpression $mysql)
 {
     $this->mysql = "MIN({$mysql->getMysql()})";
 }
コード例 #3
0
ファイル: SugarBean.php プロジェクト: jglaine/sugar761-ent
 /**
  * Retrieve names of fields of the bean related by the given link included
  * in expression
  *
  * @param AbstractExpression $expr Parsed formula expression or nested expression
  * @param string $linkName Name of the link to filter "related" expressions by
  * @return array
  */
 protected function get_formula_related_fields(AbstractExpression $expr, $linkName)
 {
     $result = array();
     if ($expr instanceof RelatedFieldExpression || $expr instanceof MinRelatedExpression || $expr instanceof MaxRelatedExpression || $expr instanceof AverageRelatedExpression || $expr instanceof SumRelatedExpression || $expr instanceof CurrencySumRelatedExpression) {
         /** @var AbstractExpression[] $params */
         $params = $expr->getParameters();
         // here we don't evaluate the first param since we need the field name
         // but not it's value
         if ($params[0] instanceof SugarFieldExpression && $params[0]->varName == $linkName) {
             $result[] = $params[1]->evaluate();
         }
         return $result;
     }
     $params = $expr->getParameters();
     if (is_array($params)) {
         /** @var AbstractExpression $param */
         foreach ($params as $param) {
             $result = array_merge($result, $this->get_formula_related_fields($param, $linkName));
         }
     } else {
         if ($params instanceof AbstractExpression) {
             $result = array_merge($result, $this->get_formula_related_fields($params, $linkName));
         }
     }
     return array_unique($result);
 }
コード例 #4
0
ファイル: PolicyRule.php プロジェクト: SystemEd-Jacob/nethgui
 public function getSpecificity()
 {
     return 1.0 - $this->inner->getSpecificity();
 }
コード例 #5
0
 /**
  * (non-PHPdoc)
  * 
  * @see library/ODataProducer/QueryProcessor/ExpressionParser/Expressions/ODataProducer\QueryProcessor\ExpressionParser\Expressions.AbstractExpression::free()
  * 
  * @return void
  */
 public function free()
 {
     $this->child->free();
     unset($this->child);
 }
コード例 #6
0
 /**
  * Validate operands of an relational operation
  *
  * @param ExpressionToken    $expressionToken The expression token
  * @param AbstractExpression $leftArgument    The left argument expression
  * @param AbstractExpression $rightArgument   The right argument expression
  *
  * @return void
  */
 public static function verifyRelationalOpArguments($expressionToken, $leftArgument, $rightArgument)
 {
     //for null operands only equality operators are allowed
     $null = new Null1();
     if ($leftArgument->typeIs($null) || $rightArgument->typeIs($null)) {
         if (strcmp($expressionToken->Text, ODataConstants::KEYWORD_EQUAL) != 0 && strcmp($expressionToken->Text, ODataConstants::KEYWORD_NOT_EQUAL) != 0) {
             ODataException::createSyntaxError(Messages::expressionParserOperatorNotSupportNull($expressionToken->Text, $expressionToken->Position));
         }
         return;
     }
     //for guid operands only equality operators are allowed
     $guid = new Guid();
     if ($leftArgument->typeIs($guid) && $rightArgument->typeIs($guid)) {
         if (strcmp($expressionToken->Text, ODataConstants::KEYWORD_EQUAL) != 0 && strcmp($expressionToken->Text, ODataConstants::KEYWORD_NOT_EQUAL) != 0) {
             ODataException::createSyntaxError(Messages::expressionParserOperatorNotSupportGuid($expressionToken->Text, $expressionToken->Position));
         }
         return;
     }
     //for binary operands only equality operators are allowed
     $binary = new Binary();
     if ($leftArgument->typeIs($binary) && $rightArgument->typeIs($binary)) {
         if (strcmp($expressionToken->Text, ODataConstants::KEYWORD_EQUAL) != 0 && strcmp($expressionToken->Text, ODataConstants::KEYWORD_NOT_EQUAL) != 0) {
             ODataException::createSyntaxError(Messages::expressionParserOperatorNotSupportBinary($expressionToken->Text, $expressionToken->Position));
         }
         return;
     }
     //TODO: eq and ne is valid for 'resource reference'
     //navigation also verify here
     $functions = array_merge(self::relationalOperationFunctions(), self::stringComparisionFunctions());
     $function = self::findFunctionWithPromotion($functions, array($leftArgument, $rightArgument), false);
     if ($function == null) {
         self::incompatibleError($expressionToken, array($leftArgument, $rightArgument));
     }
 }
コード例 #7
0
 public function getMysql()
 {
     $mysql = $this->expression->getMysql();
     return "({$this->operator} {$mysql})";
 }
コード例 #8
0
ファイル: Client.php プロジェクト: henryf/designPatterns
 public function doSomething(AbstractExpression $expression, Context $context)
 {
     return $expression->interpret($context);
 }
コード例 #9
0
 public function getMysql()
 {
     $leftMysql = $this->left->getMysql();
     $rightMysql = $this->right->getMysql();
     return "({$leftMysql} {$this->operator} {$rightMysql})";
 }
コード例 #10
0
 /**
  * Initialize function for the TRUE/FALSE constants. Should only be called by the abstract class constructor
  */
 protected static function initBoolConstants()
 {
     if (empty(self::$TRUE)) {
         self::$TRUE = new BooleanConstantExpression(true);
     }
     if (empty(self::$FALSE)) {
         self::$FALSE = new BooleanConstantExpression(false);
     }
 }