Skip to content

Commit e41c7e4

Browse files
Applied some more cs fixes
1 parent de0ff31 commit e41c7e4

16 files changed

+1025
-617
lines changed

src/Parse/Internal/ParseRelationOperation.php

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,13 @@ public function _apply($oldValue, $object, $key)
126126
return new ParseRelation($object, $key, $this->targetClassName);
127127
} elseif ($oldValue instanceof ParseRelation) {
128128
if ($this->targetClassName != null
129-
&& $oldValue->getTargetClass() !== $this->targetClassName) {
130-
throw new \Exception('Related object object must be of class '
131-
.$this->targetClassName.', but '.$oldValue->getTargetClass()
132-
.' was passed in.');
129+
&& $oldValue->getTargetClass() !== $this->targetClassName
130+
) {
131+
throw new \Exception(
132+
'Related object object must be of class '
133+
.$this->targetClassName.', but '.$oldValue->getTargetClass()
134+
.' was passed in.'
135+
);
133136
}
134137

135138
return $oldValue;
@@ -155,34 +158,50 @@ public function _mergeWithPrevious($previous)
155158
}
156159
if ($previous instanceof ParseRelationOperation) {
157160
if ($previous->targetClassName != null
158-
&& $previous->targetClassName != $this->targetClassName
161+
&& $previous->targetClassName != $this->targetClassName
159162
) {
160-
throw new \Exception('Related object object must be of class '
161-
.$this->targetClassName.', but '.$previous->targetClassName
162-
.' was passed in.');
163+
throw new \Exception(
164+
'Related object object must be of class '
165+
.$this->targetClassName.', but '.$previous->targetClassName
166+
.' was passed in.'
167+
);
163168
}
164169
$newRelationToAdd = self::convertToOneDimensionalArray(
165-
$this->relationsToAdd);
170+
$this->relationsToAdd
171+
);
166172
$newRelationToRemove = self::convertToOneDimensionalArray(
167-
$this->relationsToRemove);
173+
$this->relationsToRemove
174+
);
168175

169-
$previous->addObjects($newRelationToAdd,
170-
$previous->relationsToAdd);
171-
$previous->removeObjects($newRelationToAdd,
172-
$previous->relationsToRemove);
176+
$previous->addObjects(
177+
$newRelationToAdd,
178+
$previous->relationsToAdd
179+
);
180+
$previous->removeObjects(
181+
$newRelationToAdd,
182+
$previous->relationsToRemove
183+
);
173184

174-
$previous->removeObjects($newRelationToRemove,
175-
$previous->relationsToAdd);
176-
$previous->addObjects($newRelationToRemove,
177-
$previous->relationsToRemove);
185+
$previous->removeObjects(
186+
$newRelationToRemove,
187+
$previous->relationsToAdd
188+
);
189+
$previous->addObjects(
190+
$newRelationToRemove,
191+
$previous->relationsToRemove
192+
);
178193

179194
$newRelationToAdd = self::convertToOneDimensionalArray(
180-
$previous->relationsToAdd);
195+
$previous->relationsToAdd
196+
);
181197
$newRelationToRemove = self::convertToOneDimensionalArray(
182-
$previous->relationsToRemove);
198+
$previous->relationsToRemove
199+
);
183200

184-
return new ParseRelationOperation($newRelationToAdd,
185-
$newRelationToRemove);
201+
return new ParseRelationOperation(
202+
$newRelationToAdd,
203+
$newRelationToRemove
204+
);
186205
}
187206
throw new \Exception('Operation is invalid after previous operation.');
188207
}

src/Parse/Internal/RemoveOperation.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ public function _apply($oldValue, $obj, $key)
109109
if ($oldObject instanceof ParseObject) {
110110
if ($newObject instanceof ParseObject
111111
&& !$oldObject->isDirty()
112-
&& $oldObject->getObjectId() == $newObject->getObjectId()) {
112+
&& $oldObject->getObjectId() == $newObject->getObjectId()
113+
) {
113114
// found the object, won't add it.
114115
} else {
115116
$newValue[] = $oldObject;

src/Parse/ParseACL.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,13 @@ public static function _createACLFromJSON($data)
8181
foreach ($permissions as $accessType => $value) {
8282
if ($accessType !== 'read' && $accessType !== 'write') {
8383
throw new \Exception(
84-
'Tried to create an ACL with an invalid permission type.');
84+
'Tried to create an ACL with an invalid permission type.'
85+
);
8586
}
8687
if (!is_bool($value)) {
8788
throw new \Exception(
88-
'Tried to create an ACL with an invalid permission value.');
89+
'Tried to create an ACL with an invalid permission value.'
90+
);
8991
}
9092
$acl->setAccess($accessType, $id, $value);
9193
}
@@ -108,7 +110,7 @@ public function _isShared()
108110
/**
109111
* Set shared for ParseACL.
110112
*
111-
* @param bool $shared
113+
* @param bool $shared
112114
* @ignore
113115
*/
114116
public function _setShared($shared)
@@ -438,7 +440,8 @@ private static function validateRoleState($role)
438440
{
439441
if (!$role->getObjectId()) {
440442
throw new \Exception(
441-
"Roles must be saved to the server before they can be used in an ACL.");
443+
"Roles must be saved to the server before they can be used in an ACL."
444+
);
442445
}
443446
}
444447

