Skip to content

Commit 9c5a592

Browse files
Fixes
1 parent 08c0d5b commit 9c5a592

File tree

4 files changed

+55
-58
lines changed

4 files changed

+55
-58
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
.idea
2-
vendor/
32
composer.lock
3+
vendor

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ For us to accept contributions you will have to first have signed the
55
[Contributor License Agreement].
66

77
When committing, keep all lines to less than 80 characters, and try to
8-
follow the existing style. Before creating a pull request, squash your commits
8+
follow the existing style. Before creating a pull request, squash your commits
99
into a single commit. Please provide ample explanation in the commit message.
1010

1111
Installation
1212
------------
1313

14-
Testing the Parse PHP SDK involves some set-up. You'll need to create a Parse
14+
Testing the Parse PHP SDK involves some set-up. You'll need to create a Parse
1515
App just for testing, and deploy some cloud code to it.
1616

1717
* [Get Composer], the PHP package manager.
@@ -31,4 +31,4 @@ At present the full suite of tests takes around 20 minutes.
3131

3232
[Get Composer]: https://getcomposer.org/download/
3333
[Contributor License Agreement]: https://developers.facebook.com/opensource/cla
34-
[Create Parse App]: https://parse.com/apps/new
34+
[Create Parse App]: https://parse.com/apps/new

README.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ from your PHP app or script.
77
Installation
88
------------
99

10-
[Get Composer], the PHP package manager. Then create a composer.json file in
10+
[Get Composer], the PHP package manager. Then create a composer.json file in
1111
your projects root folder, containing:
1212

1313
```json
1414
{
15-
"require": {
16-
"parse/php-sdk" : "1.1.*"
17-
}
15+
"require": {
16+
"parse/php-sdk" : "1.1.*"
17+
}
1818
}
1919
```
2020

@@ -51,7 +51,7 @@ Usage
5151

5252
Check out the [Parse PHP Guide] for the full documentation.
5353

54-
Add the "use" declarations where you'll be using the classes. For all of the
54+
Add the "use" declarations where you'll be using the classes. For all of the
5555
sample code in this file:
5656

5757
```php
@@ -80,7 +80,7 @@ $object->set("elephant", "php");
8080
$object->set("today", new DateTime());
8181
$object->setArray("mylist", [1, 2, 3]);
8282
$object->setAssociativeArray(
83-
"languageTypes", array("php" => "awesome", "ruby" => "wtf")
83+
"languageTypes", array("php" => "awesome", "ruby" => "wtf")
8484
);
8585

8686
// Save:
@@ -95,16 +95,16 @@ $user = new ParseUser();
9595
$user->setUsername("foo");
9696
$user->setPassword("Q2w#4!o)df");
9797
try {
98-
$user->signUp();
98+
$user->signUp();
9999
} catch (ParseException $ex) {
100-
// error in $ex->getMessage();
100+
// error in $ex->getMessage();
101101
}
102102

103103
// Login
104104
try {
105-
$user = ParseUser::logIn("foo", "Q2w#4!o)df");
105+
$user = ParseUser::logIn("foo", "Q2w#4!o)df");
106106
} catch(ParseException $ex) {
107-
// error in $ex->getMessage();
107+
// error in $ex->getMessage();
108108
}
109109

110110
// Current user
@@ -147,7 +147,7 @@ $first = $query->first();
147147
// Process ALL (without limit) results with "each".
148148
// Will throw if sort, skip, or limit is used.
149149
$query->each(function($obj) {
150-
echo $obj->getObjectId();
150+
echo $obj->getObjectId();
151151
});
152152
```
153153

@@ -161,8 +161,8 @@ Analytics:
161161

162162
```php
163163
ParseAnalytics::track("logoReaction", array(
164-
"saw" => "elephant",
165-
"said" => "cute"
164+
"saw" => "elephant",
165+
"said" => "cute"
166166
));
167167
```
168168

@@ -178,7 +178,7 @@ $contents = $file->getData();
178178

