Skip to content

Commit 87e9d1c

Browse files
Applied StyleCI fixes
1 parent f624470 commit 87e9d1c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1006
-973
lines changed

autoload.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,30 @@
1515
* https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader-examples.md
1616
*/
1717

18-
spl_autoload_register(function ($class)
19-
{
18+
spl_autoload_register(function ($class) {
2019
// Parse class prefix
2120
$prefix = 'Parse\\';
2221

2322
// base directory for the namespace prefix
24-
$base_dir = defined('PARSE_SDK_DIR') ? PARSE_SDK_DIR : __DIR__ . '/src/Parse/';
23+
$base_dir = defined('PARSE_SDK_DIR') ? PARSE_SDK_DIR : __DIR__.'/src/Parse/';
2524

2625
// does the class use the namespace prefix?
27-
$len = strlen( $prefix );
28-
if ( strncmp($prefix, $class, $len) !== 0 ) {
26+
$len = strlen($prefix);
27+
if (strncmp($prefix, $class, $len) !== 0) {
2928
// no, move to the next registered autoloader
3029
return;
3130
}
3231

3332
// get the relative class name
34-
$relative_class = substr( $class, $len );
33+
$relative_class = substr($class, $len);
3534

3635
// replace the namespace prefix with the base directory, replace namespace
3736
// separators with directory separators in the relative class name, append
3837
// with .php
39-
$file = $base_dir . str_replace( '\\', '/', $relative_class ) . '.php';
38+
$file = $base_dir.str_replace('\\', '/', $relative_class).'.php';
4039

4140
// if the file exists, require it
42-
if ( file_exists( $file ) ) {
41+
if (file_exists($file)) {
4342
require $file;
4443
}
4544
});

src/Parse/Internal/AddOperation.php

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66
use Parse\ParseException;
77

88
/**
9-
* Class AddOperation - FieldOperation for adding object(s) to array fields
9+
* Class AddOperation - FieldOperation for adding object(s) to array fields.
1010
*
11-
* @package Parse
1211
* @author Fosco Marotto <fjm@fb.com>
1312
*/
1413
class AddOperation implements FieldOperation
1514
{
16-
1715
/**
1816
* @var - Array with objects to add.
1917
*/
@@ -51,17 +49,18 @@ public function getValue()
5149
*/
5250
public function _encode()
5351
{
54-
return array('__op' => 'Add',
55-
'objects' => ParseClient::_encode($this->objects, true));
52+
return ['__op' => 'Add',
53+
'objects' => ParseClient::_encode($this->objects, true), ];
5654
}
5755

5856
/**
5957
* Takes a previous operation and returns a merged operation to replace it.
6058
*
6159
* @param FieldOperation $previous Previous operation.
6260
*
63-
* @return FieldOperation Merged operation.
6461
* @throws ParseException
62+
*
63+
* @return FieldOperation Merged operation.
6564
*/
6665
public function _mergeWithPrevious($previous)
6766
{
@@ -73,14 +72,16 @@ public function _mergeWithPrevious($previous)
7372
}
7473
if ($previous instanceof SetOperation) {
7574
$oldList = $previous->getValue();
75+
7676
return new SetOperation(
77-
array_merge((array)$oldList, (array)$this->objects)
77+
array_merge((array) $oldList, (array) $this->objects)
7878
);
7979
}
8080
if ($previous instanceof AddOperation) {
8181
$oldList = $previous->getValue();
82+
8283
return new SetOperation(
83-
array_merge((array)$oldList, (array)$this->objects)
84+
array_merge((array) $oldList, (array) $this->objects)
8485
);
8586
}
8687
throw new ParseException(
@@ -91,9 +92,9 @@ public function _mergeWithPrevious($previous)
9192
/**
9293
* Applies current operation, returns resulting value.
9394
*
94-
* @param mixed $oldValue Value prior to this operation.
95-
* @param mixed $obj Value being applied.
96-
* @param string $key Key this operation affects.
95+
* @param mixed $oldValue Value prior to this operation.
96+
* @param mixed $obj Value being applied.
97+
* @param string $key Key this operation affects.
9798
*
9899
* @return array
99100
*/
@@ -102,7 +103,7 @@ public function _apply($oldValue, $obj, $key)
102103
if (!$oldValue) {
103104
return $this->objects;
104105
}
105-
return array_merge((array)$oldValue, (array)$this->objects);
106-
}
107106

107+
return array_merge((array) $oldValue, (array) $this->objects);
108+
}
108109
}

src/Parse/Internal/AddUniqueOperation.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88
/**
99
* Class AddUniqueOperation - Operation to add unique objects to an array key.
1010
*
11-
* @package Parse
1211
* @author Fosco Marotto <fjm@fb.com>
1312
*/
1413
class AddUniqueOperation implements FieldOperation
1514
{
16-
1715
/**
1816
* @var - Array containing objects to add.
1917
*/
@@ -51,17 +49,18 @@ public function getValue()
5149
*/
5250
public function _encode()
5351
{
54-
return array('__op' => 'AddUnique',
55-
'objects' => ParseClient::_encode($this->objects, true));
52+
return ['__op' => 'AddUnique',
53+
'objects' => ParseClient::_encode($this->objects, true), ];
5654
}
5755

5856
/**
5957
* Merge this operation with the previous operation and return the result.
6058
*
6159
* @param FieldOperation $previous Previous Operation.
6260
*
63-
* @return FieldOperation Merged Operation.
6461
* @throws ParseException
62+
*
63+
* @return FieldOperation Merged Operation.
6564
*/
6665
public function _mergeWithPrevious($previous)
6766
{
@@ -74,11 +73,13 @@ public function _mergeWithPrevious($previous)
7473
if ($previous instanceof SetOperation) {
7574
$oldValue = $previous->getValue();
7675
$result = $this->_apply($oldValue, null, null);
76+
7777
return new SetOperation($result);
7878
}
7979
if ($previous instanceof AddUniqueOperation) {
8080
$oldList = $previous->getValue();
8181
$result = $this->_apply($oldList, null, null);
82+
8283
return new AddUniqueOperation($result);
8384
}
8485
throw new ParseException(
@@ -89,9 +90,9 @@ public function _mergeWithPrevious($previous)
8990
/**
9091
* Apply the current operation and return the result.
9192
*
92-
* @param mixed $oldValue Value prior to this operation.
93-
* @param array $obj Value being applied.
94-
* @param string $key Key this operation affects.
93+
* @param mixed $oldValue Value prior to this operation.
94+
* @param array $obj Value being applied.
95+
* @param string $key Key this operation affects.
9596
*
9697
* @return array
9798
*/
@@ -101,14 +102,14 @@ public function _apply($oldValue, $obj, $key)
101102
return $this->objects;
102103
}
103104
if (!is_array($oldValue)) {
104-
$oldValue = (array)$oldValue;
105+
$oldValue = (array) $oldValue;
105106
}
106107
foreach ($this->objects as $object) {
107108
if ($object instanceof ParseObject && $object->getObjectId()) {
108109
if (!$this->isParseObjectInArray($object, $oldValue)) {
109110
$oldValue[] = $object;
110111
}
111-
} else if (is_object($object)) {
112+
} elseif (is_object($object)) {
112113
if (!in_array($object, $oldValue, true)) {
113114
$oldValue[] = $object;
114115
}
@@ -118,6 +119,7 @@ public function _apply($oldValue, $obj, $key)
118119
}
119120
}
120121
}
122+
121123
return $oldValue;
122124
}
123125

@@ -130,7 +132,7 @@ private function isParseObjectInArray($parseObject, $oldValue)
130132
}
131133
}
132134
}
135+
133136
return false;
134137
}
135-
136138
}