src/Parse/ParseClient.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,8 @@ public static function _encodeArray($value, $allowParseObjects)
233233
* @ignore
234234
*/
235235
public static function _request($method, $relativeUrl, $sessionToken = null,
236-
$data = null, $useMasterKey = false)
237-
{
236+
$data = null, $useMasterKey = false
237+
) {
238238
if ($data === '[]') {
239239
$data = '{}';
240240
}
@@ -279,7 +279,8 @@ public static function _request($method, $relativeUrl, $sessionToken = null,
279279

280280
$decoded = json_decode($response, true);
281281
if (isset($decoded['error'])) {
282-
throw new ParseException($decoded['error'],
282+
throw new ParseException(
283+
$decoded['error'],
283284
isset($decoded['code']) ? $decoded['code'] : 0
284285
);
285286
}

src/Parse/ParseException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ class ParseException extends \Exception
1717
* @param \Exception $previous Previous Exception.
1818
*/
1919
public function __construct($message, $code = 0,
20-
\Exception $previous = null)
21-
{
20+
\Exception $previous = null
21+
) {
2222
parent::__construct($message, $code, $previous);
2323
}
2424
}

src/Parse/ParseFile.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,8 @@ private function upload()
218218

219219
$decoded = json_decode($response, true);
220220
if (isset($decoded['error'])) {
221-
throw new ParseException($decoded['error'],
221+
throw new ParseException(
222+
$decoded['error'],
222223
isset($decoded['code']) ? $decoded['code'] : 0
223224
);
224225
}

src/Parse/ParseObject.php

Lines changed: 55 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ class ParseObject implements Encodable
7474
* @throws Exception
7575
*/
7676
public function __construct($className = null, $objectId = null,
77-
$isPointer = false)
78-
{
77+
$isPointer = false
78+
) {
7979
if (empty(self::$registeredSubclasses)) {
8080
throw new Exception(
8181
'You must initialize the ParseClient using ParseClient::initialize '.
@@ -166,7 +166,8 @@ public function get($key)
166166
{
167167
if (!$this->_isDataAvailable($key)) {
168168
throw new \Exception(
169-
'ParseObject has no data for this key. Call fetch() to get the data.');
169+
'ParseObject has no data for this key. Call fetch() to get the data.'
170+
);
170171
}
171172
if (isset($this->estimatedData[$key])) {
172173
return $this->estimatedData[$key];
@@ -229,13 +230,15 @@ protected function _isDirty($considerChildren)
229230
private function hasDirtyChildren()
230231
{
231232
$result = false;
232-
self::traverse(true, $this->estimatedData, function ($object) use (&$result) {
233-
if ($object instanceof ParseObject) {
234-
if ($object->isDirty()) {
235-
$result = true;
233+
self::traverse(
234+
true, $this->estimatedData, function ($object) use (&$result) {
235+
if ($object instanceof ParseObject) {
236+
if ($object->isDirty()) {
237+
$result = true;
238+
}
236239
}
237240
}
238-
});
241+
);
239242

240243
return $result;
241244
}
@@ -452,8 +455,8 @@ public function getUpdatedAt()
452455
* @return Object
453456
*/
454457
public static function create($className, $objectId = null,
455-
$isPointer = false)
456-
{
458+
$isPointer = false
459+
) {
457460
if (isset(self::$registeredSubclasses[$className])) {
458461
return new self::$registeredSubclasses[$className](
459462
$className, $objectId, $isPointer
@@ -862,7 +865,7 @@ public static function saveAll($list, $useMasterKey = false)
862865
* Save Object and unsaved children within.
863866
*
864867
* @param $target
865-
* @param bool $useMasterKey Whether to use the Master Key.
868+
* @param bool $useMasterKey Whether to use the Master Key.
866869
*
867870
* @throws ParseException
868871
*
@@ -929,12 +932,16 @@ private static function deepSave($target, $useMasterKey = false)
929932

930933
if (count($requests) === 1) {
931934
$req = $requests[0];
932-
$result = ParseClient::_request($req['method'],
933-
$req['path'], $sessionToken, json_encode($req['body']), $useMasterKey);
935+
$result = ParseClient::_request(
936+
$req['method'],
937+
$req['path'], $sessionToken, json_encode($req['body']), $useMasterKey
938+
);
934939
$batch[0]->mergeAfterSave($result);
935940
} else {
936-
$result = ParseClient::_request('POST', '/1/batch', $sessionToken,
937-
json_encode(["requests" => $requests]), $useMasterKey);
941+
$result = ParseClient::_request(
942+
'POST', '/1/batch', $sessionToken,
943+
json_encode(["requests" => $requests]), $useMasterKey
944+
);
938945

939946
$errorCollection = [];
940947

@@ -961,7 +968,7 @@ private static function deepSave($target, $useMasterKey = false)
961968
}
962969
if (count($errorCollection)) {
963970
throw new ParseAggregateException(
964-
"Errors during batch save.", $errorCollection
971+
"Errors during batch save.", $errorCollection
965972
);
966973
}
967974
}
@@ -976,23 +983,25 @@ private static function deepSave($target, $useMasterKey = false)
976983
* @param array &$unsavedFiles Array to populate with files.
977984
*/
978985
private static function findUnsavedChildren($object,
979-
&$unsavedChildren, &$unsavedFiles)
980-
{
981-
static::traverse(true, $object, function ($obj) use (
982-
&$unsavedChildren,
983-
&$unsavedFiles
984-
) {
985-
if ($obj instanceof ParseObject) {
986-
if ($obj->_isDirty(false)) {
987-
$unsavedChildren[] = $obj;
988-
}
989-
} elseif ($obj instanceof ParseFile) {
990-
if (!$obj->getURL()) {
991-
$unsavedFiles[] = $obj;
986+
&$unsavedChildren, &$unsavedFiles
987+
) {
988+
static::traverse(
989+
true, $object, function ($obj) use (
990+
&$unsavedChildren,
991+
&$unsavedFiles
992+
) {
993+
if ($obj instanceof ParseObject) {
994+
if ($obj->_isDirty(false)) {
995+
$unsavedChildren[] = $obj;
996+
}
997+
} elseif ($obj instanceof ParseFile) {
998+
if (!$obj->getURL()) {
999+
$unsavedFiles[] = $obj;
1000+
}
9921001
}
993-
}
9941002

995-
});
1003+
}
1004+
);
9961005
}
9971006

9981007
/**
@@ -1006,8 +1015,8 @@ private static function findUnsavedChildren($object,
10061015
* @return mixed The result of calling mapFunction on the root object.
10071016
*/
10081017
private static function traverse($deep, &$object, $mapFunction,
1009-
$seen = [])
1010-
{
1018+
$seen = []
1019+
) {
10111020
if ($object instanceof ParseObject) {
10121021
if (in_array($object, $seen, true)) {
10131022
return;
@@ -1056,20 +1065,22 @@ private function canBeSerialized()
10561065
private static function canBeSerializedAsValue($object)
10571066
{
10581067
$result = true;
1059-
self::traverse(false, $object, function ($obj) use (&$result) {
1060-
// short circuit as soon as possible.
1061-
if ($result === false) {
1062-
return;
1063-
}
1064-
// cannot make a pointer to an unsaved object.
1065-
if ($obj instanceof ParseObject) {
1066-
if (!$obj->getObjectId()) {
1067-
$result = false;
1068-
1068+
self::traverse(
1069+
false, $object, function ($obj) use (&$result) {
1070+
// short circuit as soon as possible.
1071+
if ($result === false) {
10691072
return;
10701073
}
1074+
// cannot make a pointer to an unsaved object.
1075+
if ($obj instanceof ParseObject) {
1076+
if (!$obj->getObjectId()) {
1077+
$result = false;
1078+
1079+
return;
1080+
}
1081+
}
10711082
}
1072-
});
1083+
);
10731084

10741085
return $result;
10751086
}

src/Parse/ParsePush.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ class ParsePush
3131
public static function send($data, $useMasterKey = false)
3232
{
3333
if (isset($data['expiration_time'])
34-
&& isset($data['expiration_interval'])) {
34+
&& isset($data['expiration_interval'])
35+
) {
3536
throw new \Exception(
3637
'Both expiration_time and expiration_interval can\'t be set.'
3738
);

0 commit comments

Comments
 (0)