Author: Elliot Levin (elliotlevin@hotmail.com)
Inheritance: extends ObjectOperationExpression
Example #1
0
 protected final function visitUnique(O\MethodCallExpression $expression)
 {
     $this->addSegment(function ($segmentId) {
         $this->interpretation->interpretUnique($segmentId);
     });
     $this->visit($expression->getValue());
 }
Example #2
0
 public function visitMethodCall(O\MethodCallExpression $expression)
 {
     $this->walk($expression->getValue());
     $this->walk($expression->getName());
     $this->walkAll($expression->getArguments());
     $this->addTypeOperation($expression, $this->analysis[$expression->getValue()]->getMethod($expression));
 }
 protected final function visitOffsetUnset(O\Expression $expression)
 {
     $operationId = $this->getId('offset-unset');
     $indexId = $this->getId('unset-index');
     if ($expression instanceof O\MethodCallExpression) {
         $this->interpretation->interpretOffsetUnset($operationId, $indexId, $this->getArgumentValueAt(0, $expression));
         $this->interpretSourceAsScope($expression);
         return;
     } elseif ($expression instanceof O\UnsetExpression) {
         $unsetArguments = $expression->getValues();
         if (count($unsetArguments) === 1 && $unsetArguments[0] instanceof O\IndexExpression) {
             $this->interpretation->interpretOffsetUnset($operationId, $indexId, $this->getValue($unsetArguments[0]->getIndex()));
             $this->interpretSourceAsScope($unsetArguments[0]);
             return;
         }
     }
     throw new PinqException('Cannot interpret offset unset operation: invalid expression type, expecting %s, %s given', O\MethodCallExpression::getType() . ' or ' . O\IssetExpression::getType() . ' with a single parameter index', $expression->getType());
 }
Example #4
0
 /**
  * @param O\MethodCallExpression $methodExpression
  *
  * @return O\MethodCallExpression
  * @throws PinqException
  */
 protected final function getSourceMethodCall(O\MethodCallExpression $methodExpression)
 {
     $sourceExpression = $methodExpression->getValue();
     if (!$sourceExpression instanceof O\MethodCallExpression) {
         throw new PinqException('Cannot get source method call expression: source is not a method call, %s given', get_class($methodExpression));
     }
     return $sourceExpression;
 }
 protected final function visitCount(O\Expression $expression)
 {
     $this->interpretation->interpretCount($this->getId('count'));
     if ($expression instanceof O\MethodCallExpression) {
         $this->interpretSourceAsScope($expression);
     } elseif ($expression instanceof O\FunctionCallExpression && count($expression->getArguments()) > 0) {
         $this->scopeInterpreter->interpretScope($expression->getArguments()[0]->getValue());
     } else {
         throw new PinqException('Cannot interpret count request: invalid expression type, expecting %s, %s given', O\MethodCallExpression::getType() . ' or ' . O\FunctionCallExpression::getType() . ' with at least one argument', $expression->getType());
     }
 }
Example #6
0
 public function getMethod(O\MethodCallExpression $expression)
 {
     if ($method = $this->getMethodByName($expression->getName(), false)) {
         return $method;
     }
     return parent::getMethod($expression);
 }