@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | private static function convertDate(string $value): \DateTime |
| 34 | 34 | { |
| 35 | - $value = trim($value); |
|
| 35 | + $value = trim($value); |
|
| 36 | 36 | try { |
| 37 | 37 | $date = new \DateTime(sprintf("@%s", $value)); |
| 38 | 38 | } catch (\Exception $exception) { |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | if (! $date) { |
| 55 | - throw new OrmException("Could not parse string '".$value."' as date"); |
|
| 55 | + throw new OrmException("Could not parse string '".$value."' as date"); |
|
| 56 | 56 | } |
| 57 | 57 | } catch (\Exception $exception) { |
| 58 | 58 | throw OrmException::fromPrevious($exception); |
@@ -39,19 +39,19 @@ discard block |
||
| 39 | 39 | try { |
| 40 | 40 | $date = \DateTime::createFromFormat("Y-m-d", $value); |
| 41 | 41 | |
| 42 | - if (! $date) { |
|
| 42 | + if (!$date) { |
|
| 43 | 43 | $date = \DateTime::createFromFormat("Y-m-d H:i:s", $value); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - if (! $date) { |
|
| 46 | + if (!$date) { |
|
| 47 | 47 | $date = \DateTime::createFromFormat(\DateTime::W3C, $value); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - if (! $date) { |
|
| 50 | + if (!$date) { |
|
| 51 | 51 | $date = \DateTime::createFromFormat(\DateTime::ISO8601, $value); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - if (! $date) { |
|
| 54 | + if (!$date) { |
|
| 55 | 55 | throw new OrmException("Could not parse string '".$value."' as date"); |
| 56 | 56 | } |
| 57 | 57 | } catch (\Exception $exception) { |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | private static function convertType(string $type, $value) |
| 77 | 77 | { |
| 78 | - if (! $type) { |
|
| 78 | + if (!$type) { |
|
| 79 | 79 | return $value; |
| 80 | 80 | } |
| 81 | 81 | |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | return strval($value); |
| 104 | 104 | |
| 105 | 105 | default: |
| 106 | - if (! self::isInternalClass($type)) { |
|
| 106 | + if (!self::isInternalClass($type)) { |
|
| 107 | 107 | return $value; |
| 108 | 108 | } |
| 109 | 109 | } |
@@ -119,15 +119,15 @@ |
||
| 119 | 119 | private static function persistProperty(\ReflectionProperty $property, string $class, \Nkey\Caribu\Model\AbstractModel $object, string $namespace, bool $persist) |
| 120 | 120 | { |
| 121 | 121 | try { |
| 122 | - if ("" !== ($type = self::getAnnotatedType($property->getDocComment(), $namespace)) && ! self::isPrimitive($type)) { |
|
| 123 | - if (! $persist && self::isCascadeAnnotated($property->getDocComment())) { |
|
| 122 | + if ("" !== ($type = self::getAnnotatedType($property->getDocComment(), $namespace)) && !self::isPrimitive($type)) { |
|
| 123 | + if (!$persist && self::isCascadeAnnotated($property->getDocComment())) { |
|
| 124 | 124 | $persist = true; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | $rfMethod = new \ReflectionMethod($class, sprintf("get%s", ucfirst($property->getName()))); |
| 128 | 128 | $entity = $rfMethod->invoke($object); |
| 129 | 129 | if ($entity instanceof \Nkey\Caribu\Model\AbstractModel) { |
| 130 | - if (! $persist && count($pk = self::getAnnotatedPrimaryKey($type, $entity, false))) { |
|
| 130 | + if (!$persist && count($pk = self::getAnnotatedPrimaryKey($type, $entity, false))) { |
|
| 131 | 131 | list ($pkCol) = $pk; |
| 132 | 132 | if (is_empty($pk[$pkCol])) { |
| 133 | 133 | $persist = true; |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | |
| 152 | 152 | $type = self::getAnnotatedPropertyType($toClass, $property->getName(), $namespace); |
| 153 | 153 | |
| 154 | - if ("" === $type || self::isPrimitive($type) || ! class_exists($type)) { |
|
| 154 | + if ("" === $type || self::isPrimitive($type) || !class_exists($type)) { |
|
| 155 | 155 | return array( |
| 156 | 156 | $type, |
| 157 | 157 | $value |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | foreach ($rfClass->getProperties() as $property) { |
| 244 | 244 | $docComment = $property->getDocComment(); |
| 245 | 245 | |
| 246 | - if (! self::isIdAnnotated($docComment)) { |
|
| 246 | + if (!self::isIdAnnotated($docComment)) { |
|
| 247 | 247 | continue; |
| 248 | 248 | } |
| 249 | 249 | |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | |
| 256 | 256 | $primaryKey = $rfMethod->invoke($object); |
| 257 | 257 | |
| 258 | - if (! $onlyValue) { |
|
| 258 | + if (!$onlyValue) { |
|
| 259 | 259 | $primaryKey = array( |
| 260 | 260 | $columnName => $primaryKey |
| 261 | 261 | ); |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | private static function getAnnotatedType(string $comment, string $namespace = null): string |
| 284 | 284 | { |
| 285 | 285 | $matches = array(); |
| 286 | - if (! preg_match('/@var ([\w\\\\]+)/', $comment, $matches)) { |
|
| 286 | + if (!preg_match('/@var ([\w\\\\]+)/', $comment, $matches)) { |
|
| 287 | 287 | return ""; |
| 288 | 288 | } |
| 289 | 289 | |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | |
| 296 | 296 | $type = self::fullQualifiedName($namespace, $type); |
| 297 | 297 | |
| 298 | - if (! class_exists($type)) { |
|
| 298 | + if (!class_exists($type)) { |
|
| 299 | 299 | throw new OrmException("Annotated type {type} could not be found nor loaded", array( |
| 300 | 300 | 'type' => $matches[1] |
| 301 | 301 | )); |
@@ -280,7 +280,7 @@ |
||
| 280 | 280 | { |
| 281 | 281 | $mappingOptions = array(); |
| 282 | 282 | foreach (explode(',', $mappedBy) as $mappingOption) { |
| 283 | - if(empty($mappingOption)) continue; |
|
| 283 | + if(empty($mappingOption)) continue; |
|
| 284 | 284 | |
| 285 | 285 | list ($option, $value) = preg_split('/=/', $mappingOption); |
| 286 | 286 | $mappingOptions[$option] = $value; |
@@ -51,13 +51,13 @@ discard block |
||
| 51 | 51 | $rfToClass = new \ReflectionClass($toClass); |
| 52 | 52 | |
| 53 | 53 | foreach (get_object_vars($from) as $property => $value) { |
| 54 | - if (! strpos($property, '.')) { |
|
| 54 | + if (!strpos($property, '.')) { |
|
| 55 | 55 | continue; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | list ($toProperty, $column) = explode('.', $property); |
| 59 | 59 | |
| 60 | - if (! $rfToClass->hasProperty($toProperty)) { |
|
| 60 | + if (!$rfToClass->hasProperty($toProperty)) { |
|
| 61 | 61 | continue; |
| 62 | 62 | } |
| 63 | 63 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | * @throws OrmException |
| 94 | 94 | * @throws PDOException |
| 95 | 95 | */ |
| 96 | - private static function injectMappedBy(string $toClass, AbstractModel &$object, Orm $orm) |
|
| 96 | + private static function injectMappedBy(string $toClass, AbstractModel & $object, Orm $orm) |
|
| 97 | 97 | { |
| 98 | 98 | try { |
| 99 | 99 | $rfToClass = new \ReflectionClass($toClass); |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | return true; |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - if (! self::isPrimitive($type) && class_exists($type) && ! $value instanceof $type) { |
|
| 228 | + if (!self::isPrimitive($type) && class_exists($type) && !$value instanceof $type) { |
|
| 229 | 229 | return false; |
| 230 | 230 | } |
| 231 | 231 | |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | $rfMethod->invoke($result, self::convertType($type, $value)); |
| 260 | 260 | } else { |
| 261 | 261 | foreach ($resultClass->getProperties() as $resultClassProperty) { |
| 262 | - if (! self::assignAnnotatedPropertyValue($result, $resultClassProperty, $resultClass, $propertyName, $value)) { |
|
| 262 | + if (!self::assignAnnotatedPropertyValue($result, $resultClassProperty, $resultClass, $propertyName, $value)) { |
|
| 263 | 263 | break; |
| 264 | 264 | } |
| 265 | 265 | } |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | { |
| 281 | 281 | $mappingOptions = array(); |
| 282 | 282 | foreach (explode(',', $mappedBy) as $mappingOption) { |
| 283 | - if(empty($mappingOption)) continue; |
|
| 283 | + if (empty($mappingOption)) continue; |
|
| 284 | 284 | |
| 285 | 285 | list ($option, $value) = preg_split('/=/', $mappingOption); |
| 286 | 286 | $mappingOptions[$option] = $value; |
@@ -280,7 +280,9 @@ |
||
| 280 | 280 | { |
| 281 | 281 | $mappingOptions = array(); |
| 282 | 282 | foreach (explode(',', $mappedBy) as $mappingOption) { |
| 283 | - if(empty($mappingOption)) continue; |
|
| 283 | + if(empty($mappingOption)) { |
|
| 284 | + continue; |
|
| 285 | + } |
|
| 284 | 286 | |
| 285 | 287 | list ($option, $value) = preg_split('/=/', $mappingOption); |
| 286 | 288 | $mappingOptions[$option] = $value; |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | $limits = self::parseLimits($limit, $startFrom); |
| 47 | 47 | |
| 48 | - if ($orderBy && ! stristr($orderBy, 'ORDER BY ')) { |
|
| 48 | + if ($orderBy && !stristr($orderBy, 'ORDER BY ')) { |
|
| 49 | 49 | $orderBy = sprintf("ORDER BY %s%s%s", $escapeSign, $orderBy, $escapeSign); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | } elseif (strtoupper(substr($criteria[$criterion], 0, 7)) == 'BETWEEN') { |
| 138 | 138 | $start = $end = null; |
| 139 | 139 | sscanf(strtoupper($criteria[$criterion]), "BETWEEN %s AND %s", $start, $end); |
| 140 | - if (! $start || ! $end) { |
|
| 140 | + if (!$start || !$end) { |
|
| 141 | 141 | throw new OrmException("Invalid range for between"); |
| 142 | 142 | } |
| 143 | 143 | $wheres[] = sprintf("%s BETWEEN %s AND %s", self::escapeCriterion($criterion, $escapeSign), $start, $end); |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | if ($conditions) { |
| 167 | 167 | $and = substr($where, 0, 3) == 'OR ' ? " " : " AND "; |
| 168 | 168 | } |
| 169 | - $conditions .= $and . $where; |
|
| 169 | + $conditions .= $and.$where; |
|
| 170 | 170 | } |
| 171 | 171 | $wheres = sprintf("WHERE %s", $conditions); |
| 172 | 172 | } else { |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | { |
| 261 | 261 | $class = new \ReflectionClass($className); |
| 262 | 262 | $simpleCriterion = self::getSimpleCriterionName($criterion); |
| 263 | - if (! $class->hasProperty($simpleCriterion)) { |
|
| 263 | + if (!$class->hasProperty($simpleCriterion)) { |
|
| 264 | 264 | return $criterion; |
| 265 | 265 | } |
| 266 | 266 | |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | $propertyClass = ""; |
| 324 | 324 | // search the type of property value |
| 325 | 325 | if ("" !== ($type = self::getAnnotatedType($rfProperty->getDocComment(), $rf->getNamespaceName()))) { |
| 326 | - if (! self::isPrimitive($type) && class_exists($type)) { |
|
| 326 | + if (!self::isPrimitive($type) && class_exists($type)) { |
|
| 327 | 327 | $propertyClass = $type; |
| 328 | 328 | } |
| 329 | 329 | } |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | $toThrow = OrmException::fromPrevious($ex, $message, $code); |
| 33 | 33 | |
| 34 | 34 | try { |
| 35 | - if ($statement != null && $statement instanceof \PDOStatement) { |
|
| 35 | + if ($statement != null && $statement instanceof \PDOStatement) { |
|
| 36 | 36 | $statement->closeCursor(); |
| 37 | 37 | } |
| 38 | 38 | unset($statement); |