src/Parse/Internal/DeleteOperation.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,32 @@
55
/**
66
* Class DeleteOperation - FieldOperation to remove a key from an object.
77
*
8-
* @package Parse
98
* @author Fosco Marotto <fjm@fb.com>
109
*/
1110
class DeleteOperation implements FieldOperation
1211
{
13-
1412
/**
1513
* Returns an associative array encoding of the current operation.
1614
*
1715
* @return array Associative array encoding the operation.
1816
*/
1917
public function _encode()
2018
{
21-
return array('__op' => 'Delete');
19+
return ['__op' => 'Delete'];
2220
}
2321

2422
/**
2523
* Applies the current operation and returns the result.
2624
*
27-
* @param mixed $oldValue Value prior to this operation.
28-
* @param mixed $object Unused for this operation type.
29-
* @param string $key Key to remove from the target object.
25+
* @param mixed $oldValue Value prior to this operation.
26+
* @param mixed $object Unused for this operation type.
27+
* @param string $key Key to remove from the target object.
3028
*
3129
* @return null
3230
*/
3331
public function _apply($oldValue, $object, $key)
3432
{
35-
return null;
33+
return;
3634
}
3735

3836
/**
@@ -46,5 +44,4 @@ public function _mergeWithPrevious($previous)
4644
{
4745
return $this;
4846
}
49-
5047
}

src/Parse/Internal/Encodable.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,14 @@
66
* Class Encodable - Interface for Parse Classes which provide an encode
77
* method.
88
*
9-
* @package Parse
109
* @author Fosco Marotto <fjm@fb.com>
1110
*/
1211
interface Encodable
1312
{
14-
1513
/**
1614
* Returns an associate array encoding of the implementing class.
1715
*
1816
* @return mixed
1917
*/
2018
public function _encode();
21-
2219
}

src/Parse/Internal/FieldOperation.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,16 @@
55
/**
66
* Class FieldOperation - Interface for all Parse Field Operations.
77
*
8-
* @package Parse
98
* @author Fosco Marotto <fjm@fb.com>
109
*/
1110
interface FieldOperation extends Encodable
1211
{
13-
1412
/**
1513
* Applies the current operation and returns the result.
1614
*
17-
* @param mixed $oldValue Value prior to this operation.
18-
* @param mixed $object Value for this operation.
19-
* @param string $key Key to perform this operation on.
15+
* @param mixed $oldValue Value prior to this operation.
16+
* @param mixed $object Value for this operation.
17+
* @param string $key Key to perform this operation on.
2018
*
2119
* @return mixed Result of the operation.
2220
*/
@@ -31,5 +29,4 @@ public function _apply($oldValue, $object, $key);
3129
* @return FieldOperation Merged operation result.
3230
*/
3331
public function _mergeWithPrevious($previous);
34-
3532
}

src/Parse/Internal/IncrementOperation.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@
77
/**
88
* Class IncrementOperation - Operation to increment numeric object key.
99
*
10-
* @package Parse
1110
* @author Fosco Marotto <fjm@fb.com>
1211
*/
1312
class IncrementOperation implements FieldOperation
1413
{
15-
1614
/**
1715
* @var int - Amount to increment by.
1816
*/
@@ -45,24 +43,26 @@ public function getValue()
4543
*/
4644
public function _encode()
4745
{
48-
return array('__op' => 'Increment', 'amount' => $this->value);
46+
return ['__op' => 'Increment', 'amount' => $this->value];
4947
}
5048

5149
/**
5250
* Apply the current operation and return the result.
5351
*
54-
* @param mixed $oldValue Value prior to this operation.
55-
* @param mixed $object Value for this operation.
56-
* @param string $key Key to set Value on.
52+
* @param mixed $oldValue Value prior to this operation.
53+
* @param mixed $object Value for this operation.
54+
* @param string $key Key to set Value on.
5755
*
58-
* @return int New value after application.
5956
* @throws ParseException
57+
*
58+
* @return int New value after application.
6059
*/
6160
public function _apply($oldValue, $object, $key)
6261
{
6362
if ($oldValue && !is_numeric($oldValue)) {
6463
throw new ParseException('Cannot increment a non-number type.');
6564
}
65+
6666
return $oldValue + $this->value;
6767
}
6868

@@ -72,8 +72,9 @@ public function _apply($oldValue, $object, $key)
7272
*
7373
* @param FieldOperation $previous Previous Operation.
7474
*
75-
* @return FieldOperation
7675
* @throws ParseException
76+
*
77+
* @return FieldOperation
7778
*/
7879
public function _mergeWithPrevious($previous)
7980
{
@@ -95,5 +96,4 @@ public function _mergeWithPrevious($previous)
9596
'Operation is invalid after previous operation.'
9697
);
9798
}
98-
9999
}

0 commit comments

Comments
 (0)