@@ -101,9 +101,8 @@ class ParseObject implements Encodable
101
101
*
102
102
* @throws Exception
103
103
*/
104
- public function __construct ($ className = null , $ objectId = null ,
105
- $ isPointer = false
106
- ) {
104
+ public function __construct ($ className = null , $ objectId = null , $ isPointer = false )
105
+ {
107
106
if (empty (self ::$ registeredSubclasses )) {
108
107
throw new Exception (
109
108
'You must initialize the ParseClient using ParseClient::initialize ' .
@@ -266,7 +265,9 @@ private function hasDirtyChildren()
266
265
{
267
266
$ result = false ;
268
267
self ::traverse (
269
- true , $ this ->estimatedData , function ($ object ) use (&$ result ) {
268
+ true ,
269
+ $ this ->estimatedData ,
270
+ function ($ object ) use (&$ result ) {
270
271
if ($ object instanceof ParseObject) {
271
272
if ($ object ->isDirty ()) {
272
273
$ result = true ;
@@ -474,9 +475,8 @@ public function getUpdatedAt()
474
475
*
475
476
* @return object
476
477
*/
477
- public static function create ($ className , $ objectId = null ,
478
- $ isPointer = false
479
- ) {
478
+ public static function create ($ className , $ objectId = null , $ isPointer = false )
479
+ {
480
480
if (isset (self ::$ registeredSubclasses [$ className ])) {
481
481
return new self::$ registeredSubclasses [$ className ](
482
482
$ className , $ objectId , $ isPointer
@@ -502,7 +502,9 @@ public function fetch($useMasterKey = false)
502
502
$ response = ParseClient::_request (
503
503
'GET ' ,
504
504
'classes/ ' .$ this ->className .'/ ' .$ this ->objectId ,
505
- $ sessionToken , null , $ useMasterKey
505
+ $ sessionToken ,
506
+ null ,
507
+ $ useMasterKey
506
508
);
507
509
$ this ->_mergeAfterFetch ($ response );
508
510
@@ -771,9 +773,7 @@ public static function destroyAll(array $objects, $useMasterKey = false)
771
773
}
772
774
}
773
775
if (count ($ errors )) {
774
- throw new ParseAggregateException (
775
- 'Errors during batch destroy. ' , $ errors
776
- );
776
+ throw new ParseAggregateException ('Errors during batch destroy. ' , $ errors );
777
777
}
778
778
}
779
779
@@ -795,7 +795,9 @@ private static function destroyBatch(array $objects, $useMasterKey = false)
795
795
$ sessionToken = ParseUser::getCurrentUser ()->getSessionToken ();
796
796
}
797
797
$ result = ParseClient::_request (
798
- 'POST ' , 'batch ' , $ sessionToken ,
798
+ 'POST ' ,
799
+ 'batch ' ,
800
+ $ sessionToken ,
799
801
json_encode (['requests ' => $ data ]),
800
802
$ useMasterKey
801
803
);
@@ -1004,13 +1006,19 @@ private static function deepSave($target, $useMasterKey = false)
1004
1006
$ req = $ requests [0 ];
1005
1007
$ result = ParseClient::_request (
1006
1008
$ req ['method ' ],
1007
- $ req ['path ' ], $ sessionToken , json_encode ($ req ['body ' ]), $ useMasterKey
1009
+ $ req ['path ' ],
1010
+ $ sessionToken ,
1011
+ json_encode ($ req ['body ' ]),
1012
+ $ useMasterKey
1008
1013
);
1009
1014
$ batch [0 ]->mergeAfterSave ($ result );
1010
1015
} else {
1011
1016
$ result = ParseClient::_request (
1012
- 'POST ' , 'batch ' , $ sessionToken ,
1013
- json_encode (['requests ' => $ requests ]), $ useMasterKey
1017
+ 'POST ' ,
1018
+ 'batch ' ,
1019
+ $ sessionToken ,
1020
+ json_encode (['requests ' => $ requests ]),
1021
+ $ useMasterKey
1014
1022
);
1015
1023
1016
1024
$ errorCollection = [];
@@ -1037,9 +1045,7 @@ private static function deepSave($target, $useMasterKey = false)
1037
1045
}
1038
1046
}
1039
1047
if (count ($ errorCollection )) {
1040
- throw new ParseAggregateException (
1041
- 'Errors during batch save. ' , $ errorCollection
1042
- );
1048
+ throw new ParseAggregateException ('Errors during batch save. ' , $ errorCollection );
1043
1049
}
1044
1050
}
1045
1051
}
@@ -1052,11 +1058,12 @@ private static function deepSave($target, $useMasterKey = false)
1052
1058
* @param array &$unsavedChildren Array to populate with children.
1053
1059
* @param array &$unsavedFiles Array to populate with files.
1054
1060
*/
1055
- private static function findUnsavedChildren ($ object ,
1056
- &$ unsavedChildren , &$ unsavedFiles
1057
- ) {
1061
+ private static function findUnsavedChildren ($ object , &$ unsavedChildren , &$ unsavedFiles )
1062
+ {
1058
1063
static ::traverse (
1059
- true , $ object , function ($ obj ) use (
1064
+ true ,
1065
+ $ object ,
1066
+ function ($ obj ) use (
1060
1067
&$ unsavedChildren ,
1061
1068
&$ unsavedFiles
1062
1069
) {
@@ -1084,17 +1091,19 @@ private static function findUnsavedChildren($object,
1084
1091
*
1085
1092
* @return mixed The result of calling mapFunction on the root object.
1086
1093
*/
1087
- private static function traverse ($ deep , &$ object , $ mapFunction ,
1088
- $ seen = []
1089
- ) {
1094
+ private static function traverse ($ deep , &$ object , $ mapFunction , $ seen = [])
1095
+ {
1090
1096
if ($ object instanceof self) {
1091
1097
if (in_array ($ object , $ seen , true )) {
1092
1098
return ;
1093
1099
}
1094
1100
$ seen [] = $ object ;
1095
1101
if ($ deep ) {
1096
1102
self ::traverse (
1097
- $ deep , $ object ->estimatedData , $ mapFunction , $ seen
1103
+ $ deep ,
1104
+ $ object ->estimatedData ,
1105
+ $ mapFunction ,
1106
+ $ seen
1098
1107
);
1099
1108
}
1100
1109
@@ -1136,7 +1145,9 @@ private static function canBeSerializedAsValue($object)
1136
1145
{
1137
1146
$ result = true ;
1138
1147
self ::traverse (
1139
- false , $ object , function ($ obj ) use (&$ result ) {
1148
+ false ,
1149
+ $ object ,
1150
+ function ($ obj ) use (&$ result ) {
1140
1151
// short circuit as soon as possible.
1141
1152
if ($ result === false ) {
1142
1153
return ;
@@ -1200,7 +1211,7 @@ public function getRelation($key, $className = null)
1200
1211
public function _toPointer ()
1201
1212
{
1202
1213
if (!$ this ->objectId ) {
1203
- throw new \ Exception ("Can't serialize an unsaved Parse.Object " );
1214
+ throw new Exception ("Can't serialize an unsaved Parse.Object " );
1204
1215
}
1205
1216
1206
1217
return [
@@ -1256,7 +1267,7 @@ public static function registerSubclass()
1256
1267
get_called_class ();
1257
1268
}
1258
1269
} else {
1259
- throw new \ Exception (
1270
+ throw new Exception (
1260
1271
'Cannot register a subclass that does not have a parseClassName '
1261
1272
);
1262
1273
}
0 commit comments