179179
// Upload from a local file:
180180
$file = ParseFile::createFromFile(
181-
"/tmp/foo.bar", "Parse.txt", "text/plain"
181+
"/tmp/foo.bar", "Parse.txt", "text/plain"
182182
);
183183

184184
// Upload from variable contents (string, binary)
@@ -192,24 +192,24 @@ $data = array("alert" => "Hi!");
192192

193193
// Push to Channels
194194
ParsePush::send(array(
195-
"channels" => ["PHPFans"],
196-
"data" => $data
195+
"channels" => ["PHPFans"],
196+
"data" => $data
197197
));
198198

199199
// Push to Query
200200
$query = ParseInstallation::query();
201201
$query->equalTo("design", "rad");
202202
ParsePush::send(array(
203-
"where" => $query,
204-
"data" => $data
203+
"where" => $query,
204+
"data" => $data
205205
));
206206
```
207207

208208
Contributing / Testing
209209
----------------------
210210

211211
See the CONTRIBUTORS.md file for information on testing and contributing to
212-
the Parse PHP SDK. We welcome fixes and enhancements.
212+
the Parse PHP SDK. We welcome fixes and enhancements.
213213

214214
[Get Composer]: https://getcomposer.org/download/
215215
[Parse PHP Guide]: https://www.parse.com/docs/php_guide

autoload.php

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,45 @@
11
<?php
22

3-
/**
3+
/*
44
* You only need this file if you are not using composer.
55
*/
66

77
if (version_compare(PHP_VERSION, '5.4.0', '<')) {
8-
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.');
99
}
1010

11-
/**
12-
* Register the autoloader for the Parse SDK
11+
/*
12+
* Register the autoloader for the Parse SDK.
13+
*
1314
* Based off the official PSR-4 autoloader example found here:
1415
* https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader-examples.md
15-
*
16-
* @param string $class The fully-qualified class name.
17-
* @return void
1816
*/
17+
1918
spl_autoload_register(function ($class)
2019
{
21-
// Parse class prefix
22-
$prefix = 'Parse\\';
23-
24-
// base directory for the namespace prefix
25-
$base_dir = defined('PARSE_SDK_DIR') ? PARSE_SDK_DIR : __DIR__ . '/src/Parse/';
26-
27-
// does the class use the namespace prefix?
28-
$len = strlen( $prefix );
29-
if ( strncmp($prefix, $class, $len) !== 0 ) {
30-
// no, move to the next registered autoloader
31-
return;
32-
}
33-
34-
// get the relative class name
35-
$relative_class = substr( $class, $len );
36-
37-
// replace the namespace prefix with the base directory, replace namespace
38-
// separators with directory separators in the relative class name, append
39-
// with .php
40-
$file = $base_dir . str_replace( '\\', '/', $relative_class ) . '.php';
41-
42-
// echo $relative_class . '<br/>';
43-
44-
// if the file exists, require it
45-
if ( file_exists( $file ) ) {
46-
require $file;
47-
}
48-
});
20+
// Parse class prefix
21+
$prefix = 'Parse\\';
22+
23+
// base directory for the namespace prefix
24+
$base_dir = defined('PARSE_SDK_DIR') ? PARSE_SDK_DIR : __DIR__ . '/src/Parse/';
25+
26+
// does the class use the namespace prefix?
27+
$len = strlen( $prefix );
28+
if ( strncmp($prefix, $class, $len) !== 0 ) {
29+
// no, move to the next registered autoloader
30+
return;
31+
}
32+
33+
// get the relative class name
34+
$relative_class = substr( $class, $len );
35+
36+
// replace the namespace prefix with the base directory, replace namespace
37+
// separators with directory separators in the relative class name, append
38+
// with .php
39+
$file = $base_dir . str_replace( '\\', '/', $relative_class ) . '.php';
40+
41+
// if the file exists, require it
42+
if ( file_exists( $file ) ) {
43+
require $file;
44+
}
45+
});

0 commit comments

Comments
 (0)