Skip to content

Commit 08c0d5b

Browse files
Revert "Updated to full compliance with StyleCI"
This reverts commit 4d814ba.
1 parent b738bc4 commit 08c0d5b

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

+5887
-5919
lines changed

autoload.php

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,46 @@
33
/**
44
* You only need this file if you are not using composer.
55
*/
6+
67
if (version_compare(PHP_VERSION, '5.4.0', '<')) {
7-
throw new Exception('The Parse SDK requires PHP version 5.4 or higher.');
8+
throw new Exception('The Parse SDK requires PHP version 5.4 or higher.');
89
}
910

10-
/*
11+
/**
1112
* Register the autoloader for the Parse SDK
1213
* Based off the official PSR-4 autoloader example found here:
1314
* https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader-examples.md
1415
*
1516
* @param string $class The fully-qualified class name.
1617
* @return void
1718
*/
18-
spl_autoload_register(function ($class) {
19+
spl_autoload_register(function ($class)
20+
{
1921
// Parse class prefix
2022
$prefix = 'Parse\\';
2123

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

2527
// does the class use the namespace prefix?
26-
$len = strlen($prefix);
27-
if (strncmp($prefix, $class, $len) !== 0) {
28-
// no, move to the next registered autoloader
28+
$len = strlen( $prefix );
29+
if ( strncmp($prefix, $class, $len) !== 0 ) {
30+
// no, move to the next registered autoloader
2931
return;
3032
}
3133

3234
// get the relative class name
33-
$relative_class = substr($class, $len);
35+
$relative_class = substr( $class, $len );
3436

3537
// replace the namespace prefix with the base directory, replace namespace
3638
// separators with directory separators in the relative class name, append
3739
// with .php
38-
$file = $base_dir.str_replace('\\', '/', $relative_class).'.php';
39-
40+
$file = $base_dir . str_replace( '\\', '/', $relative_class ) . '.php';
41+
4042
// echo $relative_class . '<br/>';
4143

4244
// if the file exists, require it
43-
if (file_exists($file)) {
44-
require $file;
45+
if ( file_exists( $file ) ) {
46+
require $file;
4547
}
46-
});
48+
});

src/Parse/Internal/AddOperation.php

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
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
1112
* @author Fosco Marotto <fjm@fb.com>
1213
*/
1314
class AddOperation implements FieldOperation
1415
{
16+
1517
/**
1618
* @var - Array with objects to add.
1719
*/
@@ -26,10 +28,10 @@ class AddOperation implements FieldOperation
2628
*/
2729
public function __construct($objects)
2830
{
29-
if (!is_array($objects)) {
30-
throw new ParseException("AddOperation requires an array.");
31-
}
32-
$this->objects = $objects;
31+
if (!is_array($objects)) {
32+
throw new ParseException("AddOperation requires an array.");
33+
}
34+
$this->objects = $objects;
3335
}
3436

3537
/**
@@ -39,7 +41,7 @@ public function __construct($objects)
3941
*/
4042
public function getValue()
4143
{
42-
return $this->objects;
44+
return $this->objects;
4345
}
4446

4547
/**
@@ -49,42 +51,39 @@ public function getValue()
4951
*/
5052
public function _encode()
5153
{
52-
return ['__op' => 'Add',
53-
'objects' => ParseClient::_encode($this->objects, true), ];
54+
return array('__op' => 'Add',
55+
'objects' => ParseClient::_encode($this->objects, true));
5456
}
5557

5658
/**
5759
* Takes a previous operation and returns a merged operation to replace it.
5860
*
5961
* @param FieldOperation $previous Previous operation.
6062
*
61-
* @throws ParseException
62-
*
6363
* @return FieldOperation Merged operation.
64+
* @throws ParseException
6465
*/
6566
public function _mergeWithPrevious($previous)
6667
{
67-
if (!$previous) {
68-
return $this;
69-
}
70-
if ($previous instanceof DeleteOperation) {
71-
return new SetOperation($this->objects);
72-
}
73-
if ($previous instanceof SetOperation) {
74-
$oldList = $previous->getValue();
75-
76-
return new SetOperation(
77-
array_merge((array) $oldList, (array) $this->objects)
68+
if (!$previous) {
69+
return $this;
70+
}
71+
if ($previous instanceof DeleteOperation) {
72+
return new SetOperation($this->objects);
73+
}
74+
if ($previous instanceof SetOperation) {
75+
$oldList = $previous->getValue();
76+
return new SetOperation(
77+
array_merge((array)$oldList, (array)$this->objects)
7878
);
79-
}
80-
if ($previous instanceof AddOperation) {
81-
$oldList = $previous->getValue();
82-
83-
return new SetOperation(
84-
array_merge((array) $oldList, (array) $this->objects)
79+
}
80+
if ($previous instanceof AddOperation) {
81+
$oldList = $previous->getValue();
82+
return new SetOperation(
83+
array_merge((array)$oldList, (array)$this->objects)
8584
);
86-
}
87-
throw new ParseException(
85+
}
86+
throw new ParseException(
8887
'Operation is invalid after previous operation.'
8988
);
9089
}
@@ -100,10 +99,10 @@ public function _mergeWithPrevious($previous)
10099
*/
101100
public function _apply($oldValue, $obj, $key)
102101
{
103-
if (!$oldValue) {
104-
return $this->objects;
105-
}
106-
107-
return array_merge((array) $oldValue, (array) $this->objects);
102+
if (!$oldValue) {
103+
return $this->objects;
104+
}
105+
return array_merge((array)$oldValue, (array)$this->objects);
108106
}
109-
}
107+
108+
}

src/Parse/Internal/AddUniqueOperation.php

Lines changed: 59 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
/**
99
* Class AddUniqueOperation - Operation to add unique objects to an array key.
1010
*
11+
* @package Parse
1112
* @author Fosco Marotto <fjm@fb.com>
1213
*/
1314
class AddUniqueOperation implements FieldOperation
1415
{
16+
1517
/**
1618
* @var - Array containing objects to add.
1719
*/
@@ -26,10 +28,10 @@ class AddUniqueOperation implements FieldOperation
2628
*/
2729
public function __construct($objects)
2830
{
29-
if (!is_array($objects)) {
30-
throw new ParseException("AddUniqueOperation requires an array.");
31-
}
32-
$this->objects = $objects;
31+
if (!is_array($objects)) {
32+
throw new ParseException("AddUniqueOperation requires an array.");
33+
}
34+
$this->objects = $objects;
3335
}
3436

3537
/**
@@ -39,7 +41,7 @@ public function __construct($objects)
3941
*/
4042
public function getValue()
4143
{
42-
return $this->objects;
44+
return $this->objects;
4345
}
4446

4547
/**
@@ -49,40 +51,37 @@ public function getValue()
4951
*/
5052
public function _encode()
5153
{
52-
return ['__op' => 'AddUnique',
53-
'objects' => ParseClient::_encode($this->objects, true), ];
54+
return array('__op' => 'AddUnique',
55+
'objects' => ParseClient::_encode($this->objects, true));
5456
}
5557

5658
/**
5759
* Merge this operation with the previous operation and return the result.
5860
*
5961
* @param FieldOperation $previous Previous Operation.
6062
*
61-
* @throws ParseException
62-
*
6363
* @return FieldOperation Merged Operation.
64+
* @throws ParseException
6465
*/
6566
public function _mergeWithPrevious($previous)
6667
{
67-
if (!$previous) {
68-
return $this;
69-
}
70-
if ($previous instanceof DeleteOperation) {
71-
return new SetOperation($this->objects);
72-
}
73-
if ($previous instanceof SetOperation) {
74-
$oldValue = $previous->getValue();
75-
$result = $this->_apply($oldValue, null, null);
76-
77-
return new SetOperation($result);
78-
}
79-
if ($previous instanceof AddUniqueOperation) {
80-
$oldList = $previous->getValue();
81-
$result = $this->_apply($oldList, null, null);
82-
83-
return new AddUniqueOperation($result);
84-
}
85-
throw new ParseException(
68+
if (!$previous) {
69+
return $this;
70+
}
71+
if ($previous instanceof DeleteOperation) {
72+
return new SetOperation($this->objects);
73+
}
74+
if ($previous instanceof SetOperation) {
75+
$oldValue = $previous->getValue();
76+
$result = $this->_apply($oldValue, null, null);
77+
return new SetOperation($result);
78+
}
79+
if ($previous instanceof AddUniqueOperation) {
80+
$oldList = $previous->getValue();
81+
$result = $this->_apply($oldList, null, null);
82+
return new AddUniqueOperation($result);
83+
}
84+
throw new ParseException(
8685
'Operation is invalid after previous operation.'
8786
);
8887
}
@@ -98,41 +97,40 @@ public function _mergeWithPrevious($previous)
9897
*/
9998
public function _apply($oldValue, $obj, $key)
10099
{
101-
if (!$oldValue) {
102-
return $this->objects;
103-
}
104-
if (!is_array($oldValue)) {
105-
$oldValue = (array) $oldValue;
106-
}
107-
foreach ($this->objects as $object) {
108-
if ($object instanceof ParseObject && $object->getObjectId()) {
109-
if (!$this->isParseObjectInArray($object, $oldValue)) {
110-
$oldValue[] = $object;
111-
}
112-
} elseif (is_object($object)) {
113-
if (!in_array($object, $oldValue, true)) {
114-
$oldValue[] = $object;
115-
}
116-
} else {
117-
if (!in_array($object, $oldValue, true)) {
118-
$oldValue[] = $object;
119-
}
120-
}
100+
if (!$oldValue) {
101+
return $this->objects;
102+
}
103+
if (!is_array($oldValue)) {
104+
$oldValue = (array)$oldValue;
105+
}
106+
foreach ($this->objects as $object) {
107+
if ($object instanceof ParseObject && $object->getObjectId()) {
108+
if (!$this->isParseObjectInArray($object, $oldValue)) {
109+
$oldValue[] = $object;
110+
}
111+
} else if (is_object($object)) {
112+
if (!in_array($object, $oldValue, true)) {
113+
$oldValue[] = $object;
114+
}
115+
} else {
116+
if (!in_array($object, $oldValue, true)) {
117+
$oldValue[] = $object;
118+
}
121119
}
122-
123-
return $oldValue;
120+
}
121+
return $oldValue;
124122
}
125123

126-
private function isParseObjectInArray($parseObject, $oldValue)
127-
{
128-
foreach ($oldValue as $object) {
129-
if ($object instanceof ParseObject && $object->getObjectId() != null) {
130-
if ($object->getObjectId() == $parseObject->getObjectId()) {
131-
return true;
132-
}
133-
}
124+
private function isParseObjectInArray($parseObject, $oldValue)
125+
{
126+
foreach ($oldValue as $object) {
127+
if ($object instanceof ParseObject && $object->getObjectId() != null) {
128+
if ($object->getObjectId() == $parseObject->getObjectId()) {
129+
return true;
134130
}
135-
136-
return false;
131+
}
137132
}
138-
}
133+
return false;
134+
}
135+
136+
}

src/Parse/Internal/DeleteOperation.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,20 @@
55
/**
66
* Class DeleteOperation - FieldOperation to remove a key from an object.
77
*
8+
* @package Parse
89
* @author Fosco Marotto <fjm@fb.com>
910
*/
1011
class DeleteOperation implements FieldOperation
1112
{
13+
1214
/**
1315
* Returns an associative array encoding of the current operation.
1416
*
1517
* @return array Associative array encoding the operation.
1618
*/
1719
public function _encode()
1820
{
19-
return ['__op' => 'Delete'];
21+
return array('__op' => 'Delete');
2022
}
2123

2224
/**
@@ -30,7 +32,7 @@ public function _encode()
3032
*/
3133
public function _apply($oldValue, $object, $key)
3234
{
33-
return;
35+
return null;
3436
}
3537

3638
/**
@@ -42,6 +44,7 @@ public function _apply($oldValue, $object, $key)
4244
*/
4345
public function _mergeWithPrevious($previous)
4446
{
45-
return $this;
47+
return $this;
4648
}
47-
}
49+
50+
}

0 commit comments

Comments
 (0)