Permalink
Browse files

CS fixes

  • Loading branch information...
1 parent d874297 commit 7d4b8adffb9c184f0181488971b035f73d591588 @lsmith77 lsmith77 committed Apr 19, 2012
@@ -159,12 +159,10 @@ protected function convertFullTextSearchExpression($literal)
*/
protected function convertStaticOperand(QOM\StaticOperandInterface $operand)
{
- if ($operand instanceof QOM\BindVariableValueInterface)
- {
+ if ($operand instanceof QOM\BindVariableValueInterface) {
return $this->convertBindVariable($operand->getBindVariableName());
}
- elseif ($operand instanceof QOM\LiteralInterface)
- {
+ if ($operand instanceof QOM\LiteralInterface) {
return $this->convertLiteral($operand->getLiteralValue());
}
@@ -200,7 +198,6 @@ protected function convertOrderings(array $orderings)
{
$list = array();
foreach ($orderings as $ordering) {
-
$order = $this->generator->evalOrder($ordering->getOrder());
$operand = $this->convertDynamicOperand($ordering->getOperand());
$list[] = $this->generator->evalOrdering($operand, $order);
@@ -245,6 +242,7 @@ protected function convertColumns(array $columns)
$colname = $column->getColumnName();
$list[] = $this->generator->evalColumn($selector, $property, $colname);
}
+
return $this->generator->evalColumns($list);
}
@@ -168,21 +168,20 @@ public function evalLiteral($literal)
if ($literal instanceof \DateTime) {
$string = \PHPCR\PropertyType::convertType($literal, \PHPCR\PropertyType::STRING);
return $this->evalCastLiteral($string, 'DATE');
- } else if (is_bool($literal)) {
- if ($literal) {
- $string = 'true';
- } else {
- $string = 'false';
- }
+ }
+ if (is_bool($literal)) {
+ $string = $literal ? 'true' : 'false';
return $this->evalCastLiteral($string, 'BOOLEAN');
- } else if (is_int($literal)) {
+ }
+ if (is_int($literal)) {
$string = \PHPCR\PropertyType::convertType($literal, \PHPCR\PropertyType::STRING);
return $this->evalCastLiteral($string, 'LONG');
- } else if (is_float($literal)) {
+ }
+ if (is_float($literal)) {
$string = \PHPCR\PropertyType::convertType($literal, \PHPCR\PropertyType::STRING);
return $this->evalCastLiteral($string, 'DOUBLE');
}
return "'$literal'";
}
-}
+}
@@ -1,10 +1,11 @@
<?php
-namespace PHPCR\Util\QOM;
+namespace PHPCR\Util\QOM;
class NotSupportedConstraintException extends \RuntimeException
{
- function __construct($constraint) {
+ public function __construct($constraint)
+ {
parent::__construct(get_class($constraint) . " is not supported by this query language");
}
-}
+}
@@ -1,10 +1,11 @@
<?php
-namespace PHPCR\Util\QOM;
+namespace PHPCR\Util\QOM;
class NotSupportedOperandException extends \RuntimeException
{
- function __construct($constraint) {
+ public function __construct($constraint)
+ {
parent::__construct(get_class($constraint) . " is not supported by this query language");
}
-}
+}
@@ -19,9 +19,7 @@ class QomToSql1QueryConverter extends BaseQomToSqlQueryConverter
protected function convertSource(QOM\SourceInterface $source)
{
if ($source instanceof QOM\SelectorInterface) {
-
return $this->convertSelector($source);
-
}
throw new \InvalidArgumentException("Invalid Source");
@@ -41,45 +39,37 @@ protected function convertSource(QOM\SourceInterface $source)
*/
protected function convertConstraint(QOM\ConstraintInterface $constraint)
{
- if ($constraint instanceof QOM\AndInterface)
- {
+ if ($constraint instanceof QOM\AndInterface) {
return $this->generator->evalAnd(
$this->convertConstraint($constraint->getConstraint1()),
$this->convertConstraint($constraint->getConstraint2()));
}
- elseif ($constraint instanceof QOM\OrInterface)
- {
+ if ($constraint instanceof QOM\OrInterface) {
return $this->generator->evalOr(
$this->convertConstraint($constraint->getConstraint1()),
$this->convertConstraint($constraint->getConstraint2()));
}
- elseif ($constraint instanceof QOM\NotInterface)
- {
+ if ($constraint instanceof QOM\NotInterface) {
return $this->generator->evalNot($this->convertConstraint($constraint->getConstraint()));
}
- elseif ($constraint instanceof QOM\ComparisonInterface)
- {
+ if ($constraint instanceof QOM\ComparisonInterface) {
return $this->convertComparison($constraint);
}
- elseif ($constraint instanceof QOM\PropertyExistenceInterface)
- {
+ if ($constraint instanceof QOM\PropertyExistenceInterface) {
return $this->convertPropertyExistence($constraint);
}
elseif ($constraint instanceof QOM\FullTextSearchInterface)
{
return $this->convertFullTextSearch($constraint);
}
- elseif ($constraint instanceof QOM\SameNodeInterface)
- {
+ if ($constraint instanceof QOM\SameNodeInterface) {
throw new NotSupportedConstraintException($constraint);
}
- elseif ($constraint instanceof QOM\ChildNodeInterface)
- {
+ if ($constraint instanceof QOM\ChildNodeInterface) {
return $this->generator->evalChildNode(
$this->convertPath($constraint->getParentPath()));
}
- elseif ($constraint instanceof QOM\DescendantNodeInterface)
- {
+ if ($constraint instanceof QOM\DescendantNodeInterface) {
return $this->generator->evalDescendantNode(
$this->convertPath($constraint->getAncestorPath()));
}
@@ -10,7 +10,6 @@
*/
class QomToSql2QueryConverter extends BaseQomToSqlQueryConverter
{
-
/**
* Source ::= Selector | Join
*
@@ -20,11 +19,9 @@ class QomToSql2QueryConverter extends BaseQomToSqlQueryConverter
protected function convertSource(QOM\SourceInterface $source)
{
if ($source instanceof QOM\SelectorInterface) {
-
return $this->convertSelector($source);
-
- } elseif ($source instanceof QOM\JoinInterface) {
-
+ }
+ if ($source instanceof QOM\JoinInterface) {
return $this->convertJoin($source);
}
@@ -64,26 +61,15 @@ protected function convertJoin(QOM\JoinInterface $join)
*/
protected function convertJoinCondition(QOM\JoinConditionInterface $condition)
{
- $sql2 = '';
-
- if ($condition instanceof QOM\EquiJoinConditionInterface)
- {
+ if ($condition instanceof QOM\EquiJoinConditionInterface) {
$sql2 = $this->convertEquiJoinCondition($condition);
- }
- elseif ($condition instanceof QOM\SameNodeJoinConditionInterface)
- {
+ } elseif ($condition instanceof QOM\SameNodeJoinConditionInterface) {
$sql2 = $this->convertSameNodeJoinCondition($condition);
- }
- elseif ($condition instanceof QOM\ChildNodeJoinConditionInterface)
- {
+ } elseif ($condition instanceof QOM\ChildNodeJoinConditionInterface) {
$sql2 = $this->convertChildNodeJoinCondition($condition);
- }
- elseif ($condition instanceof QOM\DescendantNodeJoinConditionInterface)
- {
+ } elseif ($condition instanceof QOM\DescendantNodeJoinConditionInterface) {
$sql2 = $this->convertDescendantNodeJoinCondition($condition);
- }
- else
- {
+ } else {
// This should not happen, but who knows...
throw new \InvalidArgumentException("Invalid operand");
}
@@ -189,48 +175,40 @@ protected function convertDescendantNodeJoinCondition(QOM\DescendantNodeJoinCond
*/
protected function convertConstraint(QOM\ConstraintInterface $constraint)
{
- if ($constraint instanceof QOM\AndInterface)
- {
+ if ($constraint instanceof QOM\AndInterface) {
return $this->generator->evalAnd(
$this->convertConstraint($constraint->getConstraint1()),
$this->convertConstraint($constraint->getConstraint2()));
}
- elseif ($constraint instanceof QOM\OrInterface)
- {
+ if ($constraint instanceof QOM\OrInterface) {
return $this->generator->evalOr(
$this->convertConstraint($constraint->getConstraint1()),
$this->convertConstraint($constraint->getConstraint2()));
}
- elseif ($constraint instanceof QOM\NotInterface)
- {
+ if ($constraint instanceof QOM\NotInterface) {
return $this->generator->evalNot($this->convertConstraint($constraint->getConstraint()));
}
- elseif ($constraint instanceof QOM\ComparisonInterface)
- {
+ if ($constraint instanceof QOM\ComparisonInterface) {
return $this->convertComparison($constraint);
}
- elseif ($constraint instanceof QOM\PropertyExistenceInterface)
- {
+ if ($constraint instanceof QOM\PropertyExistenceInterface) {
return $this->convertPropertyExistence($constraint);
}
elseif ($constraint instanceof QOM\FullTextSearchInterface)
{
return $this->convertFullTextSearch($constraint);
}
- elseif ($constraint instanceof QOM\SameNodeInterface)
- {
+ if ($constraint instanceof QOM\SameNodeInterface) {
return $this->generator->evalSameNode(
$this->convertPath($constraint->getPath()),
$constraint->getSelectorName());
}
- elseif ($constraint instanceof QOM\ChildNodeInterface)
- {
+ if ($constraint instanceof QOM\ChildNodeInterface) {
return $this->generator->evalChildNode(
$this->convertPath($constraint->getParentPath()),
$constraint->getSelectorName());
}
- elseif ($constraint instanceof QOM\DescendantNodeInterface)
- {
+ if ($constraint instanceof QOM\DescendantNodeInterface) {
return $this->generator->evalDescendantNode(
$this->convertPath($constraint->getAncestorPath()),
$constraint->getSelectorName());
@@ -26,7 +26,8 @@ public function evalSelector($nodeTypeName, $selectorName = null)
return $nodeTypeName;
}
- protected function getPathForDescendantQuery($path) {
+ protected function getPathForDescendantQuery($path)
+ {
$path = trim($path,"'");
$path = trim($path,"/");
$sql1 = "/" . str_replace("/","[%]/",$path) ;
@@ -96,7 +97,6 @@ public function evalColumns($columns)
$sql1 = '';
foreach ($columns as $column) {
-
if ($sql1 !== '') {
$sql1 .= ', ';
}
@@ -289,7 +289,6 @@ public function evalColumns($columns)
$sql2 = '';
foreach ($columns as $column) {
-
if ($sql2 !== '') {
$sql2 .= ', ';
}
@@ -24,6 +24,7 @@ public function testDateTimeLiteral()
$literal = $this->generator->evalLiteral(new \DateTime('2011-12-23T00:00:00.000+00:00'));
$this->assertEquals("CAST('2011-12-23T00:00:00.000+00:00' AS DATE)", $literal);
}
+
public function testBoolLiteral()
{
$literal = $this->generator->evalLiteral(true);

0 comments on commit 7d4b8ad

Please sign in to comment.