@@ -50,7 +50,6 @@ |
||
| 50 | 50 | /** |
| 51 | 51 | * Constructs new instance of SQLSrverExpressionProvider for NorthWind DB |
| 52 | 52 | * |
| 53 | - * @param string $iterName The name of the iterator |
|
| 54 | 53 | */ |
| 55 | 54 | public function __construct() |
| 56 | 55 | { |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | public function onLogicalExpression($expressionType, $left, $right) |
| 90 | 90 | { |
| 91 | - switch($expressionType) { |
|
| 91 | + switch ($expressionType) { |
|
| 92 | 92 | case ExpressionType::AND_LOGICAL: |
| 93 | 93 | return $this->_prepareBinaryExpression(self::LOGICAL_AND, $left, $right); |
| 94 | 94 | break; |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | */ |
| 112 | 112 | public function onArithmeticExpression($expressionType, $left, $right) |
| 113 | 113 | { |
| 114 | - switch($expressionType) { |
|
| 114 | + switch ($expressionType) { |
|
| 115 | 115 | case ExpressionType::MULTIPLY: |
| 116 | 116 | return $this->_prepareBinaryExpression(self::MULTIPLY, $left, $right); |
| 117 | 117 | break; |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | */ |
| 144 | 144 | public function onRelationalExpression($expressionType, $left, $right) |
| 145 | 145 | { |
| 146 | - switch($expressionType) { |
|
| 146 | + switch ($expressionType) { |
|
| 147 | 147 | case ExpressionType::GREATERTHAN: |
| 148 | 148 | return $this->_prepareBinaryExpression(self::GREATERTHAN, $left, $right); |
| 149 | 149 | break; |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | */ |
| 182 | 182 | public function onUnaryExpression($expressionType, $child) |
| 183 | 183 | { |
| 184 | - switch($expressionType) { |
|
| 184 | + switch ($expressionType) { |
|
| 185 | 185 | case ExpressionType::NEGATE: |
| 186 | 186 | return $this->_prepareUnaryExpression(self::NEGATE, $child); |
| 187 | 187 | break; |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | */ |
| 298 | 298 | public function onFunctionCallExpression($functionDescription, $params) |
| 299 | 299 | { |
| 300 | - switch($functionDescription->functionName) { |
|
| 300 | + switch ($functionDescription->functionName) { |
|
| 301 | 301 | case ODataConstants::STRFUN_COMPARE: |
| 302 | 302 | return "STRCMP($params[0]; $params[1])"; |
| 303 | 303 | break; |
@@ -423,12 +423,12 @@ discard block |
||
| 423 | 423 | $operator = "!".$operator; |
| 424 | 424 | } |
| 425 | 425 | return self::OPEN_BRAKET |
| 426 | - . $str[0] . ' ' . $operator |
|
| 427 | - . ' ' . $str[1] . self::CLOSE_BRACKET; |
|
| 426 | + . $str[0].' '.$operator |
|
| 427 | + . ' '.$str[1].self::CLOSE_BRACKET; |
|
| 428 | 428 | } else { |
| 429 | 429 | return self::OPEN_BRAKET |
| 430 | - . $str[0] . ' ' . $operator |
|
| 431 | - . ' ' . $str[1] . self::CLOSE_BRACKET; |
|
| 430 | + . $str[0].' '.$operator |
|
| 431 | + . ' '.$str[1].self::CLOSE_BRACKET; |
|
| 432 | 432 | } |
| 433 | 433 | } |
| 434 | 434 | |
@@ -447,19 +447,19 @@ discard block |
||
| 447 | 447 | $operator = "!".$operator; |
| 448 | 448 | } |
| 449 | 449 | return self::OPEN_BRAKET |
| 450 | - . $str[0] . ' ' . $operator |
|
| 451 | - . ' ' . $str[1] . self::CLOSE_BRACKET; |
|
| 450 | + . $str[0].' '.$operator |
|
| 451 | + . ' '.$str[1].self::CLOSE_BRACKET; |
|
| 452 | 452 | } else { |
| 453 | 453 | return self::OPEN_BRAKET |
| 454 | - . $str[0] . ' ' . $operator |
|
| 455 | - . ' ' . $str[1] . self::CLOSE_BRACKET; |
|
| 454 | + . $str[0].' '.$operator |
|
| 455 | + . ' '.$str[1].self::CLOSE_BRACKET; |
|
| 456 | 456 | } |
| 457 | 457 | } |
| 458 | 458 | |
| 459 | 459 | return |
| 460 | 460 | self::OPEN_BRAKET |
| 461 | - . $left . ' ' . $operator |
|
| 462 | - . ' ' . $right . self::CLOSE_BRACKET; |
|
| 461 | + . $left.' '.$operator |
|
| 462 | + . ' '.$right.self::CLOSE_BRACKET; |
|
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | /** |
@@ -472,6 +472,6 @@ discard block |
||
| 472 | 472 | */ |
| 473 | 473 | private function _prepareUnaryExpression($operator, $child) |
| 474 | 474 | { |
| 475 | - return $operator . self::OPEN_BRAKET . $child . self::CLOSE_BRACKET; |
|
| 475 | + return $operator.self::OPEN_BRAKET.$child.self::CLOSE_BRACKET; |
|
| 476 | 476 | } |
| 477 | 477 | } |
@@ -172,7 +172,7 @@ |
||
| 172 | 172 | * |
| 173 | 173 | * @throws InvalidOperationException |
| 174 | 174 | * |
| 175 | - * @return NorthWindMetadata |
|
| 175 | + * @return SimpleMetadataProvider |
|
| 176 | 176 | */ |
| 177 | 177 | public static function create() |
| 178 | 178 | { |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | * |
| 419 | 419 | * @param array $record each row of customer |
| 420 | 420 | * |
| 421 | - * @return object |
|
| 421 | + * @return Customer |
|
| 422 | 422 | */ |
| 423 | 423 | private function _serializeCustomer($record) |
| 424 | 424 | { |
@@ -461,7 +461,8 @@ discard block |
||
| 461 | 461 | * |
| 462 | 462 | * @param Object &$src source |
| 463 | 463 | * @param Object &$target target |
| 464 | - * @param Object $tag tag |
|
| 464 | + * @param integer $tag tag |
|
| 465 | + * @param Address $target |
|
| 465 | 466 | * |
| 466 | 467 | * @return void |
| 467 | 468 | */ |
@@ -503,7 +504,7 @@ discard block |
||
| 503 | 504 | * |
| 504 | 505 | * @param array $record each row of customer |
| 505 | 506 | * |
| 506 | - * @return object |
|
| 507 | + * @return Order |
|
| 507 | 508 | */ |
| 508 | 509 | private function _serializeOrder($record) |
| 509 | 510 | { |
@@ -547,7 +548,7 @@ discard block |
||
| 547 | 548 | * |
| 548 | 549 | * @param array $record each row of employee |
| 549 | 550 | * |
| 550 | - * @return object |
|
| 551 | + * @return Employee |
|
| 551 | 552 | */ |
| 552 | 553 | private function _serializeEmployee($record) |
| 553 | 554 | { |
@@ -595,7 +596,7 @@ discard block |
||
| 595 | 596 | * |
| 596 | 597 | * @param array $record each row of order detail |
| 597 | 598 | * |
| 598 | - * @return object |
|
| 599 | + * @return Order_Details |
|
| 599 | 600 | */ |
| 600 | 601 | private function _serializeOrderDetail($record) |
| 601 | 602 | { |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | $this->_connectionHandle = sqlsrv_connect(SERVER, $connectionInfo); |
| 50 | - if ( $this->_connectionHandle ) { |
|
| 50 | + if ($this->_connectionHandle) { |
|
| 51 | 51 | } else { |
| 52 | 52 | $errorAsString = self::_getSQLSRVError(); |
| 53 | 53 | throw ODataException::createInternalServerError($errorAsString); |
@@ -92,15 +92,15 @@ discard block |
||
| 92 | 92 | * @return array(Object) |
| 93 | 93 | */ |
| 94 | 94 | public function getResourceSet(ResourceSet $resourceSet, $filterOption = null, |
| 95 | - $select=null, $orderby=null, $top=null, $skip=null |
|
| 95 | + $select = null, $orderby = null, $top = null, $skip = null |
|
| 96 | 96 | ) { |
| 97 | - $resourceSetName = $resourceSet->getName(); |
|
| 97 | + $resourceSetName = $resourceSet->getName(); |
|
| 98 | 98 | if ($resourceSetName !== 'Customers' |
| 99 | 99 | && $resourceSetName !== 'Orders' |
| 100 | 100 | && $resourceSetName !== 'Order_Details' |
| 101 | 101 | && $resourceSetName !== 'Employees' |
| 102 | 102 | ) { |
| 103 | - throw ODataException::createInternalServerError('(NorthWindQueryProvider) Unknown resource set ' . $resourceSetName . '! Contact service provider'); |
|
| 103 | + throw ODataException::createInternalServerError('(NorthWindQueryProvider) Unknown resource set '.$resourceSetName.'! Contact service provider'); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | if ($resourceSetName === 'Order_Details') { |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | $query = "SELECT * FROM [$resourceSetName]"; |
| 111 | 111 | if ($filterOption != null) { |
| 112 | - $query .= ' WHERE ' . $filterOption; |
|
| 112 | + $query .= ' WHERE '.$filterOption; |
|
| 113 | 113 | } |
| 114 | 114 | $stmt = sqlsrv_query($this->_connectionHandle, $query); |
| 115 | 115 | if ($stmt === false) { |
@@ -146,14 +146,14 @@ discard block |
||
| 146 | 146 | */ |
| 147 | 147 | public function getResourceFromResourceSet(ResourceSet $resourceSet, KeyDescriptor $keyDescriptor) |
| 148 | 148 | { |
| 149 | - $resourceSetName = $resourceSet->getName(); |
|
| 149 | + $resourceSetName = $resourceSet->getName(); |
|
| 150 | 150 | if ($resourceSetName !== 'Customers' |
| 151 | 151 | && $resourceSetName !== 'Orders' |
| 152 | 152 | && $resourceSetName !== 'Order_Details' |
| 153 | 153 | && $resourceSetName !== 'Products' |
| 154 | 154 | && $resourceSetName !== 'Employees' |
| 155 | 155 | ) { |
| 156 | - die('(NorthWindQueryProvider) Unknown resource set ' . $resourceSetName); |
|
| 156 | + die('(NorthWindQueryProvider) Unknown resource set '.$resourceSetName); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | if ($resourceSetName === 'Order_Details') { |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | $namedKeyValues = $keyDescriptor->getValidatedNamedValues(); |
| 164 | 164 | $condition = null; |
| 165 | 165 | foreach ($namedKeyValues as $key => $value) { |
| 166 | - $condition .= $key . ' = ' . $value[0] . ' and '; |
|
| 166 | + $condition .= $key.' = '.$value[0].' and '; |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | $len = strlen($condition); |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | $result = null; |
| 184 | - while ( $record = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) { |
|
| 184 | + while ($record = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) { |
|
| 185 | 185 | switch ($resourceSetName) { |
| 186 | 186 | case 'Customers': |
| 187 | 187 | $result = $this->_serializeCustomer($record); |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | $navigationPropName = $targetProperty->getName(); |
| 228 | 228 | $key = null; |
| 229 | 229 | foreach ($keyDescriptor->getValidatedNamedValues() as $keyName => $valueDescription) { |
| 230 | - $key = $key . $keyName . '=' . $valueDescription[0] . ' and '; |
|
| 230 | + $key = $key.$keyName.'='.$valueDescription[0].' and '; |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | $key = rtrim($key, ' and '); |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | |
| 243 | 243 | $result = $this->_serializeOrders($stmt); |
| 244 | 244 | } else { |
| 245 | - die('Customer does not have navigation porperty with name: ' . $navigationPropName); |
|
| 245 | + die('Customer does not have navigation porperty with name: '.$navigationPropName); |
|
| 246 | 246 | } |
| 247 | 247 | } else if ($srcClass === 'Order') { |
| 248 | 248 | if ($navigationPropName === 'Order_Details') { |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | |
| 256 | 256 | $result = $this->_serializeOrderDetails($stmt); |
| 257 | 257 | } else { |
| 258 | - die('Order does not have navigation porperty with name: ' . $navigationPropName); |
|
| 258 | + die('Order does not have navigation porperty with name: '.$navigationPropName); |
|
| 259 | 259 | } |
| 260 | 260 | } |
| 261 | 261 | |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | ResourceSet $targetResourceSet, |
| 288 | 288 | ResourceProperty $targetProperty, |
| 289 | 289 | $filterOption = null, |
| 290 | - $select=null, $orderby=null, $top=null, $skip=null |
|
| 290 | + $select = null, $orderby = null, $top = null, $skip = null |
|
| 291 | 291 | ) { |
| 292 | 292 | $result = array(); |
| 293 | 293 | $srcClass = get_class($sourceEntityInstance); |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | if ($navigationPropName === 'Orders') { |
| 297 | 297 | $query = "SELECT * FROM Orders WHERE CustomerID = '$sourceEntityInstance->CustomerID'"; |
| 298 | 298 | if ($filterOption != null) { |
| 299 | - $query .= ' AND ' . $filterOption; |
|
| 299 | + $query .= ' AND '.$filterOption; |
|
| 300 | 300 | } |
| 301 | 301 | $stmt = sqlsrv_query($this->_connectionHandle, $query); |
| 302 | 302 | if ($stmt === false) { |
@@ -306,13 +306,13 @@ discard block |
||
| 306 | 306 | |
| 307 | 307 | $result = $this->_serializeOrders($stmt); |
| 308 | 308 | } else { |
| 309 | - die('Customer does not have navigation porperty with name: ' . $navigationPropName); |
|
| 309 | + die('Customer does not have navigation porperty with name: '.$navigationPropName); |
|
| 310 | 310 | } |
| 311 | 311 | } else if ($srcClass === 'Order') { |
| 312 | 312 | if ($navigationPropName === 'Order_Details') { |
| 313 | 313 | $query = "SELECT * FROM [Order Details] WHERE OrderID = $sourceEntityInstance->OrderID"; |
| 314 | 314 | if ($filterOption != null) { |
| 315 | - $query .= ' AND ' . $filterOption; |
|
| 315 | + $query .= ' AND '.$filterOption; |
|
| 316 | 316 | } |
| 317 | 317 | $stmt = sqlsrv_query($this->_connectionHandle, $query); |
| 318 | 318 | if ($stmt === false) { |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | |
| 323 | 323 | $result = $this->_serializeOrderDetails($stmt); |
| 324 | 324 | } else { |
| 325 | - die('Order does not have navigation porperty with name: ' . $navigationPropName); |
|
| 325 | + die('Order does not have navigation porperty with name: '.$navigationPropName); |
|
| 326 | 326 | } |
| 327 | 327 | } |
| 328 | 328 | |
@@ -362,13 +362,13 @@ discard block |
||
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | if (!sqlsrv_has_rows($stmt)) { |
| 365 | - $result = null; |
|
| 365 | + $result = null; |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | $result = $this->_serializeCustomer(sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)); |
| 369 | 369 | } |
| 370 | 370 | } else { |
| 371 | - die('Customer does not have navigation porperty with name: ' . $navigationPropName); |
|
| 371 | + die('Customer does not have navigation porperty with name: '.$navigationPropName); |
|
| 372 | 372 | } |
| 373 | 373 | } else if ($srcClass === 'Order_Details') { |
| 374 | 374 | if ($navigationPropName === 'Order') { |
@@ -383,13 +383,13 @@ discard block |
||
| 383 | 383 | } |
| 384 | 384 | |
| 385 | 385 | if (!sqlsrv_has_rows($stmt)) { |
| 386 | - $result = null; |
|
| 386 | + $result = null; |
|
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | $result = $this->_serializeOrder(sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)); |
| 390 | 390 | } |
| 391 | 391 | } else { |
| 392 | - die('Order_Details does not have navigation porperty with name: ' . $navigationPropName); |
|
| 392 | + die('Order_Details does not have navigation porperty with name: '.$navigationPropName); |
|
| 393 | 393 | } |
| 394 | 394 | } |
| 395 | 395 | |
@@ -437,14 +437,14 @@ discard block |
||
| 437 | 437 | $customer->Address->Country = $record['Country']; |
| 438 | 438 | //Set alternate address |
| 439 | 439 | $customer->Address->AltAddress = new Address(); |
| 440 | - $customer->Address->AltAddress->StreetName = 'ALT_' . $customer->Address->StreetName; |
|
| 441 | - $customer->Address->AltAddress->City = 'ALT_' . $customer->Address->City; |
|
| 442 | - $customer->Address->AltAddress->Region = 'ALT_' . $customer->Address->Region; |
|
| 443 | - $customer->Address->AltAddress->PostalCode = 'ALT_' . $customer->Address->PostalCode; |
|
| 444 | - $customer->Address->AltAddress->Country = 'ALT_' . $customer->Address->Country; |
|
| 440 | + $customer->Address->AltAddress->StreetName = 'ALT_'.$customer->Address->StreetName; |
|
| 441 | + $customer->Address->AltAddress->City = 'ALT_'.$customer->Address->City; |
|
| 442 | + $customer->Address->AltAddress->Region = 'ALT_'.$customer->Address->Region; |
|
| 443 | + $customer->Address->AltAddress->PostalCode = 'ALT_'.$customer->Address->PostalCode; |
|
| 444 | + $customer->Address->AltAddress->Country = 'ALT_'.$customer->Address->Country; |
|
| 445 | 445 | $customer->EmailAddresses = array(); |
| 446 | 446 | for ($i = 1; $i < 4; $i++) { |
| 447 | - $customer->EmailAddresses[] = $customer->CustomerID . $i . '@live.com'; |
|
| 447 | + $customer->EmailAddresses[] = $customer->CustomerID.$i.'@live.com'; |
|
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | $customer->OtherAddresses = array(); |
@@ -467,18 +467,18 @@ discard block |
||
| 467 | 467 | */ |
| 468 | 468 | private function _copyAddress(&$src, &$target, $tag) |
| 469 | 469 | { |
| 470 | - $target->StreetName = $src->StreetName . $tag; |
|
| 471 | - $target->City = $src->City . $tag; |
|
| 472 | - $target->Region = $src->Region . $tag; |
|
| 473 | - $target->PostalCode = $src->PostalCode . $tag; |
|
| 474 | - $target->Country = $src->Country . $tag; |
|
| 470 | + $target->StreetName = $src->StreetName.$tag; |
|
| 471 | + $target->City = $src->City.$tag; |
|
| 472 | + $target->Region = $src->Region.$tag; |
|
| 473 | + $target->PostalCode = $src->PostalCode.$tag; |
|
| 474 | + $target->Country = $src->Country.$tag; |
|
| 475 | 475 | |
| 476 | 476 | $target->AltAddress = new Address(); |
| 477 | - $target->AltAddress->StreetName = $target->AltAddress->StreetName . $tag; |
|
| 478 | - $target->AltAddress->City = $target->AltAddress->City . $tag; |
|
| 479 | - $target->AltAddress->Region = $target->AltAddress->Region . $tag; |
|
| 480 | - $target->AltAddress->PostalCode = $target->AltAddress->PostalCode . $tag; |
|
| 481 | - $target->AltAddress->Country = $target->AltAddress->Country . $tag; |
|
| 477 | + $target->AltAddress->StreetName = $target->AltAddress->StreetName.$tag; |
|
| 478 | + $target->AltAddress->City = $target->AltAddress->City.$tag; |
|
| 479 | + $target->AltAddress->Region = $target->AltAddress->Region.$tag; |
|
| 480 | + $target->AltAddress->PostalCode = $target->AltAddress->PostalCode.$tag; |
|
| 481 | + $target->AltAddress->Country = $target->AltAddress->Country.$tag; |
|
| 482 | 482 | } |
| 483 | 483 | |
| 484 | 484 | /** |
@@ -491,7 +491,7 @@ discard block |
||
| 491 | 491 | private function _serializeOrders($result) |
| 492 | 492 | { |
| 493 | 493 | $orders = array(); |
| 494 | - while ( $record = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC)) { |
|
| 494 | + while ($record = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC)) { |
|
| 495 | 495 | $orders[] = $this->_serializeOrder($record); |
| 496 | 496 | } |
| 497 | 497 | |
@@ -511,9 +511,9 @@ discard block |
||
| 511 | 511 | $order->OrderID = $record['OrderID']; |
| 512 | 512 | $order->CustomerID = $record['CustomerID']; |
| 513 | 513 | $order->EmployeeID = $record['EmployeeID']; |
| 514 | - $order->OrderDate = !is_null($record['OrderDate']) ? $record['OrderDate']->format('Y-m-d\TH:i:s'): null; |
|
| 515 | - $order->RequiredDate = !is_null($record['RequiredDate']) ? $record['RequiredDate']->format('Y-m-d\TH:i:s'): null; |
|
| 516 | - $order->ShippedDate = !is_null($record['ShippedDate']) ? $record['ShippedDate']->format('Y-m-d\TH:i:s'): null; |
|
| 514 | + $order->OrderDate = !is_null($record['OrderDate']) ? $record['OrderDate']->format('Y-m-d\TH:i:s') : null; |
|
| 515 | + $order->RequiredDate = !is_null($record['RequiredDate']) ? $record['RequiredDate']->format('Y-m-d\TH:i:s') : null; |
|
| 516 | + $order->ShippedDate = !is_null($record['ShippedDate']) ? $record['ShippedDate']->format('Y-m-d\TH:i:s') : null; |
|
| 517 | 517 | $order->ShipVia = $record['ShipVia']; |
| 518 | 518 | $order->Freight = $record['Freight']; |
| 519 | 519 | $order->ShipName = $record['ShipName']; |
@@ -557,8 +557,8 @@ discard block |
||
| 557 | 557 | $employee->LastName = $record['LastName']; |
| 558 | 558 | $employee->Title = $record['Title']; |
| 559 | 559 | $employee->TitleOfCourtesy = $record['TitleOfCourtesy']; |
| 560 | - $employee->BirthDate = !is_null($record['BirthDate']) ? $record['BirthDate']->format('Y-m-d\TH:i:s'): null; |
|
| 561 | - $employee->HireDate = !is_null($record['HireDate']) ? $record['HireDate']->format('Y-m-d\TH:i:s'): null; |
|
| 560 | + $employee->BirthDate = !is_null($record['BirthDate']) ? $record['BirthDate']->format('Y-m-d\TH:i:s') : null; |
|
| 561 | + $employee->HireDate = !is_null($record['HireDate']) ? $record['HireDate']->format('Y-m-d\TH:i:s') : null; |
|
| 562 | 562 | $employee->Address = $record['Address']; |
| 563 | 563 | $employee->City = $record['City']; |
| 564 | 564 | $employee->Region = $record['Region']; |
@@ -569,7 +569,7 @@ discard block |
||
| 569 | 569 | $employee->Notes = $record['Notes']; |
| 570 | 570 | $employee->ReportsTo = $record['ReportsTo']; |
| 571 | 571 | //$employee->Photo = $record['Photo']; |
| 572 | - $employee->Emails = array ($employee->FirstName . '@hotmail.com', $employee->FirstName . '@live.com'); |
|
| 572 | + $employee->Emails = array($employee->FirstName.'@hotmail.com', $employee->FirstName.'@live.com'); |
|
| 573 | 573 | return $employee; |
| 574 | 574 | } |
| 575 | 575 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * @param WebOperationContext $operationContext A reference to the context |
| 49 | 49 | * for the current operation. |
| 50 | 50 | * |
| 51 | - * @return mixed A valid default stream which is associated with the entity, |
|
| 51 | + * @return string A valid default stream which is associated with the entity, |
|
| 52 | 52 | * Null should never be returned from this method. |
| 53 | 53 | * |
| 54 | 54 | * @throws ODataException if a valid stream cannot be returned. |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | * conditional request. |
| 213 | 213 | * @param WebOperationContext $operationContext A reference to the context for the current operation. |
| 214 | 214 | * |
| 215 | - * @return mixed A valid stream the data service use to query/read a named stream which is |
|
| 215 | + * @return string A valid stream the data service use to query/read a named stream which is |
|
| 216 | 216 | * associated with the $entity. Null may be returned from this method if the requested named |
| 217 | 217 | * stream has not been created since the creation of $entity. The data service will respond |
| 218 | 218 | * with 204 if this method returns null. |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | $filePath = self::IMAGE_PATH_ROOT |
| 79 | - . 'Employee_' . $entity->EmployeeID |
|
| 79 | + . 'Employee_'.$entity->EmployeeID |
|
| 80 | 80 | . '.jpg'; |
| 81 | 81 | if (file_exists($filePath)) { |
| 82 | 82 | $handle = fopen($filePath, 'r'); |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | $lastModifiedTime = null; |
| 155 | - $filePath = self::IMAGE_PATH_ROOT . 'Employee_' . $entity->EmployeeID . '.jpg'; |
|
| 155 | + $filePath = self::IMAGE_PATH_ROOT.'Employee_'.$entity->EmployeeID.'.jpg'; |
|
| 156 | 156 | if (file_exists($filePath)) { |
| 157 | 157 | $lastModifiedTime = date("\"m-d-Y H:i:s\"", filemtime($filePath)); |
| 158 | 158 | } else { |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | throw new ODataException('Internal Server Error.', 500); |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - $filePath = self::IMAGE_PATH_ROOT . 'Employee_' |
|
| 239 | + $filePath = self::IMAGE_PATH_ROOT.'Employee_' |
|
| 240 | 240 | . $entity->EmployeeID |
| 241 | 241 | . '_' |
| 242 | 242 | . $resourceStreamInfo->getName() |
@@ -76,7 +76,6 @@ discard block |
||
| 76 | 76 | * |
| 77 | 77 | * @param ResourceSet $resourceSet The entity set whose |
| 78 | 78 | * entities needs to be fetched |
| 79 | - * @param string $filterOption Contains the filter condition |
|
| 80 | 79 | * @param string $select For future purpose,no need to pass it |
| 81 | 80 | * @param string $orderby For future purpose,no need to pass it |
| 82 | 81 | * @param string $top For future purpose,no need to pass it |
@@ -273,7 +272,6 @@ discard block |
||
| 273 | 272 | * the navigation property |
| 274 | 273 | * @param ResourceProperty $targetProperty The navigation property to be |
| 275 | 274 | * retrieved |
| 276 | - * @param string $filterOption Contains the filter condition |
|
| 277 | 275 | * @param string $select For future purpose,no need to pass it |
| 278 | 276 | * @param string $orderby For future purpose,no need to pass it |
| 279 | 277 | * @param string $top For future purpose,no need to pass it |
@@ -662,7 +660,7 @@ discard block |
||
| 662 | 660 | /** |
| 663 | 661 | * Serialize the mysql result array into Post objects |
| 664 | 662 | * |
| 665 | - * @param array(array) $result result of the mysql query |
|
| 663 | + * @param resource $result result of the mysql query |
|
| 666 | 664 | * |
| 667 | 665 | * @return array(Object) |
| 668 | 666 | */ |
@@ -681,7 +679,7 @@ discard block |
||
| 681 | 679 | * |
| 682 | 680 | * @param array $record each post row |
| 683 | 681 | * |
| 684 | - * @return object |
|
| 682 | + * @return Post |
|
| 685 | 683 | */ |
| 686 | 684 | private function _serializePost($record) |
| 687 | 685 | { |
@@ -741,7 +739,7 @@ discard block |
||
| 741 | 739 | /** |
| 742 | 740 | * Serialize the mysql result array into Tag objects |
| 743 | 741 | * |
| 744 | - * @param array(array) $result result of the mysql query |
|
| 742 | + * @param resource $result result of the mysql query |
|
| 745 | 743 | * |
| 746 | 744 | * @return array(Object) |
| 747 | 745 | */ |
@@ -760,7 +758,7 @@ discard block |
||
| 760 | 758 | * |
| 761 | 759 | * @param array $record each tag row |
| 762 | 760 | * |
| 763 | - * @return object |
|
| 761 | + * @return Tag |
|
| 764 | 762 | */ |
| 765 | 763 | private function _serializeTag($record) |
| 766 | 764 | { |
@@ -775,7 +773,7 @@ discard block |
||
| 775 | 773 | /** |
| 776 | 774 | * Serialize the mysql result array into Category objects |
| 777 | 775 | * |
| 778 | - * @param array(array) $result result of the mysql query |
|
| 776 | + * @param resource $result result of the mysql query |
|
| 779 | 777 | * |
| 780 | 778 | * @return array(Object) |
| 781 | 779 | */ |
@@ -794,7 +792,7 @@ discard block |
||
| 794 | 792 | * |
| 795 | 793 | * @param array $record each category row |
| 796 | 794 | * |
| 797 | - * @return object |
|
| 795 | + * @return Category |
|
| 798 | 796 | */ |
| 799 | 797 | private function _serializeCategory($record) |
| 800 | 798 | { |
@@ -809,7 +807,7 @@ discard block |
||
| 809 | 807 | /** |
| 810 | 808 | * Serialize the mysql result array into Comment objects |
| 811 | 809 | * |
| 812 | - * @param array(array) $result mysql query result |
|
| 810 | + * @param resource $result mysql query result |
|
| 813 | 811 | * |
| 814 | 812 | * @return array(Object) |
| 815 | 813 | */ |
@@ -828,7 +826,7 @@ discard block |
||
| 828 | 826 | * |
| 829 | 827 | * @param array $record each comment row |
| 830 | 828 | * |
| 831 | - * @return object |
|
| 829 | + * @return Comment |
|
| 832 | 830 | */ |
| 833 | 831 | private function _serializeComment($record) |
| 834 | 832 | { |
@@ -867,7 +865,7 @@ discard block |
||
| 867 | 865 | /** |
| 868 | 866 | * Serialize the mysql result array into User objects |
| 869 | 867 | * |
| 870 | - * @param array(array) $result result of the mysql query |
|
| 868 | + * @param resource $result result of the mysql query |
|
| 871 | 869 | * |
| 872 | 870 | * @return array(Object) |
| 873 | 871 | */ |
@@ -886,7 +884,7 @@ discard block |
||
| 886 | 884 | * |
| 887 | 885 | * @param array $record each user row |
| 888 | 886 | * |
| 889 | - * @return object |
|
| 887 | + * @return User |
|
| 890 | 888 | */ |
| 891 | 889 | private function _serializeUser($record) |
| 892 | 890 | { |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | public function __construct() |
| 42 | 42 | { |
| 43 | 43 | $this->_connectionHandle = @mysql_connect(DB_HOST, DB_USER, DB_PASSWORD, true); |
| 44 | - if ( $this->_connectionHandle ) { |
|
| 44 | + if ($this->_connectionHandle) { |
|
| 45 | 45 | } else { |
| 46 | 46 | die(print_r(mysql_error(), true)); |
| 47 | 47 | } |
@@ -84,16 +84,16 @@ discard block |
||
| 84 | 84 | * |
| 85 | 85 | * @return array(Object) |
| 86 | 86 | */ |
| 87 | - public function getResourceSet(ResourceSet $resourceSet,$filter=null,$select=null,$orderby=null,$top=null,$skip=null) |
|
| 87 | + public function getResourceSet(ResourceSet $resourceSet, $filter = null, $select = null, $orderby = null, $top = null, $skip = null) |
|
| 88 | 88 | { |
| 89 | - $resourceSetName = $resourceSet->getName(); |
|
| 89 | + $resourceSetName = $resourceSet->getName(); |
|
| 90 | 90 | if ($resourceSetName !== 'Posts' |
| 91 | 91 | && $resourceSetName !== 'Tags' |
| 92 | 92 | && $resourceSetName !== 'Categories' |
| 93 | 93 | && $resourceSetName !== 'Comments' |
| 94 | 94 | && $resourceSetName !== 'Users' |
| 95 | 95 | ) { |
| 96 | - die('(WordPressQueryProvider) Unknown resource set ' . $resourceSetName); |
|
| 96 | + die('(WordPressQueryProvider) Unknown resource set '.$resourceSetName); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | |
@@ -167,14 +167,14 @@ discard block |
||
| 167 | 167 | */ |
| 168 | 168 | public function getResourceFromResourceSet(ResourceSet $resourceSet, KeyDescriptor $keyDescriptor) |
| 169 | 169 | { |
| 170 | - $resourceSetName = $resourceSet->getName(); |
|
| 170 | + $resourceSetName = $resourceSet->getName(); |
|
| 171 | 171 | if ($resourceSetName !== 'Posts' |
| 172 | 172 | && $resourceSetName !== 'Tags' |
| 173 | 173 | && $resourceSetName !== 'Categories' |
| 174 | 174 | && $resourceSetName !== 'Comments' |
| 175 | 175 | && $resourceSetName !== 'Users' |
| 176 | 176 | ) { |
| 177 | - die('(WordPressQueryProvider) Unknown resource set ' . $resourceSetName); |
|
| 177 | + die('(WordPressQueryProvider) Unknown resource set '.$resourceSetName); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | $namedKeyValues = $keyDescriptor->getValidatedNamedValues(); |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | $sourceEntityInstance, |
| 287 | 287 | ResourceSet $targetResourceSet, |
| 288 | 288 | ResourceProperty $targetProperty, |
| 289 | - $filter=null ,$select=null, $orderby=null, $top=null, $skip=null |
|
| 289 | + $filter = null, $select = null, $orderby = null, $top = null, $skip = null |
|
| 290 | 290 | ) { |
| 291 | 291 | $result = array(); |
| 292 | 292 | $srcClass = get_class($sourceEntityInstance); |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | $query .= " AND $filter"; |
| 308 | 308 | } |
| 309 | 309 | $stmt = mysql_query($query); |
| 310 | - if ( $stmt === false) { |
|
| 310 | + if ($stmt === false) { |
|
| 311 | 311 | die(mysql_error()); |
| 312 | 312 | } |
| 313 | 313 | |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | $query .= " AND $filter"; |
| 326 | 326 | } |
| 327 | 327 | $stmt = mysql_query($query); |
| 328 | - if ( $stmt === false) { |
|
| 328 | + if ($stmt === false) { |
|
| 329 | 329 | die(mysql_error()); |
| 330 | 330 | } |
| 331 | 331 | |
@@ -338,13 +338,13 @@ discard block |
||
| 338 | 338 | $query .= " AND $filter"; |
| 339 | 339 | } |
| 340 | 340 | $stmt = mysql_query($query); |
| 341 | - if ( $stmt === false) { |
|
| 341 | + if ($stmt === false) { |
|
| 342 | 342 | die(mysql_error()); |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | $result = $this->_serializeComments($stmt); |
| 346 | 346 | } else { |
| 347 | - die('Post does not have navigation porperty with name: ' . $navigationPropName); |
|
| 347 | + die('Post does not have navigation porperty with name: '.$navigationPropName); |
|
| 348 | 348 | } |
| 349 | 349 | break; |
| 350 | 350 | |
@@ -363,13 +363,13 @@ discard block |
||
| 363 | 363 | $query .= " AND $filter"; |
| 364 | 364 | } |
| 365 | 365 | $stmt = mysql_query($query); |
| 366 | - if ( $stmt === false) { |
|
| 366 | + if ($stmt === false) { |
|
| 367 | 367 | die(mysql_error()); |
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | $result = $this->_serializePosts($stmt); |
| 371 | 371 | } else { |
| 372 | - die('Tag does not have navigation porperty with name: ' . $navigationPropName); |
|
| 372 | + die('Tag does not have navigation porperty with name: '.$navigationPropName); |
|
| 373 | 373 | } |
| 374 | 374 | break; |
| 375 | 375 | |
@@ -388,18 +388,18 @@ discard block |
||
| 388 | 388 | $query .= " AND $filter"; |
| 389 | 389 | } |
| 390 | 390 | $stmt = mysql_query($query); |
| 391 | - if ( $stmt === false) { |
|
| 391 | + if ($stmt === false) { |
|
| 392 | 392 | die(mysql_error()); |
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | $result = $this->_serializePosts($stmt); |
| 396 | 396 | } else { |
| 397 | - die('Category does not have navigation porperty with name: ' . $navigationPropName); |
|
| 397 | + die('Category does not have navigation porperty with name: '.$navigationPropName); |
|
| 398 | 398 | } |
| 399 | 399 | break; |
| 400 | 400 | |
| 401 | 401 | case ($srcClass == 'Comment'): |
| 402 | - die('Comment does not have navigation porperty with name: ' . $navigationPropName); |
|
| 402 | + die('Comment does not have navigation porperty with name: '.$navigationPropName); |
|
| 403 | 403 | break; |
| 404 | 404 | |
| 405 | 405 | case ($srcClass == 'User'): |
@@ -412,7 +412,7 @@ discard block |
||
| 412 | 412 | $query .= " AND $filter"; |
| 413 | 413 | } |
| 414 | 414 | $stmt = mysql_query($query); |
| 415 | - if ( $stmt === false) { |
|
| 415 | + if ($stmt === false) { |
|
| 416 | 416 | die(mysql_error()); |
| 417 | 417 | } |
| 418 | 418 | |
@@ -425,13 +425,13 @@ discard block |
||
| 425 | 425 | $query .= " AND $filter"; |
| 426 | 426 | } |
| 427 | 427 | $stmt = mysql_query($query); |
| 428 | - if ( $stmt === false) { |
|
| 428 | + if ($stmt === false) { |
|
| 429 | 429 | die(mysql_error()); |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | $result = $this->_serializeComments($stmt); |
| 433 | 433 | } else { |
| 434 | - die('User does not have navigation porperty with name: ' . $navigationPropName); |
|
| 434 | + die('User does not have navigation porperty with name: '.$navigationPropName); |
|
| 435 | 435 | } |
| 436 | 436 | break; |
| 437 | 437 | } |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | $stmt = mysql_query($query); |
| 507 | 507 | $result = $this->_serializeComments($stmt); |
| 508 | 508 | } else { |
| 509 | - die('Post does not have navigation porperty with name: ' . $navigationPropName); |
|
| 509 | + die('Post does not have navigation porperty with name: '.$navigationPropName); |
|
| 510 | 510 | } |
| 511 | 511 | break; |
| 512 | 512 | |
@@ -525,7 +525,7 @@ discard block |
||
| 525 | 525 | $stmt = mysql_query($query); |
| 526 | 526 | $result = $this->_serializePosts($stmt); |
| 527 | 527 | } else { |
| 528 | - die('Tag does not have navigation porperty with name: ' . $navigationPropName); |
|
| 528 | + die('Tag does not have navigation porperty with name: '.$navigationPropName); |
|
| 529 | 529 | } |
| 530 | 530 | break; |
| 531 | 531 | |
@@ -544,12 +544,12 @@ discard block |
||
| 544 | 544 | $stmt = mysql_query($query); |
| 545 | 545 | $result = $this->_serializePosts($stmt); |
| 546 | 546 | } else { |
| 547 | - die('Category does not have navigation porperty with name: ' . $navigationPropName); |
|
| 547 | + die('Category does not have navigation porperty with name: '.$navigationPropName); |
|
| 548 | 548 | } |
| 549 | 549 | break; |
| 550 | 550 | |
| 551 | 551 | case ($srcClass == 'Comment'): |
| 552 | - die('Comment does not have navigation porperty with name: ' . $navigationPropName); |
|
| 552 | + die('Comment does not have navigation porperty with name: '.$navigationPropName); |
|
| 553 | 553 | break; |
| 554 | 554 | |
| 555 | 555 | case ($srcClass == 'User'): |
@@ -569,7 +569,7 @@ discard block |
||
| 569 | 569 | $stmt = mysql_query($query); |
| 570 | 570 | $result = $this->_serializeComments($stmt); |
| 571 | 571 | } else { |
| 572 | - die('User does not have navigation porperty with name: ' . $navigationPropName); |
|
| 572 | + die('User does not have navigation porperty with name: '.$navigationPropName); |
|
| 573 | 573 | } |
| 574 | 574 | break; |
| 575 | 575 | } |
@@ -606,15 +606,15 @@ discard block |
||
| 606 | 606 | $stmt = mysql_query($query); |
| 607 | 607 | $data = mysql_fetch_assoc($stmt); |
| 608 | 608 | $result = $this->_serializeUser($data); |
| 609 | - if ( $stmt === false) { |
|
| 609 | + if ($stmt === false) { |
|
| 610 | 610 | die(mysql_error()); |
| 611 | 611 | } |
| 612 | 612 | |
| 613 | 613 | if (!mysql_num_rows($stmt)) { |
| 614 | - $result = null; |
|
| 614 | + $result = null; |
|
| 615 | 615 | } |
| 616 | 616 | } else { |
| 617 | - die('Post does not have navigation porperty with name: ' . $navigationPropName); |
|
| 617 | + die('Post does not have navigation porperty with name: '.$navigationPropName); |
|
| 618 | 618 | } |
| 619 | 619 | break; |
| 620 | 620 | |
@@ -622,12 +622,12 @@ discard block |
||
| 622 | 622 | if ($navigationPropName == 'User') { |
| 623 | 623 | $query = "SELECT * FROM `wp_users` WHERE ID = $sourceEntityInstance->UserID"; |
| 624 | 624 | $stmt = mysql_query($query); |
| 625 | - if ( $stmt === false) { |
|
| 625 | + if ($stmt === false) { |
|
| 626 | 626 | die(mysql_error()); |
| 627 | 627 | } |
| 628 | 628 | |
| 629 | 629 | if (!mysql_num_rows($stmt)) { |
| 630 | - $result = null; |
|
| 630 | + $result = null; |
|
| 631 | 631 | } |
| 632 | 632 | |
| 633 | 633 | $data = mysql_fetch_assoc($stmt); |
@@ -639,18 +639,18 @@ discard block |
||
| 639 | 639 | ." AND wp_posts.post_status = 'publish'" |
| 640 | 640 | ." AND wp_posts.ID = $sourceEntityInstance->PostID"; |
| 641 | 641 | $stmt = mysql_query($query); |
| 642 | - if ( $stmt === false) { |
|
| 642 | + if ($stmt === false) { |
|
| 643 | 643 | die(mysql_error()); |
| 644 | 644 | } |
| 645 | 645 | |
| 646 | 646 | if (!mysql_num_rows($stmt)) { |
| 647 | - $result = null; |
|
| 647 | + $result = null; |
|
| 648 | 648 | } |
| 649 | 649 | |
| 650 | 650 | $data = mysql_fetch_assoc($stmt); |
| 651 | 651 | $result = $this->_serializePost($data); |
| 652 | 652 | } else { |
| 653 | - die('Comment does not have navigation porperty with name: ' . $navigationPropName); |
|
| 653 | + die('Comment does not have navigation porperty with name: '.$navigationPropName); |
|
| 654 | 654 | } |
| 655 | 655 | break; |
| 656 | 656 | } |
@@ -816,7 +816,7 @@ discard block |
||
| 816 | 816 | private function _serializeComments($result) |
| 817 | 817 | { |
| 818 | 818 | $comments = array(); |
| 819 | - while ( $record = mysql_fetch_array($result, MYSQL_ASSOC)) { |
|
| 819 | + while ($record = mysql_fetch_array($result, MYSQL_ASSOC)) { |
|
| 820 | 820 | $comments[] = $this->_serializeComment($record); |
| 821 | 821 | } |
| 822 | 822 | |
@@ -665,6 +665,7 @@ |
||
| 665 | 665 | * @param boolean &$needToSerializeResponse On return, this will contain |
| 666 | 666 | * True if response needs to be |
| 667 | 667 | * serialized, False otherwise. |
| 668 | + * @param boolean $needToSerializeResponse |
|
| 668 | 669 | * |
| 669 | 670 | * @return string|null The ETag for the entry object if it has eTag properties |
| 670 | 671 | * NULL otherwise. |
@@ -316,11 +316,11 @@ discard block |
||
| 316 | 316 | $registry->register(new JsonODataV1Writer()); |
| 317 | 317 | $registry->register(new AtomODataWriter($serviceURI)); |
| 318 | 318 | |
| 319 | - if($serviceVersion->compare(Version::v2()) > -1){ |
|
| 319 | + if ($serviceVersion->compare(Version::v2()) > -1) { |
|
| 320 | 320 | $registry->register(new JsonODataV2Writer()); |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | - if($serviceVersion->compare(Version::v3()) > -1){ |
|
| 323 | + if ($serviceVersion->compare(Version::v3()) > -1) { |
|
| 324 | 324 | $registry->register(new JsonLightODataWriter(JsonLightMetadataLevel::NONE(), $serviceURI)); |
| 325 | 325 | $registry->register(new JsonLightODataWriter(JsonLightMetadataLevel::MINIMAL(), $serviceURI)); |
| 326 | 326 | $registry->register(new JsonLightODataWriter(JsonLightMetadataLevel::FULL(), $serviceURI)); |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | |
| 352 | 352 | if (is_null($responseContentType) && $request->getTargetKind() != TargetKind::MEDIA_RESOURCE()) { |
| 353 | 353 | //the responseContentType can ONLY be null if it's a stream (media resource) and that stream is storing null as the content type |
| 354 | - throw new ODataException( Messages::unsupportedMediaType(), 415 ); |
|
| 354 | + throw new ODataException(Messages::unsupportedMediaType(), 415); |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | $odataModelInstance = null; |
@@ -518,10 +518,10 @@ discard block |
||
| 518 | 518 | |
| 519 | 519 | //if the $format header is present it overrides the accepts header |
| 520 | 520 | $format = $host->getQueryStringItem(ODataConstants::HTTPQUERY_STRING_FORMAT); |
| 521 | - if(!is_null($format)){ |
|
| 521 | + if (!is_null($format)) { |
|
| 522 | 522 | |
| 523 | 523 | //There's a strange edge case..if application/json is supplied and it's V3 |
| 524 | - if($format == MimeTypes::MIME_APPLICATION_JSON && $requestVersion == Version::v3()){ |
|
| 524 | + if ($format == MimeTypes::MIME_APPLICATION_JSON && $requestVersion == Version::v3()) { |
|
| 525 | 525 | //then it's actual minimalmetadata |
| 526 | 526 | //TODO: should this be done with the header text too? |
| 527 | 527 | $format = MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META; |
@@ -537,7 +537,7 @@ discard block |
||
| 537 | 537 | //getTargetKind doesn't deal with link resources directly and this can change things |
| 538 | 538 | $targetKind = $request->isLinkUri() ? TargetKind::LINK() : $request->getTargetKind(); |
| 539 | 539 | |
| 540 | - switch($targetKind){ |
|
| 540 | + switch ($targetKind) { |
|
| 541 | 541 | case TargetKind::METADATA(): |
| 542 | 542 | return HttpProcessUtility::selectMimeType( |
| 543 | 543 | $requestAcceptText, |
@@ -614,7 +614,7 @@ discard block |
||
| 614 | 614 | ); |
| 615 | 615 | |
| 616 | 616 | case TargetKind::MEDIA_RESOURCE(): |
| 617 | - if (!$request->isNamedStream() && !$request->getTargetResourceType()->isMediaLinkEntry()){ |
|
| 617 | + if (!$request->isNamedStream() && !$request->getTargetResourceType()->isMediaLinkEntry()) { |
|
| 618 | 618 | throw ODataException::createBadRequestError( |
| 619 | 619 | Messages::badRequestInvalidUriForMediaResource( |
| 620 | 620 | $host->getAbsoluteRequestUri()->getUrlAsString() |
@@ -648,7 +648,7 @@ discard block |
||
| 648 | 648 | |
| 649 | 649 | |
| 650 | 650 | //If we got here, we just don't know what it is... |
| 651 | - throw new ODataException( Messages::unsupportedMediaType(), 415 ); |
|
| 651 | + throw new ODataException(Messages::unsupportedMediaType(), 415); |
|
| 652 | 652 | |
| 653 | 653 | } |
| 654 | 654 | |
@@ -669,7 +669,7 @@ discard block |
||
| 669 | 669 | * @return string|null The ETag for the entry object if it has eTag properties |
| 670 | 670 | * NULL otherwise. |
| 671 | 671 | */ |
| 672 | - protected function compareETag(&$entryObject, ResourceType &$resourceType, |
|
| 672 | + protected function compareETag(&$entryObject, ResourceType & $resourceType, |
|
| 673 | 673 | &$needToSerializeResponse |
| 674 | 674 | ) { |
| 675 | 675 | $needToSerializeResponse = true; |
@@ -720,7 +720,7 @@ discard block |
||
| 720 | 720 | // but that is causing an issue in Linux env where the |
| 721 | 721 | // firefix browser is unable to parse the ETag in this case. |
| 722 | 722 | // Need to follow up PHP core devs for this. |
| 723 | - $eTag = ODataConstants::HTTP_WEAK_ETAG_PREFIX . $eTag . '"'; |
|
| 723 | + $eTag = ODataConstants::HTTP_WEAK_ETAG_PREFIX.$eTag.'"'; |
|
| 724 | 724 | if (!is_null($ifMatch)) { |
| 725 | 725 | if (strcmp($eTag, $ifMatch) != 0) { |
| 726 | 726 | // Requested If-Match value does not match with current |
@@ -743,7 +743,7 @@ discard block |
||
| 743 | 743 | // but that is causing an issue in Linux env where the |
| 744 | 744 | // firefix browser is unable to parse the ETag in this case. |
| 745 | 745 | // Need to follow up PHP core devs for this. |
| 746 | - $eTag = ODataConstants::HTTP_WEAK_ETAG_PREFIX . $eTag . '"'; |
|
| 746 | + $eTag = ODataConstants::HTTP_WEAK_ETAG_PREFIX.$eTag.'"'; |
|
| 747 | 747 | } |
| 748 | 748 | |
| 749 | 749 | return $eTag; |
@@ -762,7 +762,7 @@ discard block |
||
| 762 | 762 | * for use in a URI) there are etag properties, NULL if |
| 763 | 763 | * there is no etag property. |
| 764 | 764 | */ |
| 765 | - protected function getETagForEntry(&$entryObject, ResourceType &$resourceType) |
|
| 765 | + protected function getETagForEntry(&$entryObject, ResourceType & $resourceType) |
|
| 766 | 766 | { |
| 767 | 767 | $eTag = null; |
| 768 | 768 | $comma = null; |
@@ -777,18 +777,18 @@ discard block |
||
| 777 | 777 | try { |
| 778 | 778 | |
| 779 | 779 | //TODO #88...also this seems like dupe work |
| 780 | - $reflectionProperty = new \ReflectionProperty($entryObject, $eTagProperty->getName() ); |
|
| 780 | + $reflectionProperty = new \ReflectionProperty($entryObject, $eTagProperty->getName()); |
|
| 781 | 781 | $value = $reflectionProperty->getValue($entryObject); |
| 782 | 782 | } catch (\ReflectionException $reflectionException) { |
| 783 | 783 | throw ODataException::createInternalServerError( |
| 784 | - Messages::failedToAccessProperty($eTagProperty->getName(), $resourceType->getName() ) |
|
| 784 | + Messages::failedToAccessProperty($eTagProperty->getName(), $resourceType->getName()) |
|
| 785 | 785 | ); |
| 786 | 786 | } |
| 787 | 787 | |
| 788 | 788 | if (is_null($value)) { |
| 789 | - $eTag = $eTag . $comma. 'null'; |
|
| 789 | + $eTag = $eTag.$comma.'null'; |
|
| 790 | 790 | } else { |
| 791 | - $eTag = $eTag . $comma . $type->convertToOData($value); |
|
| 791 | + $eTag = $eTag.$comma.$type->convertToOData($value); |
|
| 792 | 792 | } |
| 793 | 793 | |
| 794 | 794 | $comma = ','; |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | * @param string $statusCode The status code |
| 30 | 30 | * @param string $errorCode The error code |
| 31 | 31 | * |
| 32 | - * @return void |
|
| 32 | + * @return ODataException |
|
| 33 | 33 | */ |
| 34 | 34 | public function __construct($message, $statusCode, $errorCode= null) |
| 35 | 35 | { |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | * |
| 32 | 32 | * @return void |
| 33 | 33 | */ |
| 34 | - public function __construct($message, $statusCode, $errorCode= null) |
|
| 34 | + public function __construct($message, $statusCode, $errorCode = null) |
|
| 35 | 35 | { |
| 36 | 36 | $this->_errorCode = $errorCode; |
| 37 | 37 | $this->_statusCode = $statusCode; |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | * To check whether the given character is a HTTP token character |
| 464 | 464 | * or not. |
| 465 | 465 | * |
| 466 | - * @param char $char The character to inspect. |
|
| 466 | + * @param string $char The character to inspect. |
|
| 467 | 467 | * |
| 468 | 468 | * @return boolean True if the given character is a valid HTTP token |
| 469 | 469 | * character, False otherwise. |
@@ -606,6 +606,7 @@ discard block |
||
| 606 | 606 | * @param string $text Text to read qvalue from. |
| 607 | 607 | * @param int &$textIndex Index into text where the qvalue starts. |
| 608 | 608 | * @param int &$qualityValue After the method executes, the normalized qvalue. |
| 609 | + * @param integer $textIndex |
|
| 609 | 610 | * |
| 610 | 611 | * @throws HttpHeaderFailure If any error occured while reading and processing |
| 611 | 612 | * the quality factor. |
@@ -659,7 +660,7 @@ discard block |
||
| 659 | 660 | /** |
| 660 | 661 | * Converts the specified character from the ASCII range to a digit. |
| 661 | 662 | * |
| 662 | - * @param char $c Character to convert |
|
| 663 | + * @param string $c Character to convert |
|
| 663 | 664 | * |
| 664 | 665 | * @return int The Int32 value for $c, or -1 if it is an element separator. |
| 665 | 666 | * |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | public function getMimeType() |
| 65 | 65 | { |
| 66 | - return $this->_type . '/' . $this->_subType; |
|
| 66 | + return $this->_type.'/'.$this->_subType; |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -97,18 +97,18 @@ discard block |
||
| 97 | 97 | //get the odata parameter (if there is one) |
| 98 | 98 | $candidateODataValue = null; |
| 99 | 99 | $candidateParts = explode(';', $candidate); |
| 100 | - if(count($candidateParts) > 1){ |
|
| 100 | + if (count($candidateParts) > 1) { |
|
| 101 | 101 | //is it safe to assume the mime type is always the first part? |
| 102 | 102 | $candidate = array_shift($candidateParts); //move off the first type matcher |
| 103 | 103 | //the rest look like QSPs..kinda so we can do this |
| 104 | 104 | parse_str(implode("&", $candidateParts), $candidateParts); |
| 105 | - if(array_key_exists('odata', $candidateParts)){ |
|
| 105 | + if (array_key_exists('odata', $candidateParts)) { |
|
| 106 | 106 | $candidateODataValue = $candidateParts['odata']; |
| 107 | 107 | } |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | //ensure that the odata parameter values match |
| 111 | - if($this->getODataValue() !== $candidateODataValue){ |
|
| 111 | + if ($this->getODataValue() !== $candidateODataValue) { |
|
| 112 | 112 | return -1; |
| 113 | 113 | } |
| 114 | 114 | |
@@ -697,7 +697,7 @@ discard block |
||
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | |
| 700 | - public static function headerToServerKey($headerName){ |
|
| 701 | - return 'HTTP_' . strtoupper(str_replace('-', '_', $headerName)); |
|
| 700 | + public static function headerToServerKey($headerName) { |
|
| 701 | + return 'HTTP_'.strtoupper(str_replace('-', '_', $headerName)); |
|
| 702 | 702 | } |
| 703 | 703 | } |
| 704 | 704 | \ No newline at end of file |
@@ -376,7 +376,7 @@ |
||
| 376 | 376 | * NULL for complex object. |
| 377 | 377 | * @param string $relativeUri Relative uri for the given |
| 378 | 378 | * custom object. |
| 379 | - * @param ODataEntry &$odataEntry ODataEntry instance to |
|
| 379 | + * @param ODataEntry ODataEntry|null ODataEntry instance to |
|
| 380 | 380 | * place links and |
| 381 | 381 | * expansion of the |
| 382 | 382 | * entry object, |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | $this->getCurrentResourceSetWrapper()->getName() |
| 141 | 141 | ); |
| 142 | 142 | |
| 143 | - $url->url = rtrim($this->absoluteServiceUri, '/') . '/' . $relativeUri; |
|
| 143 | + $url->url = rtrim($this->absoluteServiceUri, '/').'/'.$relativeUri; |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | return $url; |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | public function writeTopLevelComplexObject( |
| 192 | 192 | &$complexValue, |
| 193 | 193 | $propertyName, |
| 194 | - ResourceType &$resourceType |
|
| 194 | + ResourceType & $resourceType |
|
| 195 | 195 | ) { |
| 196 | 196 | $propertyContent = new ODataPropertyContent(); |
| 197 | 197 | $this->_writeComplexValue( |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | public function writeTopLevelBagObject( |
| 219 | 219 | &$BagValue, |
| 220 | 220 | $propertyName, |
| 221 | - ResourceType &$resourceType |
|
| 221 | + ResourceType & $resourceType |
|
| 222 | 222 | ) { |
| 223 | 223 | |
| 224 | 224 | $propertyContent = new ODataPropertyContent(); |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | */ |
| 246 | 246 | public function writeTopLevelPrimitive( |
| 247 | 247 | &$primitiveValue, |
| 248 | - ResourceProperty &$resourceProperty |
|
| 248 | + ResourceProperty & $resourceProperty |
|
| 249 | 249 | ) { |
| 250 | 250 | $propertyContent = new ODataPropertyContent(); |
| 251 | 251 | $propertyContent->properties[] = new ODataProperty(); |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | $this->getCurrentResourceSetWrapper()->getName() |
| 288 | 288 | ); |
| 289 | 289 | |
| 290 | - $absoluteUri = rtrim($this->absoluteServiceUri, '/') . '/' . $relativeUri; |
|
| 290 | + $absoluteUri = rtrim($this->absoluteServiceUri, '/').'/'.$relativeUri; |
|
| 291 | 291 | $title = $resourceType->getName(); |
| 292 | 292 | //TODO Resolve actual resource type |
| 293 | 293 | $actualResourceType = $resourceType; |
@@ -334,18 +334,18 @@ discard block |
||
| 334 | 334 | */ |
| 335 | 335 | private function _writeFeedElements( |
| 336 | 336 | &$entryObjects, |
| 337 | - ResourceType &$resourceType, |
|
| 337 | + ResourceType & $resourceType, |
|
| 338 | 338 | $title, |
| 339 | 339 | $absoluteUri, |
| 340 | 340 | $relativeUri, |
| 341 | - ODataFeed &$feed |
|
| 341 | + ODataFeed & $feed |
|
| 342 | 342 | ) { |
| 343 | 343 | $this->assert(is_array($entryObjects), '_writeFeedElements::is_array($entryObjects)'); |
| 344 | 344 | $feed->id = $absoluteUri; |
| 345 | 345 | $feed->title = $title; |
| 346 | 346 | $feed->selfLink = new ODataLink(); |
| 347 | 347 | $feed->selfLink->name = ODataConstants::ATOM_SELF_RELATION_ATTRIBUTE_VALUE; |
| 348 | - $feed->selfLink->title = $title; |
|
| 348 | + $feed->selfLink->title = $title; |
|
| 349 | 349 | $feed->selfLink->url = $relativeUri; |
| 350 | 350 | |
| 351 | 351 | if (empty($entryObjects)) { |
@@ -389,11 +389,11 @@ discard block |
||
| 389 | 389 | */ |
| 390 | 390 | private function _writeObjectProperties( |
| 391 | 391 | $customObject, |
| 392 | - ResourceType &$resourceType, |
|
| 392 | + ResourceType & $resourceType, |
|
| 393 | 393 | $absoluteUri, |
| 394 | 394 | $relativeUri, |
| 395 | 395 | &$odataEntry, |
| 396 | - ODataPropertyContent &$odataPropertyContent |
|
| 396 | + ODataPropertyContent & $odataPropertyContent |
|
| 397 | 397 | ) { |
| 398 | 398 | $resourceTypeKind = $resourceType->getResourceTypeKind(); |
| 399 | 399 | if (is_null($absoluteUri) == ($resourceTypeKind == ResourceTypeKind::ENTITY) |
@@ -464,7 +464,7 @@ discard block |
||
| 464 | 464 | $propertyValue, |
| 465 | 465 | $resourceProperty->getName(), |
| 466 | 466 | $resourceType2, |
| 467 | - $relativeUri . '/' . $resourceProperty->getName(), |
|
| 467 | + $relativeUri.'/'.$resourceProperty->getName(), |
|
| 468 | 468 | $odataPropertyContent |
| 469 | 469 | ); |
| 470 | 470 | } else { |
@@ -476,7 +476,7 @@ discard block |
||
| 476 | 476 | $propertyValue, |
| 477 | 477 | $resourceProperty->getName(), |
| 478 | 478 | $resourceType1, |
| 479 | - $relativeUri . '/' . $resourceProperty->getName(), |
|
| 479 | + $relativeUri.'/'.$resourceProperty->getName(), |
|
| 480 | 480 | $odataPropertyContent |
| 481 | 481 | ); |
| 482 | 482 | } else if ($resourceProperty->getKind() == ResourcePropertyKind::PRIMITIVE |
@@ -541,7 +541,7 @@ discard block |
||
| 541 | 541 | $propertyValue, |
| 542 | 542 | $propertyName, |
| 543 | 543 | $bagResourceType, |
| 544 | - $relativeUri . '/' . $propertyName, |
|
| 544 | + $relativeUri.'/'.$propertyName, |
|
| 545 | 545 | $odataPropertyContent |
| 546 | 546 | ); |
| 547 | 547 | } else if (ResourceProperty::sIsKindOf($propertyTypeKind, ResourcePropertyKind::PRIMITIVE)) { |
@@ -554,7 +554,7 @@ discard block |
||
| 554 | 554 | $propertyValue, |
| 555 | 555 | $propertyName, |
| 556 | 556 | $complexResourceType, |
| 557 | - $relativeUri . '/' . $propertyName, |
|
| 557 | + $relativeUri.'/'.$propertyName, |
|
| 558 | 558 | $odataPropertyContent |
| 559 | 559 | ); |
| 560 | 560 | } else { |
@@ -569,17 +569,16 @@ discard block |
||
| 569 | 569 | foreach ($navigationProperties as $navigationPropertyInfo) { |
| 570 | 570 | $propertyName = $navigationPropertyInfo->resourceProperty->getName(); |
| 571 | 571 | $type = $navigationPropertyInfo->resourceProperty->getKind() == ResourcePropertyKind::RESOURCE_REFERENCE ? |
| 572 | - 'application/atom+xml;type=entry': |
|
| 573 | - 'application/atom+xml;type=feed'; |
|
| 572 | + 'application/atom+xml;type=entry' : 'application/atom+xml;type=feed'; |
|
| 574 | 573 | $link = new ODataLink(); |
| 575 | - $link->name = ODataConstants::ODATA_RELATED_NAMESPACE . $propertyName; |
|
| 574 | + $link->name = ODataConstants::ODATA_RELATED_NAMESPACE.$propertyName; |
|
| 576 | 575 | $link->title = $propertyName; |
| 577 | 576 | $link->type = $type; |
| 578 | - $link->url = $relativeUri . '/' . $propertyName; |
|
| 577 | + $link->url = $relativeUri.'/'.$propertyName; |
|
| 579 | 578 | |
| 580 | 579 | if ($navigationPropertyInfo->expanded) { |
| 581 | - $propertyRelativeUri = $relativeUri . '/' . $propertyName; |
|
| 582 | - $propertyAbsoluteUri = trim($absoluteUri, '/') . '/' . $propertyName; |
|
| 580 | + $propertyRelativeUri = $relativeUri.'/'.$propertyName; |
|
| 581 | + $propertyAbsoluteUri = trim($absoluteUri, '/').'/'.$propertyName; |
|
| 583 | 582 | $needPop = $this->pushSegmentForNavigationProperty($navigationPropertyInfo->resourceProperty); |
| 584 | 583 | $navigationPropertyKind = $navigationPropertyInfo->resourceProperty->getKind(); |
| 585 | 584 | $this->assert( |
@@ -645,7 +644,7 @@ discard block |
||
| 645 | 644 | * @return void |
| 646 | 645 | */ |
| 647 | 646 | private function _writePrimitiveValue(&$primitiveValue, |
| 648 | - ResourceProperty &$resourceProperty, ODataProperty &$odataProperty |
|
| 647 | + ResourceProperty & $resourceProperty, ODataProperty & $odataProperty |
|
| 649 | 648 | ) { |
| 650 | 649 | if (is_object($primitiveValue)) { |
| 651 | 650 | //TODO ERROR: The property 'PropertyName' |
@@ -684,8 +683,8 @@ discard block |
||
| 684 | 683 | * @return void |
| 685 | 684 | */ |
| 686 | 685 | private function _writeComplexValue(&$complexValue, |
| 687 | - $propertyName, ResourceType &$resourceType, $relativeUri, |
|
| 688 | - ODataPropertyContent &$odataPropertyContent |
|
| 686 | + $propertyName, ResourceType & $resourceType, $relativeUri, |
|
| 687 | + ODataPropertyContent & $odataPropertyContent |
|
| 689 | 688 | ) { |
| 690 | 689 | $odataProperty = new ODataProperty(); |
| 691 | 690 | $odataProperty->name = $propertyName; |
@@ -724,8 +723,8 @@ discard block |
||
| 724 | 723 | * @return void |
| 725 | 724 | */ |
| 726 | 725 | private function _writeBagValue(&$BagValue, |
| 727 | - $propertyName, ResourceType &$resourceType, $relativeUri, |
|
| 728 | - ODataPropertyContent &$odataPropertyContent |
|
| 726 | + $propertyName, ResourceType & $resourceType, $relativeUri, |
|
| 727 | + ODataPropertyContent & $odataPropertyContent |
|
| 729 | 728 | ) { |
| 730 | 729 | $bagItemResourceTypeKind = $resourceType->getResourceTypeKind(); |
| 731 | 730 | $this->assert( |
@@ -737,7 +736,7 @@ discard block |
||
| 737 | 736 | |
| 738 | 737 | $odataProperty = new ODataProperty(); |
| 739 | 738 | $odataProperty->name = $propertyName; |
| 740 | - $odataProperty->typeName = 'Collection(' . $resourceType->getFullName() .')'; |
|
| 739 | + $odataProperty->typeName = 'Collection('.$resourceType->getFullName().')'; |
|
| 741 | 740 | if (is_null($BagValue) || (is_array($BagValue) && empty ($BagValue))) { |
| 742 | 741 | $odataProperty->value = null; |
| 743 | 742 | } else { |
@@ -784,10 +783,10 @@ discard block |
||
| 784 | 783 | */ |
| 785 | 784 | private function _writeMediaResourceMetadata( |
| 786 | 785 | $entryObject, |
| 787 | - ResourceType &$resourceType, |
|
| 786 | + ResourceType & $resourceType, |
|
| 788 | 787 | $title, |
| 789 | 788 | $relativeUri, |
| 790 | - ODataEntry &$odataEntry |
|
| 789 | + ODataEntry & $odataEntry |
|
| 791 | 790 | ) { |
| 792 | 791 | if ($resourceType->isMediaLinkEntry()) { |
| 793 | 792 | $odataEntry->isMediaLinkEntry = true; |
@@ -833,7 +832,7 @@ discard block |
||
| 833 | 832 | * |
| 834 | 833 | * @return void |
| 835 | 834 | */ |
| 836 | - private function _primitiveToString(ResourceType &$primtiveResourceType, |
|
| 835 | + private function _primitiveToString(ResourceType & $primtiveResourceType, |
|
| 837 | 836 | $primitiveValue, &$stringValue |
| 838 | 837 | ) { |
| 839 | 838 | $type = $primtiveResourceType->getInstanceType(); |
@@ -868,8 +867,8 @@ discard block |
||
| 868 | 867 | * @return void |
| 869 | 868 | */ |
| 870 | 869 | private function _complexObjectToContent(&$complexValue, |
| 871 | - $propertyName, ResourceType &$resourceType, $relativeUri, |
|
| 872 | - ODataPropertyContent &$odataPropertyContent |
|
| 870 | + $propertyName, ResourceType & $resourceType, $relativeUri, |
|
| 871 | + ODataPropertyContent & $odataPropertyContent |
|
| 873 | 872 | ) { |
| 874 | 873 | $count = count($this->complexTypeInstanceCollection); |
| 875 | 874 | for ($i = 0; $i < $count; $i++) { |